Skip to content

Commit 394ccd4

Browse files
committed
Fix assign reflectionclass to list uninitialized properties
1 parent 6624ef2 commit 394ccd4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Mvc/Collection.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
use Phalcon\Messages\MessageInterface;
3333
use Phalcon\Mvc\EntityInterface;
3434
use Phalcon\Validation\ValidationInterface;
35+
use ReflectionClass;
36+
use ReflectionException;
3537
use Serializable;
3638
use Traversable;
3739

@@ -1494,6 +1496,7 @@ final protected function possibleGetter(string $property)
14941496
* @param null $dataColumnMap
14951497
* @param null $whiteList
14961498
* @return $this|CollectionInterface
1499+
* @throws ReflectionException
14971500
*/
14981501
public function assign(array $data, $dataColumnMap = null, $whiteList = null): CollectionInterface
14991502
{
@@ -1513,7 +1516,12 @@ public function assign(array $data, $dataColumnMap = null, $whiteList = null): C
15131516
return $this;
15141517
}
15151518

1516-
foreach (get_object_vars($this) as $key => $value) {
1519+
// Use reflection to list uninitialized properties
1520+
$reflection = new ReflectionClass($this);
1521+
1522+
foreach ($reflection->getProperties() as $reflectionMethod) {
1523+
$key = $reflectionMethod->getName();
1524+
15171525
if (isset($dataMapped[$key])) {
15181526
if (is_array($whiteList) && !in_array($key, $whiteList, true)) {
15191527
continue;

0 commit comments

Comments
 (0)