make addScalar friendlier to subclassing
authorgggeek <giunta.gaetano@gmail.com>
Wed, 18 Jan 2023 17:29:28 +0000 (17:29 +0000)
committergggeek <giunta.gaetano@gmail.com>
Wed, 18 Jan 2023 17:29:28 +0000 (17:29 +0000)
src/Value.php

index 8aebe35..03a8108 100644 (file)
@@ -177,7 +177,8 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
                 return 0;
             case 2:
                 // we're adding a scalar value to an array here
-                $this->me['array'][] = new Value($val, $type);
+                $class = get_class($this);
+                $this->me['array'][] = new $class($val, $type);
 
                 return 1;
             default: