function PropertyMetadata::getPropertyValue
Overrides PropertyMetadataInterface::getPropertyValue
File
-
vendor/
symfony/ validator/ Mapping/ PropertyMetadata.php, line 46
Class
- PropertyMetadata
- Stores all metadata needed for validating a class property.
Namespace
Symfony\Component\Validator\MappingCode
public function getPropertyValue(mixed $object) : mixed {
$reflProperty = $this->getReflectionMember($object);
if ($reflProperty->hasType() && !$reflProperty->isInitialized($object)) {
// There is no way to check if a property has been unset or if it is uninitialized.
// When trying to access an uninitialized property, __get method is triggered.
// If __get method is not present, no fallback is possible
// Otherwise we need to catch an Error in case we are trying to access an uninitialized but set property.
if (!method_exists($object, '__get')) {
return null;
}
try {
return $reflProperty->getValue($object);
} catch (\Error) {
return null;
}
}
return $reflProperty->getValue($object);
}