Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AttributeLoader.php

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\Loader

Code

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);
            }
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal