File manager - Edit - /var/www/payraty/helpdesk/vendor/rector/rector/vendor/symfony/contracts/Service/ServiceSubscriberTrait.php
Back
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace RectorPrefix202208\Symfony\Contracts\Service; use RectorPrefix202208\Psr\Container\ContainerInterface; use RectorPrefix202208\Symfony\Contracts\Service\Attribute\Required; use RectorPrefix202208\Symfony\Contracts\Service\Attribute\SubscribedService; /** * Implementation of ServiceSubscriberInterface that determines subscribed services from * method return types. Service ids are available as "ClassName::methodName". * * @author Kevin Bond <kevinbond@gmail.com> */ trait ServiceSubscriberTrait { /** @var ContainerInterface */ protected $container; /** * {@inheritdoc} */ public static function getSubscribedServices() : array { $services = \method_exists(\get_parent_class(self::class) ?: '', __FUNCTION__) ? parent::getSubscribedServices() : []; foreach ((new \ReflectionClass(self::class))->getMethods() as $method) { if (self::class !== $method->getDeclaringClass()->name) { continue; } if (!($attribute = (\method_exists($method, 'getAttributes') ? $method->getAttributes(SubscribedService::class) : [])[0] ?? null)) { continue; } if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) { throw new \LogicException(\sprintf('Cannot use "%s" on method "%s::%s()" (can only be used on non-static, non-abstract methods with no parameters).', SubscribedService::class, self::class, $method->name)); } if (!($returnType = $method->getReturnType())) { throw new \LogicException(\sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class)); } $serviceId = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType; if ($returnType->allowsNull()) { $serviceId = '?' . $serviceId; } $services[$attribute->newInstance()->key ?? self::class . '::' . $method->name] = $serviceId; } return $services; } /** * @required */ public function setContainer(ContainerInterface $container) : ?ContainerInterface { $this->container = $container; if (\method_exists(\get_parent_class(self::class) ?: '', __FUNCTION__)) { return parent::setContainer($container); } return null; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0 |
proxy
|
phpinfo
|
Settings