function AttributeLoader::loadAttributes
1 call to AttributeLoader::loadAttributes()
- AttributeLoader::loadClassMetadata in vendor/
symfony/ serializer/ Mapping/ Loader/ AttributeLoader.php
File
-
vendor/
symfony/ serializer/ Mapping/ Loader/ AttributeLoader.php, line 175
Class
- AttributeLoader
- Loader for PHP attributes.
Namespace
Symfony\Component\Serializer\Mapping\LoaderCode
private function loadAttributes(\ReflectionMethod|\ReflectionClass|\ReflectionProperty $reflector) : iterable {
foreach ($reflector->getAttributes() as $attribute) {
if ($this->isKnownAttribute($attribute->getName())) {
try {
(yield $attribute->newInstance());
} catch (\Error $e) {
if (\Error::class !== $e::class) {
throw $e;
}
$on = match (true) { $reflector instanceof \ReflectionClass => ' on class ' . $reflector->name,
$reflector instanceof \ReflectionMethod => \sprintf(' on "%s::%s()"', $reflector->getDeclaringClass()->name, $reflector->name),
$reflector instanceof \ReflectionProperty => \sprintf(' on "%s::$%s"', $reflector->getDeclaringClass()->name, $reflector->name),
default => '',
};
throw new MappingException(\sprintf('Could not instantiate attribute "%s"%s.', $attribute->getName(), $on), 0, $e);
}
}
}
}