Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

vendor/symfony/http-kernel/ControllerMetadata/ArgumentMetadataFactory.php line 24

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\HttpKernel\ControllerMetadata;
  11. /**
  12.  * Builds {@see ArgumentMetadata} objects based on the given Controller.
  13.  *
  14.  * @author Iltar van der Berg <kjarli@gmail.com>
  15.  */
  16. final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
  17. {
  18.     /**
  19.      * {@inheritdoc}
  20.      */
  21.     public function createArgumentMetadata($controller): array
  22.     {
  23.         $arguments = [];
  24.         if (\is_array($controller)) {
  25.             $reflection = new \ReflectionMethod($controller[0], $controller[1]);
  26.             $class $reflection->class;
  27.         } elseif (\is_object($controller) && !$controller instanceof \Closure) {
  28.             $reflection = new \ReflectionMethod($controller'__invoke');
  29.             $class $reflection->class;
  30.         } else {
  31.             $reflection = new \ReflectionFunction($controller);
  32.             if ($class str_contains($reflection->name'{closure}') ? null : (\PHP_VERSION_ID >= 80111 $reflection->getClosureCalledClass() : $reflection->getClosureScopeClass())) {
  33.                 $class $class->name;
  34.             }
  35.         }
  36.         foreach ($reflection->getParameters() as $param) {
  37.             $attributes = [];
  38.             if (\PHP_VERSION_ID >= 80000) {
  39.                 foreach ($param->getAttributes() as $reflectionAttribute) {
  40.                     if (class_exists($reflectionAttribute->getName())) {
  41.                         $attributes[] = $reflectionAttribute->newInstance();
  42.                     }
  43.                 }
  44.             }
  45.             $arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param$class), $param->isVariadic(), $param->isDefaultValueAvailable(), $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null$param->allowsNull(), $attributes);
  46.         }
  47.         return $arguments;
  48.     }
  49.     /**
  50.      * Returns an associated type to the given parameter if available.
  51.      */
  52.     private function getType(\ReflectionParameter $parameter, ?string $class): ?string
  53.     {
  54.         if (!$type $parameter->getType()) {
  55.             return null;
  56.         }
  57.         $name $type instanceof \ReflectionNamedType $type->getName() : (string) $type;
  58.         if (null !== $class) {
  59.             switch (strtolower($name)) {
  60.                 case 'self':
  61.                     return $class;
  62.                 case 'parent':
  63.                     return get_parent_class($class) ?: null;
  64.             }
  65.         }
  66.         return $name;
  67.     }
  68. }