Skip to content

Commit

Permalink
Merge branch '5.4' into 6.0
Browse files Browse the repository at this point in the history
* 5.4:
  [Process] intersect with getenv() in case-insensitive manner to get default envs
  [Serializer] fix support for lazy/unset properties
  Fix redundant type casts
  [Notifier] Fix AllMySms bridge body content
  Revert "[DoctrineBridge] add support for the JSON type"
  • Loading branch information
nicolas-grekas committed Nov 28, 2021
2 parents a3018d4 + 66942cf commit 110e985
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Normalizer/PropertyNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,18 @@ protected function getAttributeValue(object $object, string $attribute, string $
$reflectionProperty->setAccessible(true);
}

if (!$reflectionProperty->hasType() && !method_exists($object, '__get')) {
if ($reflectionProperty->hasType()) {
return $reflectionProperty->getValue($object);
}

if (!method_exists($object, '__get') && !isset($object->$attribute)) {
$propertyValues = (array) $object;

if (($reflectionProperty->isPublic() && !\array_key_exists($reflectionProperty->name, $propertyValues))
|| ($reflectionProperty->isProtected() && !\array_key_exists("\0*\0{$reflectionProperty->name}", $propertyValues))
|| ($reflectionProperty->isPrivate() && !\array_key_exists("\0{$reflectionProperty->class}\0{$reflectionProperty->name}", $propertyValues))
) {
throw new UninitializedPropertyException(sprintf('The property "%s::$%s" is not initialized.', $reflectionProperty->class, $reflectionProperty->name));
throw new UninitializedPropertyException(sprintf('The property "%s::$%s" is not initialized.', \get_class($object), $reflectionProperty->name));
}
}

Expand Down

0 comments on commit 110e985

Please sign in to comment.