Test
3 years ago
ResetInterface.php
4 years ago
ServiceLocatorTrait.php
4 years ago
ServiceProviderInterface.php
4 years ago
ServiceSubscriberInterface.php
4 years ago
ServiceSubscriberTrait.php
4 years ago
index.php
3 years ago
ServiceSubscriberTrait.php
41 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Contracts\Service; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Psr\Container\ContainerInterface; |
| 5 | trait ServiceSubscriberTrait |
| 6 | { |
| 7 | protected $container; |
| 8 | public static function getSubscribedServices() : array |
| 9 | { |
| 10 | static $services; |
| 11 | if (null !== $services) { |
| 12 | return $services; |
| 13 | } |
| 14 | $services = \is_callable(['parent', __FUNCTION__]) ? parent::getSubscribedServices() : []; |
| 15 | foreach ((new \ReflectionClass(self::class))->getMethods() as $method) { |
| 16 | if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) { |
| 17 | continue; |
| 18 | } |
| 19 | if (self::class !== $method->getDeclaringClass()->name) { |
| 20 | continue; |
| 21 | } |
| 22 | if (!($returnType = $method->getReturnType()) instanceof \ReflectionNamedType) { |
| 23 | continue; |
| 24 | } |
| 25 | if ($returnType->isBuiltin()) { |
| 26 | continue; |
| 27 | } |
| 28 | $services[self::class . '::' . $method->name] = '?' . $returnType->getName(); |
| 29 | } |
| 30 | return $services; |
| 31 | } |
| 32 | public function setContainer(ContainerInterface $container) |
| 33 | { |
| 34 | $this->container = $container; |
| 35 | if (\is_callable(['parent', __FUNCTION__])) { |
| 36 | return parent::setContainer($container); |
| 37 | } |
| 38 | return null; |
| 39 | } |
| 40 | } |
| 41 |