diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a66a0c0..0061dfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,3 +45,6 @@ jobs: - name: Run phpunit run: composer test + + - name: Run easy coding standard + run: composer cs-check diff --git a/composer.json b/composer.json index 47f200d..6e23114 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,6 @@ "doctrine/orm": "^2.5", "php-coveralls/php-coveralls": "^2.0", "symfony/yaml": "^4.0 | ^5.0 | ^6.0", - "friendsofphp/php-cs-fixer": "^3.4", "phpstan/phpstan": "^1.3", "phpspec/prophecy-phpunit": "^2.0", "laminas/laminas-hydrator": "^4.2", @@ -59,7 +58,9 @@ "laminas/laminas-filter": "^2.11", "laminas/laminas-form": "^3.0", "laminas/laminas-inputfilter": "^2.12", - "bnf/phpstan-psr-container": "^1.0" + "bnf/phpstan-psr-container": "^1.0", + "symplify/easy-coding-standard": "^11.2", + "doctrine/annotations": "^2.0" }, "extra": { "zf": { @@ -73,6 +74,8 @@ } }, "scripts": { + "cs-check": "ecs check", + "cs-fix": "ecs check --fix", "phpstan": "./vendor/bin/phpstan analyse -c phpstan.neon", "test": "vendor/bin/phpunit --no-coverage", "test-with-coverage": "vendor/bin/phpunit --coverage-clover=build/coverage.xml", diff --git a/config/module.config.php b/config/module.config.php index 7106992..0ee66ba 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -1,25 +1,27 @@ [ - 'factories' => [ - \Reinfi\DependencyInjection\Config\ModuleConfig::class => \Reinfi\DependencyInjection\Config\Factory\ModuleConfigFactory::class, - \Reinfi\DependencyInjection\Service\Extractor\AnnotationExtractor::class => \Reinfi\DependencyInjection\Service\Extractor\Factory\AnnotationExtractorFactory::class, - \Reinfi\DependencyInjection\Service\Extractor\AttributeExtractor::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, - \Reinfi\DependencyInjection\Service\Extractor\YamlExtractor::class => \Reinfi\DependencyInjection\Service\Extractor\Factory\YamlExtractorFactory::class, - \Reinfi\DependencyInjection\Service\InjectionService::class => \Reinfi\DependencyInjection\Service\Factory\InjectionServiceFactory::class, - \Reinfi\DependencyInjection\Service\CacheService::class => \Reinfi\DependencyInjection\Service\Factory\CacheServiceFactory::class, - \Reinfi\DependencyInjection\Service\ConfigService::class => \Reinfi\DependencyInjection\Service\Factory\ConfigServiceFactory::class, - \Reinfi\DependencyInjection\Service\AutoWiringService::class => \Reinfi\DependencyInjection\Service\Factory\AutoWiringServiceFactory::class, - \Reinfi\DependencyInjection\Service\Extractor\ExtractorInterface::class => \Reinfi\DependencyInjection\Service\Extractor\Factory\ExtractorFactory::class, - \Reinfi\DependencyInjection\Service\AutoWiring\ResolverService::class => \Reinfi\DependencyInjection\Service\AutoWiring\Factory\ResolverServiceFactory::class, - \Reinfi\DependencyInjection\Service\AutoWiring\LazyResolverService::class => \Reinfi\DependencyInjection\Service\AutoWiring\Factory\LazyResolverServiceFactory::class, - \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\ContainerResolver::class => \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\Factory\ContainerResolverFactory::class, - \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\ContainerInterfaceResolver::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, - \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\PluginManagerResolver::class => \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\Factory\PluginManagerResolverFactory::class, - \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\RequestResolver::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, - \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\ResponseResolver::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, - \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\TranslatorResolver::class => \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\Factory\TranslatorResolverFactory::class, + 'factories' => [ + \Reinfi\DependencyInjection\Config\ModuleConfig::class => \Reinfi\DependencyInjection\Config\Factory\ModuleConfigFactory::class, + \Reinfi\DependencyInjection\Service\Extractor\AnnotationExtractor::class => \Reinfi\DependencyInjection\Service\Extractor\Factory\AnnotationExtractorFactory::class, + \Reinfi\DependencyInjection\Service\Extractor\AttributeExtractor::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, + \Reinfi\DependencyInjection\Service\Extractor\YamlExtractor::class => \Reinfi\DependencyInjection\Service\Extractor\Factory\YamlExtractorFactory::class, + \Reinfi\DependencyInjection\Service\InjectionService::class => \Reinfi\DependencyInjection\Service\Factory\InjectionServiceFactory::class, + \Reinfi\DependencyInjection\Service\CacheService::class => \Reinfi\DependencyInjection\Service\Factory\CacheServiceFactory::class, + \Reinfi\DependencyInjection\Service\ConfigService::class => \Reinfi\DependencyInjection\Service\Factory\ConfigServiceFactory::class, + \Reinfi\DependencyInjection\Service\AutoWiringService::class => \Reinfi\DependencyInjection\Service\Factory\AutoWiringServiceFactory::class, + \Reinfi\DependencyInjection\Service\Extractor\ExtractorInterface::class => \Reinfi\DependencyInjection\Service\Extractor\Factory\ExtractorFactory::class, + \Reinfi\DependencyInjection\Service\AutoWiring\ResolverService::class => \Reinfi\DependencyInjection\Service\AutoWiring\Factory\ResolverServiceFactory::class, + \Reinfi\DependencyInjection\Service\AutoWiring\LazyResolverService::class => \Reinfi\DependencyInjection\Service\AutoWiring\Factory\LazyResolverServiceFactory::class, + \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\ContainerResolver::class => \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\Factory\ContainerResolverFactory::class, + \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\ContainerInterfaceResolver::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, + \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\PluginManagerResolver::class => \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\Factory\PluginManagerResolverFactory::class, + \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\RequestResolver::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, + \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\ResponseResolver::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, + \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\TranslatorResolver::class => \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\Factory\TranslatorResolverFactory::class, \Reinfi\DependencyInjection\Service\AutoWiring\Resolver\BuildInTypeWithDefaultResolver::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, \Reinfi\DependencyInjection\Command\CacheWarmupCommand::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, diff --git a/ecs.php b/ecs.php new file mode 100644 index 0000000..e168a6b --- /dev/null +++ b/ecs.php @@ -0,0 +1,26 @@ +parallel(); + + $configurator->paths([ + __DIR__ . '/config/', + __DIR__ . '/src/', + __DIR__ . '/test/', + ]); + + // import SetList here in the end of ecs. is on purpose + // to avoid overridden by existing Skip Option in current config + $configurator->import(SetList::PSR_12); + $configurator->import(SetList::COMMON); + $configurator->import(SetList::NAMESPACES); + $configurator->import(SetList::CLEAN_CODE); + + $configurator->lineEnding("\n"); +}; diff --git a/src/AbstractFactory/Config/InjectConfigAbstractFactory.php b/src/AbstractFactory/Config/InjectConfigAbstractFactory.php index 5526531..bec96eb 100644 --- a/src/AbstractFactory/Config/InjectConfigAbstractFactory.php +++ b/src/AbstractFactory/Config/InjectConfigAbstractFactory.php @@ -15,29 +15,10 @@ class InjectConfigAbstractFactory implements AbstractFactoryInterface { private const MATCH_PATTERN = '/^Config\.(.*)$/'; - /** - * @var array - */ private array $matches = []; /** - * @inheritDoc - */ - public function canCreate( - ContainerInterface $container, - $requestedName - ): bool { - return preg_match( - self::MATCH_PATTERN, - $requestedName, - $this->matches - ) === 1; - } - - /** - * @param ContainerInterface $container * @param string $requestedName - * @param array|null $options * * @return mixed|object|null */ @@ -51,4 +32,15 @@ public function __invoke( return $configService->resolve($this->matches[1]); } + + public function canCreate( + ContainerInterface $container, + $requestedName + ): bool { + return preg_match( + self::MATCH_PATTERN, + $requestedName, + $this->matches + ) === 1; + } } diff --git a/src/AbstractFactory/FallbackAutoWiringFactory.php b/src/AbstractFactory/FallbackAutoWiringFactory.php index 339e397..3803e71 100644 --- a/src/AbstractFactory/FallbackAutoWiringFactory.php +++ b/src/AbstractFactory/FallbackAutoWiringFactory.php @@ -1,4 +1,5 @@ options = $values['options']; } @@ -40,15 +34,12 @@ public function __construct(array $values) $this->name = $values['value']; } - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { $container = $this->determineContainer($container); $pluginManagerImplementation = $container->get(static::PLUGIN_MANAGER); - if (!$pluginManagerImplementation instanceof AbstractPluginManager) { + if (! $pluginManagerImplementation instanceof AbstractPluginManager) { throw InjectionNotPossibleException::fromUnknownPluginManager(static::PLUGIN_MANAGER); } diff --git a/src/Annotation/Inject.php b/src/Annotation/Inject.php index f21ebe6..0c33b84 100644 --- a/src/Annotation/Inject.php +++ b/src/Annotation/Inject.php @@ -19,9 +19,6 @@ final class Inject implements AnnotationInterface */ public $value; - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { return $container->get($this->value); diff --git a/src/Annotation/InjectConfig.php b/src/Annotation/InjectConfig.php index 3413f5b..10c7c0c 100644 --- a/src/Annotation/InjectConfig.php +++ b/src/Annotation/InjectConfig.php @@ -16,19 +16,10 @@ */ final class InjectConfig extends AbstractAnnotation { - /** - * @var string - */ private string $configPath; - /** - * @var bool - */ private bool $asArray = false; - /** - * @param array $values - */ public function __construct(array $values) { if (isset($values['asArray'])) { @@ -37,9 +28,7 @@ public function __construct(array $values) $this->configPath = $values['value']; } - /** - * @inheritDoc - */ + public function __invoke(ContainerInterface $container) { $container = $this->determineContainer($container); diff --git a/src/Annotation/InjectConstant.php b/src/Annotation/InjectConstant.php index 34723ef..411c99f 100644 --- a/src/Annotation/InjectConstant.php +++ b/src/Annotation/InjectConstant.php @@ -19,9 +19,6 @@ final class InjectConstant implements AnnotationInterface */ public $value; - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { return constant($this->value); diff --git a/src/Annotation/InjectContainer.php b/src/Annotation/InjectContainer.php index 0f01199..8bc5efd 100644 --- a/src/Annotation/InjectContainer.php +++ b/src/Annotation/InjectContainer.php @@ -14,9 +14,6 @@ */ final class InjectContainer implements AnnotationInterface { - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { return $container; diff --git a/src/Annotation/InjectControllerPlugin.php b/src/Annotation/InjectControllerPlugin.php index 981e52d..49f1b07 100644 --- a/src/Annotation/InjectControllerPlugin.php +++ b/src/Annotation/InjectControllerPlugin.php @@ -4,8 +4,6 @@ namespace Reinfi\DependencyInjection\Annotation; -use Attribute; - /** * @package Reinfi\DependencyInjection\Annotation * diff --git a/src/Annotation/InjectDoctrineRepository.php b/src/Annotation/InjectDoctrineRepository.php index b4c28aa..69b5ce9 100644 --- a/src/Annotation/InjectDoctrineRepository.php +++ b/src/Annotation/InjectDoctrineRepository.php @@ -19,12 +19,9 @@ final class InjectDoctrineRepository extends AbstractAnnotation private string $entity; - /** - * @param array $values - */ public function __construct(array $values) { - if (!isset($values['value'])) { + if (! isset($values['value'])) { if (isset($values['em']) || isset($values['entityManager'])) { $this->entityManager = $values['entityManager'] ?? $values['em']; } @@ -34,13 +31,9 @@ public function __construct(array $values) return; } - $this->entity = $values['value']; } - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { $container = $this->determineContainer($container); @@ -48,8 +41,8 @@ public function __invoke(ContainerInterface $container) $entityManager = $container->get($this->entityManager); if ( - !is_object($entityManager) - || !method_exists($entityManager, 'getRepository') + ! is_object($entityManager) + || ! method_exists($entityManager, 'getRepository') ) { throw new AutoWiringNotPossibleException($this->entity); } diff --git a/src/Annotation/InjectParent.php b/src/Annotation/InjectParent.php index 4c8e20e..7d5bec9 100644 --- a/src/Annotation/InjectParent.php +++ b/src/Annotation/InjectParent.php @@ -4,8 +4,8 @@ namespace Reinfi\DependencyInjection\Annotation; -use Psr\Container\ContainerInterface; use Laminas\ServiceManager\AbstractPluginManager; +use Psr\Container\ContainerInterface; /** * @package Reinfi\DependencyInjection\Annotation @@ -20,9 +20,6 @@ final class InjectParent implements AnnotationInterface */ public $value; - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { if ($container instanceof AbstractPluginManager) { diff --git a/src/Attribute/AbstractInjectPluginManager.php b/src/Attribute/AbstractInjectPluginManager.php index d21bbba..07d7089 100644 --- a/src/Attribute/AbstractInjectPluginManager.php +++ b/src/Attribute/AbstractInjectPluginManager.php @@ -17,9 +17,6 @@ abstract class AbstractInjectPluginManager extends AbstractAttribute private string $name; - /** - * @var array|null - */ private ?array $options; public function __construct(string $name, ?array $options = null) @@ -28,15 +25,12 @@ public function __construct(string $name, ?array $options = null) $this->options = $options; } - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { $container = $this->determineContainer($container); $pluginManagerImplementation = $container->get(static::PLUGIN_MANAGER); - if (!$pluginManagerImplementation instanceof AbstractPluginManager) { + if (! $pluginManagerImplementation instanceof AbstractPluginManager) { throw InjectionNotPossibleException::fromUnknownPluginManager(static::PLUGIN_MANAGER); } diff --git a/src/Attribute/Inject.php b/src/Attribute/Inject.php index fe9086d..de2da4d 100644 --- a/src/Attribute/Inject.php +++ b/src/Attribute/Inject.php @@ -21,9 +21,6 @@ public function __construct(string $value) $this->value = $value; } - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { return $container->get($this->value); diff --git a/src/Attribute/InjectConfig.php b/src/Attribute/InjectConfig.php index 08dc0fb..c7bd6d0 100644 --- a/src/Attribute/InjectConfig.php +++ b/src/Attribute/InjectConfig.php @@ -15,14 +15,8 @@ #[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] final class InjectConfig extends AbstractAttribute { - /** - * @var string - */ private string $configPath; - /** - * @var bool - */ private bool $asArray; public function __construct(string $configPath, bool $asArray = false) @@ -31,9 +25,6 @@ public function __construct(string $configPath, bool $asArray = false) $this->asArray = $asArray; } - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { $container = $this->determineContainer($container); diff --git a/src/Attribute/InjectConstant.php b/src/Attribute/InjectConstant.php index 53f5d12..d3f9267 100644 --- a/src/Attribute/InjectConstant.php +++ b/src/Attribute/InjectConstant.php @@ -21,9 +21,6 @@ public function __construct(string $value) $this->value = $value; } - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { return constant($this->value); diff --git a/src/Attribute/InjectContainer.php b/src/Attribute/InjectContainer.php index a0ccd1f..930dd9f 100644 --- a/src/Attribute/InjectContainer.php +++ b/src/Attribute/InjectContainer.php @@ -14,9 +14,6 @@ #[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] final class InjectContainer implements InjectionInterface { - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { return $container; diff --git a/src/Attribute/InjectDoctrineRepository.php b/src/Attribute/InjectDoctrineRepository.php index 802dc8d..a89e4e5 100644 --- a/src/Attribute/InjectDoctrineRepository.php +++ b/src/Attribute/InjectDoctrineRepository.php @@ -27,9 +27,6 @@ public function __construct(string $entity, ?string $entityManager = null) } } - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { $container = $this->determineContainer($container); @@ -37,8 +34,8 @@ public function __invoke(ContainerInterface $container) $entityManager = $container->get($this->entityManager); if ( - !is_object($entityManager) - || !method_exists($entityManager, 'getRepository') + ! is_object($entityManager) + || ! method_exists($entityManager, 'getRepository') ) { throw new AutoWiringNotPossibleException($this->entity); } diff --git a/src/Attribute/InjectParent.php b/src/Attribute/InjectParent.php index 171b654..cf26d6e 100644 --- a/src/Attribute/InjectParent.php +++ b/src/Attribute/InjectParent.php @@ -5,8 +5,8 @@ namespace Reinfi\DependencyInjection\Attribute; use Attribute; -use Psr\Container\ContainerInterface; use Laminas\ServiceManager\AbstractPluginManager; +use Psr\Container\ContainerInterface; use Reinfi\DependencyInjection\Injection\InjectionInterface; /** @@ -22,9 +22,6 @@ public function __construct(string $value) $this->value = $value; } - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { if ($container instanceof AbstractPluginManager) { diff --git a/src/Command/CacheWarmupCommand.php b/src/Command/CacheWarmupCommand.php index 9884641..41ba6aa 100644 --- a/src/Command/CacheWarmupCommand.php +++ b/src/Command/CacheWarmupCommand.php @@ -5,6 +5,7 @@ namespace Reinfi\DependencyInjection\Command; use InvalidArgumentException; +use Laminas\Mvc\Application; use Psr\Container\ContainerInterface; use Reinfi\DependencyInjection\Service\AutoWiring\ResolverService; use Reinfi\DependencyInjection\Service\CacheService; @@ -14,7 +15,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Laminas\Mvc\Application; /** * @package Reinfi\DependencyInjection\Command @@ -23,9 +23,6 @@ class CacheWarmupCommand extends Command { use WarmupTrait; - /** - * {@inheritDoc} - */ protected function configure(): void { $this @@ -40,21 +37,18 @@ protected function configure(): void ); } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln('Start up application with supplied config...'); $config = $input->getArgument('applicationConfig'); - if (!is_string($config)) { + if (! is_string($config)) { throw new InvalidArgumentException('Invalid config path provided'); } $path = stream_resolve_include_path($config); - if ($path === false || !is_readable($path)) { + if ($path === false || ! is_readable($path)) { throw new InvalidArgumentException(sprintf( 'Invalid config path: %s', $config @@ -78,11 +72,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int return self::SUCCESS; } - /** - * @param ContainerInterface $container - * - * @return array - */ private function getServiceManagerConfig(ContainerInterface $container): array { $configuration = $container->get('config'); diff --git a/src/Config/Factory/ModuleConfigFactory.php b/src/Config/Factory/ModuleConfigFactory.php index df09e8a..b0987a5 100644 --- a/src/Config/Factory/ModuleConfigFactory.php +++ b/src/Config/Factory/ModuleConfigFactory.php @@ -23,7 +23,7 @@ public function __invoke(ContainerInterface $container): array $moduleConfig = $config[ModuleConfig::CONFIG_KEY] ?? []; - if (!is_array($moduleConfig)) { + if (! is_array($moduleConfig)) { throw new InvalidArgumentException('Module config must be type of array'); } diff --git a/src/Extension/PHPStan/Resolve/AutoWiringClassesResolver.php b/src/Extension/PHPStan/Resolve/AutoWiringClassesResolver.php index 44fdc65..64adb91 100644 --- a/src/Extension/PHPStan/Resolve/AutoWiringClassesResolver.php +++ b/src/Extension/PHPStan/Resolve/AutoWiringClassesResolver.php @@ -5,8 +5,8 @@ namespace Reinfi\DependencyInjection\Extension\PHPStan\Resolve; use Laminas\Config\Config; -use Reinfi\DependencyInjection\Factory\AutoWiringFactory; use Reinfi\DependencyInjection\Extension\PHPStan\ServiceManagerLoader; +use Reinfi\DependencyInjection\Factory\AutoWiringFactory; class AutoWiringClassesResolver { diff --git a/src/Extension/PHPStan/Resolve/AutoWiringPossibleResolver.php b/src/Extension/PHPStan/Resolve/AutoWiringPossibleResolver.php index 9aa72ff..28aa9f5 100644 --- a/src/Extension/PHPStan/Resolve/AutoWiringPossibleResolver.php +++ b/src/Extension/PHPStan/Resolve/AutoWiringPossibleResolver.php @@ -4,9 +4,9 @@ namespace Reinfi\DependencyInjection\Extension\PHPStan\Resolve; +use Reinfi\DependencyInjection\Extension\PHPStan\ServiceManagerLoader; use Reinfi\DependencyInjection\Service\AutoWiring\ResolverService; use Reinfi\DependencyInjection\Service\AutoWiring\ResolverServiceInterface; -use Reinfi\DependencyInjection\Extension\PHPStan\ServiceManagerLoader; class AutoWiringPossibleResolver { diff --git a/src/Extension/PHPStan/Rules/AutoWiringPossibleRule.php b/src/Extension/PHPStan/Rules/AutoWiringPossibleRule.php index 197cd15..3900450 100644 --- a/src/Extension/PHPStan/Rules/AutoWiringPossibleRule.php +++ b/src/Extension/PHPStan/Rules/AutoWiringPossibleRule.php @@ -14,6 +14,7 @@ final class AutoWiringPossibleRule implements Rule { private AutoWiringClassesResolver $classesResolver; + private AutoWiringPossibleResolver $possibleResolver; public function __construct( @@ -31,7 +32,6 @@ public function getNodeType(): string /** * @param Node\Stmt\Class_ $node - * @param Scope $scope * @return string[] */ public function processNode(Node $node, Scope $scope): array @@ -52,7 +52,7 @@ public function processNode(Node $node, Scope $scope): array 'AutoWiring of %s not possible, due to: %s', $node->namespacedName->toString(), $exception->getMessage() - ) + ), ]; } diff --git a/src/Extension/PHPStan/ServiceManagerLoader.php b/src/Extension/PHPStan/ServiceManagerLoader.php index 9646d0e..6765de3 100644 --- a/src/Extension/PHPStan/ServiceManagerLoader.php +++ b/src/Extension/PHPStan/ServiceManagerLoader.php @@ -17,7 +17,7 @@ final class ServiceManagerLoader public function __construct(?string $serviceManagerLoader) { - if (null === $serviceManagerLoader) { + if ($serviceManagerLoader === null) { return; } diff --git a/src/Factory/AbstractFactory.php b/src/Factory/AbstractFactory.php index 2436ed3..065816c 100644 --- a/src/Factory/AbstractFactory.php +++ b/src/Factory/AbstractFactory.php @@ -15,7 +15,6 @@ abstract class AbstractFactory implements FactoryInterface { /** - * @param ServiceLocatorInterface $serviceLocator * @param class-string $canonicalName * @param class-string $requestedName * @@ -44,9 +43,6 @@ public function createService( /** * @param class-string $className - * @param array $injections - * - * @return object */ protected function buildInstance(string $className, array $injections): object { diff --git a/src/Factory/AutoWiringFactory.php b/src/Factory/AutoWiringFactory.php index b4b2bde..5d6886a 100644 --- a/src/Factory/AutoWiringFactory.php +++ b/src/Factory/AutoWiringFactory.php @@ -4,9 +4,9 @@ namespace Reinfi\DependencyInjection\Factory; +use Laminas\ServiceManager\AbstractPluginManager; use Psr\Container\ContainerInterface; use Reinfi\DependencyInjection\Service\AutoWiringService; -use Laminas\ServiceManager\AbstractPluginManager; /** * @package Reinfi\DependencyInjection\Factory @@ -14,9 +14,7 @@ final class AutoWiringFactory extends AbstractFactory { /** - * @param \Interop\Container\ContainerInterface $container * @param class-string $requestedName - * @param array|null $options * * @return mixed */ @@ -34,7 +32,7 @@ public function __invoke( ); if ($injections === null) { - return new $requestedName; + return new $requestedName(); } return $this->buildInstance($requestedName, $injections); diff --git a/src/Factory/InjectionFactory.php b/src/Factory/InjectionFactory.php index 76ccaec..8fe7051 100644 --- a/src/Factory/InjectionFactory.php +++ b/src/Factory/InjectionFactory.php @@ -14,9 +14,7 @@ final class InjectionFactory extends AbstractFactory { /** - * @param \Interop\Container\ContainerInterface $container * @param class-string $requestedName - * @param array|null $options * * @return mixed */ @@ -33,7 +31,7 @@ public function __invoke( ); if ($injections === false) { - return new $requestedName; + return new $requestedName(); } return $this->buildInstance($requestedName, $injections); diff --git a/src/Injection/AutoWiring.php b/src/Injection/AutoWiring.php index 60b488f..8ea3ec1 100644 --- a/src/Injection/AutoWiring.php +++ b/src/Injection/AutoWiring.php @@ -4,9 +4,9 @@ namespace Reinfi\DependencyInjection\Injection; +use Laminas\ServiceManager\AbstractPluginManager; use Psr\Container\ContainerInterface; use Reinfi\DependencyInjection\Exception\AutoWiringNotPossibleException; -use Laminas\ServiceManager\AbstractPluginManager; /** * @package Reinfi\DependencyInjection\Injection diff --git a/src/Injection/AutoWiringContainer.php b/src/Injection/AutoWiringContainer.php index d30e7f0..a676609 100644 --- a/src/Injection/AutoWiringContainer.php +++ b/src/Injection/AutoWiringContainer.php @@ -11,9 +11,6 @@ */ class AutoWiringContainer implements InjectionInterface { - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container): ContainerInterface { return $container; diff --git a/src/Injection/AutoWiringPluginManager.php b/src/Injection/AutoWiringPluginManager.php index c0ac04b..7472f62 100644 --- a/src/Injection/AutoWiringPluginManager.php +++ b/src/Injection/AutoWiringPluginManager.php @@ -4,9 +4,9 @@ namespace Reinfi\DependencyInjection\Injection; +use Laminas\ServiceManager\AbstractPluginManager; use Psr\Container\ContainerInterface; use Reinfi\DependencyInjection\Exception\AutoWiringNotPossibleException; -use Laminas\ServiceManager\AbstractPluginManager; /** * @package Reinfi\DependencyInjection\Injection @@ -26,8 +26,6 @@ public function __construct( } /** - * @param ContainerInterface $container - * * @return mixed * @throws AutoWiringNotPossibleException */ diff --git a/src/Injection/ContainerTrait.php b/src/Injection/ContainerTrait.php index c94a983..1b6ed39 100644 --- a/src/Injection/ContainerTrait.php +++ b/src/Injection/ContainerTrait.php @@ -1,5 +1,7 @@ value = $value; } - /** - * @inheritDoc - */ public function __invoke(ContainerInterface $container) { return $this->value; diff --git a/src/Module.php b/src/Module.php index 659a394..4b20c3a 100644 --- a/src/Module.php +++ b/src/Module.php @@ -11,9 +11,6 @@ */ class Module implements ConfigProviderInterface { - /** - * @inheritDoc - */ public function getConfig(): array { return require __DIR__ . '/../config/module.config.php'; diff --git a/src/Service/AutoWiring/Factory/ResolverServiceFactory.php b/src/Service/AutoWiring/Factory/ResolverServiceFactory.php index 3d73168..53d4d1c 100644 --- a/src/Service/AutoWiring/Factory/ResolverServiceFactory.php +++ b/src/Service/AutoWiring/Factory/ResolverServiceFactory.php @@ -37,8 +37,6 @@ public function __invoke(ContainerInterface $container): ResolverService } /** - * @param array $config - * * @return class-string[] */ private function getResolverStack(array $config): array diff --git a/src/Service/AutoWiring/LazyResolverService.php b/src/Service/AutoWiring/LazyResolverService.php index 1c14f2b..984aee1 100644 --- a/src/Service/AutoWiring/LazyResolverService.php +++ b/src/Service/AutoWiring/LazyResolverService.php @@ -22,12 +22,9 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - /** - * @inheritdoc - */ public function resolve(string $className, ?array $options = null): array { - if (!$this->resolverService instanceof ResolverServiceInterface) { + if (! $this->resolverService instanceof ResolverServiceInterface) { $this->resolverService = $this->container->get(ResolverService::class); } diff --git a/src/Service/AutoWiring/Resolver/BuildInTypeWithDefaultResolver.php b/src/Service/AutoWiring/Resolver/BuildInTypeWithDefaultResolver.php index 4f3ad29..f64d415 100644 --- a/src/Service/AutoWiring/Resolver/BuildInTypeWithDefaultResolver.php +++ b/src/Service/AutoWiring/Resolver/BuildInTypeWithDefaultResolver.php @@ -14,21 +14,18 @@ */ class BuildInTypeWithDefaultResolver implements ResolverInterface { - /** - * @inheritDoc - */ public function resolve(ReflectionParameter $parameter): ?InjectionInterface { $type = $parameter->getType(); - if (!$type instanceof ReflectionNamedType) { + if (! $type instanceof ReflectionNamedType) { return null; } - if (!$type->isBuiltin()) { + if (! $type->isBuiltin()) { return null; } - if (!$parameter->isDefaultValueAvailable()) { + if (! $parameter->isDefaultValueAvailable()) { return null; } diff --git a/src/Service/AutoWiring/Resolver/ContainerInterfaceResolver.php b/src/Service/AutoWiring/Resolver/ContainerInterfaceResolver.php index 56763ca..5a3bd7e 100644 --- a/src/Service/AutoWiring/Resolver/ContainerInterfaceResolver.php +++ b/src/Service/AutoWiring/Resolver/ContainerInterfaceResolver.php @@ -4,32 +4,29 @@ namespace Reinfi\DependencyInjection\Service\AutoWiring\Resolver; +use Laminas\ServiceManager\AbstractPluginManager; use Psr\Container\ContainerInterface; use ReflectionClass; use ReflectionNamedType; use ReflectionParameter; use Reinfi\DependencyInjection\Injection\AutoWiringContainer; use Reinfi\DependencyInjection\Injection\InjectionInterface; -use Laminas\ServiceManager\AbstractPluginManager; /** * @package Reinfi\DependencyInjection\Service\AutoWiring\Resolver */ class ContainerInterfaceResolver implements ResolverInterface { - /** - * @inheritDoc - */ public function resolve(ReflectionParameter $parameter): ?InjectionInterface { $type = $parameter->getType(); - if (!$type instanceof ReflectionNamedType) { + if (! $type instanceof ReflectionNamedType) { return null; } if ( - !class_exists($type->getName()) - && !interface_exists($type->getName()) + ! class_exists($type->getName()) + && ! interface_exists($type->getName()) ) { return null; } @@ -37,11 +34,6 @@ public function resolve(ReflectionParameter $parameter): ?InjectionInterface return $this->handleClass(new ReflectionClass($type->getName())); } - /** - * @param ReflectionClass $reflectionClass - * - * @return AutoWiringContainer|null - */ private function handleClass( ReflectionClass $reflectionClass ): ?AutoWiringContainer { @@ -57,7 +49,7 @@ private function handleClass( } $interfaceNames = $reflectionClass->getInterfaceNames(); - if (in_array(ContainerInterface::class, $interfaceNames)) { + if (in_array(ContainerInterface::class, $interfaceNames, true)) { return new AutoWiringContainer(); } diff --git a/src/Service/AutoWiring/Resolver/ContainerResolver.php b/src/Service/AutoWiring/Resolver/ContainerResolver.php index 1255178..95b2f26 100644 --- a/src/Service/AutoWiring/Resolver/ContainerResolver.php +++ b/src/Service/AutoWiring/Resolver/ContainerResolver.php @@ -25,7 +25,7 @@ public function __construct(ContainerInterface $container) public function resolve(ReflectionParameter $parameter): ?InjectionInterface { $type = $parameter->getType(); - if (!$type instanceof ReflectionNamedType) { + if (! $type instanceof ReflectionNamedType) { return null; } diff --git a/src/Service/AutoWiring/Resolver/PluginManagerResolver.php b/src/Service/AutoWiring/Resolver/PluginManagerResolver.php index 1152bfe..85c62ce 100644 --- a/src/Service/AutoWiring/Resolver/PluginManagerResolver.php +++ b/src/Service/AutoWiring/Resolver/PluginManagerResolver.php @@ -20,13 +20,13 @@ class PluginManagerResolver implements ResolverInterface * @var array */ protected static array $pluginManagerMapping = [ - 'Laminas\Hydrator\HydratorInterface' => 'HydratorManager', - 'Laminas\View\Helper\HelperInterface' => 'ViewHelperManager', - 'Laminas\Validator\ValidatorInterface' => 'ValidatorManager', - 'Laminas\Filter\FilterInterface' => 'FilterManager', + 'Laminas\Hydrator\HydratorInterface' => 'HydratorManager', + 'Laminas\View\Helper\HelperInterface' => 'ViewHelperManager', + 'Laminas\Validator\ValidatorInterface' => 'ValidatorManager', + 'Laminas\Filter\FilterInterface' => 'FilterManager', 'Laminas\InputFilter\InputFilterInterface' => 'InputFilterManager', - 'Laminas\InputFilter\InputInterface' => 'InputFilterManager', - 'Laminas\Form\ElementInterface' => 'FormElementManager', + 'Laminas\InputFilter\InputInterface' => 'InputFilterManager', + 'Laminas\Form\ElementInterface' => 'FormElementManager', ]; private ContainerInterface $container; @@ -36,19 +36,16 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - /** - * @inheritdoc - */ public function resolve(ReflectionParameter $parameter): ?InjectionInterface { $type = $parameter->getType(); - if (!$type instanceof ReflectionNamedType) { + if (! $type instanceof ReflectionNamedType) { return null; } if ( - !class_exists($type->getName()) - && !interface_exists($type->getName()) + ! class_exists($type->getName()) + && ! interface_exists($type->getName()) ) { return null; } @@ -59,10 +56,13 @@ public function resolve(ReflectionParameter $parameter): ?InjectionInterface } /** - * @param ReflectionClass $reflectionClass - * - * @return AutoWiringPluginManager|null + * @param class-string $className */ + public static function addMapping(string $className, string $pluginManager): void + { + static::$pluginManagerMapping[$className] = $pluginManager; + } + private function handleClass( ReflectionClass $reflectionClass ): ?AutoWiringPluginManager { @@ -71,7 +71,7 @@ private function handleClass( $interfaceNames = $reflectionClass->getInterfaceNames(); foreach (self::$pluginManagerMapping as $interfaceName => $pluginManager) { - if (in_array($interfaceName, $interfaceNames)) { + if (in_array($interfaceName, $interfaceNames, true)) { $pluginManagerImplementation = $this->container->get($pluginManager); if ( $pluginManagerImplementation instanceof ContainerInterface @@ -87,13 +87,4 @@ private function handleClass( return null; } - - /** - * @param class-string $className - * @param string $pluginManager - */ - public static function addMapping(string $className, string $pluginManager): void - { - static::$pluginManagerMapping[$className] = $pluginManager; - } } diff --git a/src/Service/AutoWiring/Resolver/RequestResolver.php b/src/Service/AutoWiring/Resolver/RequestResolver.php index 289b51b..b7f69f9 100644 --- a/src/Service/AutoWiring/Resolver/RequestResolver.php +++ b/src/Service/AutoWiring/Resolver/RequestResolver.php @@ -4,31 +4,28 @@ namespace Reinfi\DependencyInjection\Service\AutoWiring\Resolver; +use Laminas\Stdlib\RequestInterface; use ReflectionClass; use ReflectionNamedType; use ReflectionParameter; use Reinfi\DependencyInjection\Injection\AutoWiring; use Reinfi\DependencyInjection\Injection\InjectionInterface; -use Laminas\Stdlib\RequestInterface; /** * @package Reinfi\DependencyInjection\Service\AutoWiring\Resolver */ class RequestResolver implements ResolverInterface { - /** - * @inheritDoc - */ public function resolve(ReflectionParameter $parameter): ?InjectionInterface { $type = $parameter->getType(); - if (!$type instanceof ReflectionNamedType) { + if (! $type instanceof ReflectionNamedType) { return null; } if ( - !class_exists($type->getName()) - && !interface_exists($type->getName()) + ! class_exists($type->getName()) + && ! interface_exists($type->getName()) ) { return null; } @@ -38,7 +35,7 @@ public function resolve(ReflectionParameter $parameter): ?InjectionInterface if ( $reflectionClass->getName() !== RequestInterface::class - && !in_array(RequestInterface::class, $interfaceNames) + && ! in_array(RequestInterface::class, $interfaceNames, true) ) { return null; } diff --git a/src/Service/AutoWiring/Resolver/ResolverInterface.php b/src/Service/AutoWiring/Resolver/ResolverInterface.php index cdcca64..3482fea 100644 --- a/src/Service/AutoWiring/Resolver/ResolverInterface.php +++ b/src/Service/AutoWiring/Resolver/ResolverInterface.php @@ -12,10 +12,5 @@ */ interface ResolverInterface { - /** - * @param ReflectionParameter $parameter - * - * @return InjectionInterface|null - */ public function resolve(ReflectionParameter $parameter): ?InjectionInterface; } diff --git a/src/Service/AutoWiring/Resolver/ResponseResolver.php b/src/Service/AutoWiring/Resolver/ResponseResolver.php index 2af717f..5f502fa 100644 --- a/src/Service/AutoWiring/Resolver/ResponseResolver.php +++ b/src/Service/AutoWiring/Resolver/ResponseResolver.php @@ -4,31 +4,28 @@ namespace Reinfi\DependencyInjection\Service\AutoWiring\Resolver; +use Laminas\Stdlib\ResponseInterface; use ReflectionClass; use ReflectionNamedType; use ReflectionParameter; use Reinfi\DependencyInjection\Injection\AutoWiring; use Reinfi\DependencyInjection\Injection\InjectionInterface; -use Laminas\Stdlib\ResponseInterface; /** * @package Reinfi\DependencyInjection\Service\AutoWiring\Resolver */ class ResponseResolver implements ResolverInterface { - /** - * @inheritDoc - */ public function resolve(ReflectionParameter $parameter): ?InjectionInterface { $type = $parameter->getType(); - if (!$type instanceof ReflectionNamedType) { + if (! $type instanceof ReflectionNamedType) { return null; } if ( - !class_exists($type->getName()) - && !interface_exists($type->getName()) + ! class_exists($type->getName()) + && ! interface_exists($type->getName()) ) { return null; } @@ -38,7 +35,7 @@ public function resolve(ReflectionParameter $parameter): ?InjectionInterface if ( $reflectionClass->getName() !== ResponseInterface::class - && !in_array(ResponseInterface::class, $interfaceNames) + && ! in_array(ResponseInterface::class, $interfaceNames, true) ) { return null; } diff --git a/src/Service/AutoWiring/Resolver/TranslatorResolver.php b/src/Service/AutoWiring/Resolver/TranslatorResolver.php index 85162d1..aa28579 100644 --- a/src/Service/AutoWiring/Resolver/TranslatorResolver.php +++ b/src/Service/AutoWiring/Resolver/TranslatorResolver.php @@ -27,7 +27,7 @@ class TranslatorResolver implements ResolverInterface private const TRANSLATOR_CONTAINER_SERVICE_NAME = [ 'MvcTranslator', self::TRANSLATOR_INTERFACE, - 'Translator' + 'Translator', ]; private ContainerInterface $container; @@ -37,12 +37,9 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - /** - * @inheritDoc - */ public function resolve(ReflectionParameter $parameter): ?InjectionInterface { - if (!$this->isValid($parameter)) { + if (! $this->isValid($parameter)) { return null; } @@ -58,13 +55,13 @@ public function resolve(ReflectionParameter $parameter): ?InjectionInterface private function isValid(ReflectionParameter $parameter): bool { $type = $parameter->getType(); - if (!$type instanceof ReflectionNamedType) { + if (! $type instanceof ReflectionNamedType) { return false; } if ( - !class_exists($type->getName()) - && !interface_exists($type->getName()) + ! class_exists($type->getName()) + && ! interface_exists($type->getName()) ) { return false; } @@ -72,9 +69,8 @@ private function isValid(ReflectionParameter $parameter): bool $reflectionClass = new ReflectionClass($type->getName()); $interfaceNames = $reflectionClass->getInterfaceNames(); - return ( - $reflectionClass->getName() === self::TRANSLATOR_INTERFACE - || in_array(self::TRANSLATOR_INTERFACE, $interfaceNames) - ); + return $reflectionClass->getName() === self::TRANSLATOR_INTERFACE + || in_array(self::TRANSLATOR_INTERFACE, $interfaceNames, true) + ; } } diff --git a/src/Service/AutoWiring/ResolverService.php b/src/Service/AutoWiring/ResolverService.php index 3a0a02b..8e95a88 100644 --- a/src/Service/AutoWiring/ResolverService.php +++ b/src/Service/AutoWiring/ResolverService.php @@ -34,7 +34,6 @@ public function __construct( /** * @param class-string $className - * @param null|array $options * * @return InjectionInterface[] */ @@ -57,10 +56,6 @@ function (ReflectionParameter $parameter) use ($options) { } /** - * @param ReflectionParameter $parameter - * @param null|array $options - * - * @return InjectionInterface * @throws AutoWiringNotPossibleException */ private function resolveParameter( @@ -86,14 +81,13 @@ private function resolveParameter( } /** - * * @throws AutoWiringNotPossibleException */ private function handleUnresolvedParameter( ReflectionParameter $parameter ): Throwable { $type = $parameter->getType(); - if (!$type instanceof ReflectionNamedType) { + if (! $type instanceof ReflectionNamedType) { return AutoWiringNotPossibleException::fromMissingTypeHint( $parameter ); diff --git a/src/Service/AutoWiring/ResolverServiceInterface.php b/src/Service/AutoWiring/ResolverServiceInterface.php index 2c9ed87..cd1d9cf 100644 --- a/src/Service/AutoWiring/ResolverServiceInterface.php +++ b/src/Service/AutoWiring/ResolverServiceInterface.php @@ -12,9 +12,6 @@ interface ResolverServiceInterface { /** - * @param string $className - * @param null|array $options - * * @return InjectionInterface[] */ public function resolve(string $className, ?array $options = null): array; diff --git a/src/Service/AutoWiringService.php b/src/Service/AutoWiringService.php index f8bb467..1904815 100644 --- a/src/Service/AutoWiringService.php +++ b/src/Service/AutoWiringService.php @@ -29,10 +29,6 @@ public function __construct( } /** - * @param ContainerInterface $container - * @param string $className - * @param null|array $options - * * @return InjectionInterface[]|null */ public function resolveConstructorInjection( @@ -54,9 +50,6 @@ public function resolveConstructorInjection( } /** - * @param string $className - * @param array|null $options - * * @return InjectionInterface[] */ private function getInjections(string $className, ?array $options = null): array diff --git a/src/Service/Cache/Memory.php b/src/Service/Cache/Memory.php index c98b8a5..fd14422 100644 --- a/src/Service/Cache/Memory.php +++ b/src/Service/Cache/Memory.php @@ -9,9 +9,6 @@ class Memory implements CacheInterface { - /** - * @var array - */ private array $cachedItems = []; public function get($key, $default = null) diff --git a/src/Service/CacheService.php b/src/Service/CacheService.php index e9b72ab..f64eb22 100644 --- a/src/Service/CacheService.php +++ b/src/Service/CacheService.php @@ -21,7 +21,7 @@ public function __construct(CacheInterface $cache) public function get(string $key): ?array { $cachedValue = $this->cache->get($key); - if (!is_array($cachedValue)) { + if (! is_array($cachedValue)) { return null; } diff --git a/src/Service/ConfigService.php b/src/Service/ConfigService.php index 203d24a..00af59a 100644 --- a/src/Service/ConfigService.php +++ b/src/Service/ConfigService.php @@ -4,8 +4,8 @@ namespace Reinfi\DependencyInjection\Service; -use Reinfi\DependencyInjection\Exception\ConfigPathNotFoundException; use Laminas\Config\Config; +use Reinfi\DependencyInjection\Exception\ConfigPathNotFoundException; /** * @package Reinfi\DependencyInjection\Service @@ -20,8 +20,6 @@ public function __construct(Config $config) } /** - * @param string $configPath - * * @return mixed|null * @throws ConfigPathNotFoundException */ @@ -44,10 +42,6 @@ public function resolve(string $configPath) } /** - * @param Config $config - * @param array $configParts - * @param bool $nullAllowed - * * @return mixed|null * @throws ConfigPathNotFoundException */ @@ -58,7 +52,7 @@ private function resolveConfigPath( ) { $currentKey = array_shift($configParts); - if (!$config->offsetExists($currentKey)) { + if (! $config->offsetExists($currentKey)) { if ($nullAllowed) { return null; } diff --git a/src/Service/Extractor/AnnotationExtractor.php b/src/Service/Extractor/AnnotationExtractor.php index 535e4ce..7fe0bd3 100644 --- a/src/Service/Extractor/AnnotationExtractor.php +++ b/src/Service/Extractor/AnnotationExtractor.php @@ -22,9 +22,6 @@ public function __construct(AnnotationReader $reader) $this->reader = $reader; } - /** - * @inheritdoc - */ public function getPropertiesInjections(string $className): array { $injections = []; @@ -40,7 +37,7 @@ public function getPropertiesInjections(string $className): array AnnotationInterface::class ); - if (null !== $inject) { + if ($inject !== null) { $injections[$index] = $inject; } } @@ -48,12 +45,9 @@ public function getPropertiesInjections(string $className): array return $injections; } - /** - * @inheritDoc - */ public function getConstructorInjections(string $className): array { - if (!in_array('__construct', get_class_methods($className))) { + if (! in_array('__construct', get_class_methods($className), true)) { return []; } diff --git a/src/Service/Extractor/AttributeExtractor.php b/src/Service/Extractor/AttributeExtractor.php index 9025442..0253a3b 100644 --- a/src/Service/Extractor/AttributeExtractor.php +++ b/src/Service/Extractor/AttributeExtractor.php @@ -11,9 +11,6 @@ class AttributeExtractor implements ExtractorInterface { - /** - * @inheritDoc - */ public function getPropertiesInjections(string $className): array { $injections = []; @@ -28,7 +25,7 @@ public function getPropertiesInjections(string $className): array foreach ($attributes as $attribute) { $injection = $this->getInjectionFromAttribute($attribute); - if (!$injection instanceof InjectionInterface) { + if (! $injection instanceof InjectionInterface) { continue; } @@ -42,9 +39,6 @@ public function getPropertiesInjections(string $className): array return $injections; } - /** - * @inheritDoc - */ public function getConstructorInjections(string $className): array { $injections = []; @@ -60,7 +54,7 @@ public function getConstructorInjections(string $className): array foreach ($attributes as $attribute) { $injection = $this->getInjectionFromAttribute($attribute); - if (!$injection instanceof InjectionInterface) { + if (! $injection instanceof InjectionInterface) { continue; } @@ -73,12 +67,12 @@ public function getConstructorInjections(string $className): array private function getInjectionFromAttribute(ReflectionAttribute $attribute): ?InjectionInterface { $attributeName = $attribute->getName(); - if (!is_subclass_of($attributeName, InjectionInterface::class)) { + if (! is_subclass_of($attributeName, InjectionInterface::class)) { return null; } $instance = $attribute->newInstance(); - if (!$instance instanceof InjectionInterface) { + if (! $instance instanceof InjectionInterface) { return null; } diff --git a/src/Service/Extractor/ExtractorChain.php b/src/Service/Extractor/ExtractorChain.php index 1e932d0..ddfca31 100644 --- a/src/Service/Extractor/ExtractorChain.php +++ b/src/Service/Extractor/ExtractorChain.php @@ -16,9 +16,6 @@ public function __construct(array $chain) $this->chain = $chain; } - /** - * @inheritDoc - */ public function getPropertiesInjections(string $className): array { return array_reduce( @@ -34,9 +31,6 @@ function (array $injections, ExtractorInterface $extractor) use ($className): ar ); } - /** - * @inheritDoc - */ public function getConstructorInjections(string $className): array { return array_reduce( @@ -50,6 +44,5 @@ function (array $injections, ExtractorInterface $extractor) use ($className): ar }, [] ); - } } diff --git a/src/Service/Extractor/ExtractorInterface.php b/src/Service/Extractor/ExtractorInterface.php index 8289b6d..63e4926 100644 --- a/src/Service/Extractor/ExtractorInterface.php +++ b/src/Service/Extractor/ExtractorInterface.php @@ -22,8 +22,6 @@ public function getPropertiesInjections(string $className): array; /** * @param class-string $className - * - * @return array */ public function getConstructorInjections(string $className): array; } diff --git a/src/Service/Extractor/Factory/ExtractorFactory.php b/src/Service/Extractor/Factory/ExtractorFactory.php index c15047a..679e725 100644 --- a/src/Service/Extractor/Factory/ExtractorFactory.php +++ b/src/Service/Extractor/Factory/ExtractorFactory.php @@ -43,7 +43,7 @@ public function __invoke(ContainerInterface $container): ExtractorInterface private function extractorFromConfig( ContainerInterface $container, - array $config + array $config ): ?ExtractorInterface { $extractorConfiguration = $config['extractor'] ?? null; diff --git a/src/Service/Extractor/YamlExtractor.php b/src/Service/Extractor/YamlExtractor.php index a730295..3dead0c 100644 --- a/src/Service/Extractor/YamlExtractor.php +++ b/src/Service/Extractor/YamlExtractor.php @@ -16,9 +16,6 @@ */ class YamlExtractor implements ExtractorInterface { - /** - * @var array|null - */ protected ?array $config = null; protected Yaml $yaml; @@ -37,17 +34,11 @@ public function __construct( $this->injectionNamespace = $injectionNamespace; } - /** - * @inheritdoc - */ public function getPropertiesInjections(string $className): array { return []; } - /** - * @inheritdoc - */ public function getConstructorInjections(string $className): array { $config = $this->getConfig($className); @@ -75,14 +66,9 @@ public function getConstructorInjections(string $className): array return $injections; } - /** - * @param string $className - * - * @return array - */ private function getConfig(string $className): array { - if (!is_array($this->config)) { + if (! is_array($this->config)) { $fileContents = file_get_contents($this->filePath); if ($fileContents === false) { @@ -98,10 +84,6 @@ private function getConfig(string $className): array } /** - * @param string $type - * @param array $spec - * - * @return InjectionInterface * @throws InjectionTypeUnknownException */ private function buildInjection( @@ -110,7 +92,7 @@ private function buildInjection( ): InjectionInterface { $injectionClass = $this->injectionNamespace . '\\' . $type; - if (!class_exists($injectionClass)) { + if (! class_exists($injectionClass)) { throw new InjectionTypeUnknownException('Invalid injection type ' . $type); } @@ -118,7 +100,7 @@ private function buildInjection( if ($reflectionClass->getConstructor() !== null) { $injection = $reflectionClass->newInstance($spec); - if (!$injection instanceof InjectionInterface) { + if (! $injection instanceof InjectionInterface) { throw new InjectionTypeUnknownException('Invalid class of type ' . get_class($injection)); } @@ -127,12 +109,12 @@ private function buildInjection( $injection = new $injectionClass(); - if (!$injection instanceof InjectionInterface) { + if (! $injection instanceof InjectionInterface) { throw new InjectionTypeUnknownException('Invalid class of type ' . get_class($injection)); } foreach ($spec as $key => $value) { - $injection->$key = $value; + $injection->{$key} = $value; } return $injection; diff --git a/src/Service/Factory/CacheServiceFactory.php b/src/Service/Factory/CacheServiceFactory.php index 68c839a..12e0e26 100644 --- a/src/Service/Factory/CacheServiceFactory.php +++ b/src/Service/Factory/CacheServiceFactory.php @@ -36,7 +36,7 @@ public function __invoke(ContainerInterface $container): CacheService $cache = $cacheConfigValue($container); } - if (!$cache instanceof CacheInterface) { + if (! $cache instanceof CacheInterface) { throw new InvalidArgumentException( 'config value for cache does not return a cache interface instance' ); diff --git a/src/Service/Factory/ConfigServiceFactory.php b/src/Service/Factory/ConfigServiceFactory.php index 1a8377f..3c2098c 100644 --- a/src/Service/Factory/ConfigServiceFactory.php +++ b/src/Service/Factory/ConfigServiceFactory.php @@ -4,9 +4,9 @@ namespace Reinfi\DependencyInjection\Service\Factory; +use Laminas\Config\Config; use Psr\Container\ContainerInterface; use Reinfi\DependencyInjection\Service\ConfigService; -use Laminas\Config\Config; /** * @package Reinfi\DependencyInjection\Service\Factory diff --git a/src/Service/Factory/InjectionServiceFactory.php b/src/Service/Factory/InjectionServiceFactory.php index a6082f7..3b33b12 100644 --- a/src/Service/Factory/InjectionServiceFactory.php +++ b/src/Service/Factory/InjectionServiceFactory.php @@ -5,11 +5,9 @@ namespace Reinfi\DependencyInjection\Service\Factory; use Psr\Container\ContainerInterface; -use Reinfi\DependencyInjection\Config\ModuleConfig; use Reinfi\DependencyInjection\Service\CacheService; use Reinfi\DependencyInjection\Service\Extractor\ExtractorInterface; use Reinfi\DependencyInjection\Service\InjectionService; -use Laminas\Config\Config; /** * @package Reinfi\DependencyInjection\Service\Factory diff --git a/src/Service/InjectionService.php b/src/Service/InjectionService.php index d2e7f27..20f398c 100644 --- a/src/Service/InjectionService.php +++ b/src/Service/InjectionService.php @@ -29,7 +29,6 @@ public function __construct( } /** - * @param ContainerInterface $container * @param class-string $className * * @return array|false diff --git a/src/Traits/CacheKeyTrait.php b/src/Traits/CacheKeyTrait.php index a352961..174888e 100644 --- a/src/Traits/CacheKeyTrait.php +++ b/src/Traits/CacheKeyTrait.php @@ -1,5 +1,6 @@ handleService( diff --git a/test/Integration/AbstractIntegrationTest.php b/test/Integration/AbstractIntegrationTest.php index 56714c1..3853d6e 100644 --- a/test/Integration/AbstractIntegrationTest.php +++ b/test/Integration/AbstractIntegrationTest.php @@ -1,5 +1,7 @@ 'reinfi:di:cache', + 'command' => 'reinfi:di:cache', 'applicationConfig' => $config, ] ); @@ -54,10 +50,7 @@ public function itWarmsupCacheEntries(): void $command->run($input, $output->reveal()); } - /** - * @test - */ - public function itThrowsExceptionIfPathNotValid(): void + public function testItThrowsExceptionIfPathNotValid(): void { $this->expectException(InvalidArgumentException::class); @@ -65,7 +58,7 @@ public function itThrowsExceptionIfPathNotValid(): void $input = new ArgvInput( [ - 'command' => 'reinfi:di:cache', + 'command' => 'reinfi:di:cache', 'applicationConfig' => $config, ] ); diff --git a/test/Integration/Factory/AutoWiringFactoryTest.php b/test/Integration/Factory/AutoWiringFactoryTest.php index 51efa69..b085a46 100644 --- a/test/Integration/Factory/AutoWiringFactoryTest.php +++ b/test/Integration/Factory/AutoWiringFactoryTest.php @@ -1,5 +1,7 @@ getServiceManager(require __DIR__ . '/../../resources/config.php'); @@ -45,10 +44,7 @@ public function itCreatesServiceWithDependencies(): void ); } - /** - * @test - */ - public function itCreatesServiceWithContainerAsDependency(): void + public function testItCreatesServiceWithContainerAsDependency(): void { $container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php'); @@ -66,10 +62,7 @@ public function itCreatesServiceWithContainerAsDependency(): void ); } - /** - * @test - */ - public function itCreatesServiceWithNoDependencies(): void + public function testItCreatesServiceWithNoDependencies(): void { $container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php'); @@ -87,10 +80,7 @@ public function itCreatesServiceWithNoDependencies(): void ); } - /** - * @test - */ - public function itCreatesServiceWithBuiltInType(): void + public function testItCreatesServiceWithBuiltInType(): void { $container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php'); @@ -108,10 +98,7 @@ public function itCreatesServiceWithBuiltInType(): void ); } - /** - * @test - */ - public function itCreatesServiceWithBuiltInTypeUsingConstantAsDefault(): void + public function testItCreatesServiceWithBuiltInTypeUsingConstantAsDefault(): void { $container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php'); @@ -129,10 +116,7 @@ public function itCreatesServiceWithBuiltInTypeUsingConstantAsDefault(): void ); } - /** - * @test - */ - public function itCreatesServiceFromPluginManager(): void + public function testItCreatesServiceFromPluginManager(): void { $container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php'); @@ -158,10 +142,7 @@ public function itCreatesServiceFromPluginManager(): void ); } - /** - * @test - */ - public function itThrowsExceptionIfServiceNotFound(): void + public function testItThrowsExceptionIfServiceNotFound(): void { $this->expectException(InvalidServiceException::class); diff --git a/test/Integration/Factory/InjectionFactoryTest.php b/test/Integration/Factory/InjectionFactoryTest.php index bad237e..0d9d1f9 100644 --- a/test/Integration/Factory/InjectionFactoryTest.php +++ b/test/Integration/Factory/InjectionFactoryTest.php @@ -1,5 +1,7 @@ getServiceManager(require __DIR__ . '/../../resources/config.php'); @@ -45,10 +44,7 @@ public function itCreatesServiceWithDependencies(): void ); } - /** - * @test - */ - public function itCreatesServiceWithDependenciesFromConstructor(): void + public function testItCreatesServiceWithDependenciesFromConstructor(): void { $container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php'); @@ -66,10 +62,7 @@ public function itCreatesServiceWithDependenciesFromConstructor(): void ); } - /** - * @test - */ - public function itCreatesServiceWithNoInjectionsDefined(): void + public function testItCreatesServiceWithNoInjectionsDefined(): void { $container = $this->getServiceManager([ 'service_manager' => [ @@ -77,7 +70,7 @@ public function itCreatesServiceWithNoInjectionsDefined(): void Service3::class => InjectionFactory::class, ], ], - ]); + ]); $factory = new InjectionFactory(); @@ -93,10 +86,7 @@ public function itCreatesServiceWithNoInjectionsDefined(): void ); } - /** - * @test - */ - public function itCreatesServiceFromCanonicalName(): void + public function testItCreatesServiceFromCanonicalName(): void { $container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php'); @@ -114,10 +104,7 @@ public function itCreatesServiceFromCanonicalName(): void ); } - /** - * @test - */ - public function itCreatesServiceFromPluginManager(): void + public function testItCreatesServiceFromPluginManager(): void { $container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php'); @@ -140,10 +127,7 @@ public function itCreatesServiceFromPluginManager(): void ); } - /** - * @test - */ - public function itThrowsExceptionIfServiceNotFound(): void + public function testItThrowsExceptionIfServiceNotFound(): void { $this->expectException(InvalidServiceException::class); @@ -158,10 +142,7 @@ public function itThrowsExceptionIfServiceNotFound(): void ); } - /** - * @test - */ - public function itResolvesYamlInjections(): void + public function testItResolvesYamlInjections(): void { $config = ArrayUtils::merge( require __DIR__ . '/../../resources/config.php', diff --git a/test/Service/BadInjectionClass.php b/test/Service/BadInjectionClass.php index 5bbaa2c..783c005 100644 --- a/test/Service/BadInjectionClass.php +++ b/test/Service/BadInjectionClass.php @@ -1,5 +1,7 @@ property = $property; diff --git a/test/Service/Factory/Service3Factory.php b/test/Service/Factory/Service3Factory.php index 684bc53..b01e43c 100644 --- a/test/Service/Factory/Service3Factory.php +++ b/test/Service/Factory/Service3Factory.php @@ -1,5 +1,7 @@ service2 = $service2; diff --git a/test/Service/Resolver/TestResolver.php b/test/Service/Resolver/TestResolver.php index 796bf58..11b402f 100644 --- a/test/Service/Resolver/TestResolver.php +++ b/test/Service/Resolver/TestResolver.php @@ -1,5 +1,7 @@ service2 = $service2; diff --git a/test/Service/ServiceAnnotationConstructor.php b/test/Service/ServiceAnnotationConstructor.php index c7e5135..d9c4ffb 100644 --- a/test/Service/ServiceAnnotationConstructor.php +++ b/test/Service/ServiceAnnotationConstructor.php @@ -1,5 +1,7 @@ service2 = $service2; $this->version = $version; diff --git a/test/Service/ServiceBuildInType.php b/test/Service/ServiceBuildInType.php index 63575f6..516b4ac 100644 --- a/test/Service/ServiceBuildInType.php +++ b/test/Service/ServiceBuildInType.php @@ -1,5 +1,7 @@ 'reinfi.di.test']); + $inject = new InjectConfig([ + 'value' => 'reinfi.di.test', + ]); $configService = $this->prophesize(ConfigService::class); $configService->resolve('reinfi.di.test') @@ -38,12 +39,11 @@ public function itCallsConfigServiceFromContainerWithValue(): void ); } - /** - * @test - */ - public function itCallsConfigServiceFromPluginManagerWithValue(): void + public function testItCallsConfigServiceFromPluginManagerWithValue(): void { - $inject = new InjectConfig(['value' => 'reinfi.di.test']); + $inject = new InjectConfig([ + 'value' => 'reinfi.di.test', + ]); $configService = $this->prophesize(ConfigService::class); $configService->resolve('reinfi.di.test') @@ -63,15 +63,15 @@ public function itCallsConfigServiceFromPluginManagerWithValue(): void ); } - /** - * @test - */ - public function itReturnsArrayIfPropertyIsSet(): void + public function testItReturnsArrayIfPropertyIsSet(): void { - $inject = new InjectConfig(['value' => 'reinfi.di.test', 'asArray' => true]); + $inject = new InjectConfig([ + 'value' => 'reinfi.di.test', + 'asArray' => true, + ]); $config = $this->prophesize(Config::class); - $config->toArray()->shouldBeCalled()->willReturn([ true ]); + $config->toArray()->shouldBeCalled()->willReturn([true]); $configService = $this->prophesize(ConfigService::class); $configService->resolve('reinfi.di.test') @@ -82,7 +82,7 @@ public function itReturnsArrayIfPropertyIsSet(): void ->willReturn($configService->reveal()); self::assertEquals( - [ true ], + [true], $inject($container->reveal()), 'Invoke should return array containing true' ); diff --git a/test/Unit/Annotation/InjectConstantTest.php b/test/Unit/Annotation/InjectConstantTest.php index ca4ecce..d4f8621 100644 --- a/test/Unit/Annotation/InjectConstantTest.php +++ b/test/Unit/Annotation/InjectConstantTest.php @@ -1,5 +1,7 @@ value = Service2::class . '::CONSTANT'; diff --git a/test/Unit/Annotation/InjectContainerTest.php b/test/Unit/Annotation/InjectContainerTest.php index 2548357..f0c9191 100644 --- a/test/Unit/Annotation/InjectContainerTest.php +++ b/test/Unit/Annotation/InjectContainerTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Annotation/InjectDoctrineRepositoryTest.php b/test/Unit/Annotation/InjectDoctrineRepositoryTest.php index f7f1196..3cee6c6 100644 --- a/test/Unit/Annotation/InjectDoctrineRepositoryTest.php +++ b/test/Unit/Annotation/InjectDoctrineRepositoryTest.php @@ -1,5 +1,7 @@ EntityRepository::class ], + [ + 'value' => EntityRepository::class, + ], EntityRepository::class, ], [ - [ 'entity' => EntityRepository::class ], + [ + 'entity' => EntityRepository::class, + ], EntityRepository::class, ], ]; } - /** - * @return array - */ public function getAnnotationValuesWithEntityManager(): array { return [ [ [ 'entity' => EntityRepository::class, - 'em' => 'doctrine.entityManager', + 'em' => 'doctrine.entityManager', ], 'doctrine.entityManager', EntityRepository::class, ], [ [ - 'entity' => EntityRepository::class, + 'entity' => EntityRepository::class, 'entityManager' => 'doctrine.entityManager', ], 'doctrine.entityManager', diff --git a/test/Unit/Annotation/InjectFilterTest.php b/test/Unit/Annotation/InjectFilterTest.php index ef04cac..a7650ca 100644 --- a/test/Unit/Annotation/InjectFilterTest.php +++ b/test/Unit/Annotation/InjectFilterTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Annotation/InjectFormElementTest.php b/test/Unit/Annotation/InjectFormElementTest.php index dee104b..5239107 100644 --- a/test/Unit/Annotation/InjectFormElementTest.php +++ b/test/Unit/Annotation/InjectFormElementTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Annotation/InjectHydratorTest.php b/test/Unit/Annotation/InjectHydratorTest.php index c05b149..b19e5ba 100644 --- a/test/Unit/Annotation/InjectHydratorTest.php +++ b/test/Unit/Annotation/InjectHydratorTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Annotation/InjectInputFilterTest.php b/test/Unit/Annotation/InjectInputFilterTest.php index 39c227f..569eecd 100644 --- a/test/Unit/Annotation/InjectInputFilterTest.php +++ b/test/Unit/Annotation/InjectInputFilterTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Annotation/InjectParentTest.php b/test/Unit/Annotation/InjectParentTest.php index b6bc800..c793a4a 100644 --- a/test/Unit/Annotation/InjectParentTest.php +++ b/test/Unit/Annotation/InjectParentTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Annotation/InjectViewHelperTest.php b/test/Unit/Annotation/InjectViewHelperTest.php index abab644..78cd593 100644 --- a/test/Unit/Annotation/InjectViewHelperTest.php +++ b/test/Unit/Annotation/InjectViewHelperTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Attribute/AbstractInjectPluginManagerTest.php b/test/Unit/Attribute/AbstractInjectPluginManagerTest.php index 376b795..e18ea86 100644 --- a/test/Unit/Attribute/AbstractInjectPluginManagerTest.php +++ b/test/Unit/Attribute/AbstractInjectPluginManagerTest.php @@ -16,10 +16,7 @@ class AbstractInjectPluginManagerTest extends TestCase { use ProphecyTrait; - /** - * @test - */ - public function itThrowsExceptionIfNotInstanceOfPluginManager(): void + public function testItThrowsExceptionIfNotInstanceOfPluginManager(): void { $this->expectException(InjectionNotPossibleException::class); @@ -31,6 +28,5 @@ public function itThrowsExceptionIfNotInstanceOfPluginManager(): void $container->get('NOT-A-PLUGIN-MANAGER')->willReturn($noPluginManagerClass->reveal()); $attribute($container->reveal()); - } } diff --git a/test/Unit/Attribute/InjectConfigTest.php b/test/Unit/Attribute/InjectConfigTest.php index d949f95..b132792 100644 --- a/test/Unit/Attribute/InjectConfigTest.php +++ b/test/Unit/Attribute/InjectConfigTest.php @@ -1,5 +1,7 @@ prophesize(Config::class); - $config->toArray()->shouldBeCalled()->willReturn([ true ]); + $config->toArray()->shouldBeCalled()->willReturn([true]); $configService = $this->prophesize(ConfigService::class); $configService->resolve('reinfi.di.test') @@ -82,7 +75,7 @@ public function itReturnsArrayIfPropertyIsSet(): void ->willReturn($configService->reveal()); self::assertEquals( - [ true ], + [true], $inject($container->reveal()), 'Invoke should return array containing true' ); diff --git a/test/Unit/Attribute/InjectConstantTest.php b/test/Unit/Attribute/InjectConstantTest.php index 5420164..606bca9 100644 --- a/test/Unit/Attribute/InjectConstantTest.php +++ b/test/Unit/Attribute/InjectConstantTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Attribute/InjectDoctrineRepositoryTest.php b/test/Unit/Attribute/InjectDoctrineRepositoryTest.php index 43a72ef..3bda4de 100644 --- a/test/Unit/Attribute/InjectDoctrineRepositoryTest.php +++ b/test/Unit/Attribute/InjectDoctrineRepositoryTest.php @@ -1,5 +1,7 @@ EntityRepository::class ], + [ + 'entity' => EntityRepository::class, + ], EntityRepository::class, ], ]; } - /** - * @return array - */ public function getAttributeValuesWithEntityManager(): array { return [ [ [ - 'entity' => EntityRepository::class, + 'entity' => EntityRepository::class, 'entityManager' => 'doctrine.entityManager', ], 'doctrine.entityManager', @@ -148,10 +130,7 @@ public function getAttributeValuesWithEntityManager(): array ]; } - /** - * @test - */ - public function itThrowsExceptionIfEntityManagerIsNotAnObject(): void + public function testItThrowsExceptionIfEntityManagerIsNotAnObject(): void { $this->expectException(AutoWiringNotPossibleException::class); @@ -164,10 +143,7 @@ public function itThrowsExceptionIfEntityManagerIsNotAnObject(): void $inject($container->reveal()); } - /** - * @test - */ - public function itThrowsExceptionIfEntityManagerHasNotGetRepositoryMethod(): void + public function testItThrowsExceptionIfEntityManagerHasNotGetRepositoryMethod(): void { $this->expectException(AutoWiringNotPossibleException::class); diff --git a/test/Unit/Attribute/InjectFilterTest.php b/test/Unit/Attribute/InjectFilterTest.php index 0bf3a2b..7c6b439 100644 --- a/test/Unit/Attribute/InjectFilterTest.php +++ b/test/Unit/Attribute/InjectFilterTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Attribute/InjectFormElementTest.php b/test/Unit/Attribute/InjectFormElementTest.php index 73b4d21..ff47791 100644 --- a/test/Unit/Attribute/InjectFormElementTest.php +++ b/test/Unit/Attribute/InjectFormElementTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Attribute/InjectHydratorTest.php b/test/Unit/Attribute/InjectHydratorTest.php index 9c44667..86d7cd5 100644 --- a/test/Unit/Attribute/InjectHydratorTest.php +++ b/test/Unit/Attribute/InjectHydratorTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Attribute/InjectInputFilterTest.php b/test/Unit/Attribute/InjectInputFilterTest.php index 86f5c30..8c61d26 100644 --- a/test/Unit/Attribute/InjectInputFilterTest.php +++ b/test/Unit/Attribute/InjectInputFilterTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Attribute/InjectParentTest.php b/test/Unit/Attribute/InjectParentTest.php index ecaedd7..c0cd7ac 100644 --- a/test/Unit/Attribute/InjectParentTest.php +++ b/test/Unit/Attribute/InjectParentTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Attribute/InjectViewHelperTest.php b/test/Unit/Attribute/InjectViewHelperTest.php index 63f5a65..e6d6a98 100644 --- a/test/Unit/Attribute/InjectViewHelperTest.php +++ b/test/Unit/Attribute/InjectViewHelperTest.php @@ -1,5 +1,7 @@ Service1::class, - 'options' => [ 'field' => true ], + 'name' => Service1::class, + 'options' => [ + 'field' => true, + ], ], Service1::class, ], diff --git a/test/Unit/Config/Factory/ModuleConfigFactoryTest.php b/test/Unit/Config/Factory/ModuleConfigFactoryTest.php index 0b8f3a3..3595d23 100644 --- a/test/Unit/Config/Factory/ModuleConfigFactoryTest.php +++ b/test/Unit/Config/Factory/ModuleConfigFactoryTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); $container->get('config') - ->willReturn([ ModuleConfig::CONFIG_KEY => [] ]); + ->willReturn([ + ModuleConfig::CONFIG_KEY => [], + ]); self::assertIsArray( $factory($container->reveal()), @@ -33,16 +34,17 @@ public function itReturnsModuleConfig(): void ); } - /** - * @test - */ - public function itReturnsModuleConfigData(): void + public function testItReturnsModuleConfigData(): void { $factory = new ModuleConfigFactory(); $container = $this->prophesize(ContainerInterface::class); $container->get('config') - ->willReturn([ ModuleConfig::CONFIG_KEY => [ 'extractor' => '' ] ]); + ->willReturn([ + ModuleConfig::CONFIG_KEY => [ + 'extractor' => '', + ], + ]); $config = $factory($container->reveal()); @@ -53,10 +55,7 @@ public function itReturnsModuleConfigData(): void ); } - /** - * @test - */ - public function itReturnsEmptyConfig(): void + public function testItReturnsEmptyConfig(): void { $factory = new ModuleConfigFactory(); @@ -73,10 +72,7 @@ public function itReturnsEmptyConfig(): void ); } - /** - * @test - */ - public function itThrowsExceptionIfModuleConfigIsNotArray(): void + public function testItThrowsExceptionIfModuleConfigIsNotArray(): void { $this->expectException(InvalidArgumentException::class); @@ -84,7 +80,9 @@ public function itThrowsExceptionIfModuleConfigIsNotArray(): void $container = $this->prophesize(ContainerInterface::class); $container->get('config') - ->willReturn([ ModuleConfig::CONFIG_KEY => true ]); + ->willReturn([ + ModuleConfig::CONFIG_KEY => true, + ]); $factory($container->reveal()); } diff --git a/test/Unit/ConfigProviderTest.php b/test/Unit/ConfigProviderTest.php index 3df0d3c..c2bbae1 100644 --- a/test/Unit/ConfigProviderTest.php +++ b/test/Unit/ConfigProviderTest.php @@ -9,10 +9,7 @@ class ConfigProviderTest extends TestCase { - /** - * @test - */ - public function itReturnsDependencies(): void + public function testItReturnsDependencies(): void { $configProvider = new ConfigProvider(); diff --git a/test/Unit/Extension/PHPStan/Resolve/AutoWiringClassesResolverTest.php b/test/Unit/Extension/PHPStan/Resolve/AutoWiringClassesResolverTest.php index 808fc41..0a00f3b 100644 --- a/test/Unit/Extension/PHPStan/Resolve/AutoWiringClassesResolverTest.php +++ b/test/Unit/Extension/PHPStan/Resolve/AutoWiringClassesResolverTest.php @@ -15,10 +15,7 @@ class AutoWiringClassesResolverTest extends TestCase { use ProphecyTrait; - /** - * @test - */ - public function itReturnsFalseIfNoServiceManagerIsProvided(): void + public function testItReturnsFalseIfNoServiceManagerIsProvided(): void { $serviceManagerLoader = new ServiceManagerLoader(null); @@ -29,10 +26,7 @@ public function itReturnsFalseIfNoServiceManagerIsProvided(): void ); } - /** - * @test - */ - public function itReturnsTrueIfClassIsRegisteredForAutoWiring(): void + public function testItReturnsTrueIfClassIsRegisteredForAutoWiring(): void { $serviceManagerLoader = new ServiceManagerLoader( __DIR__ . '/../../../../resources/container.php' diff --git a/test/Unit/Factory/AutoWiringFactoryTest.php b/test/Unit/Factory/AutoWiringFactoryTest.php index 075de4e..7e03157 100644 --- a/test/Unit/Factory/AutoWiringFactoryTest.php +++ b/test/Unit/Factory/AutoWiringFactoryTest.php @@ -1,5 +1,7 @@ prophesize(AutoWiringService::class); $service->resolveConstructorInjection( @@ -43,7 +42,7 @@ public function itCreatesServiceWithInjections(): void $instance = $factory->createService( $container->reveal(), Service1::class, - Service1::class + Service1::class ); self::assertInstanceOf( @@ -52,12 +51,11 @@ public function itCreatesServiceWithInjections(): void ); } - /** - * @test - */ - public function itCreatesServiceWithInjectionsWithOptions(): void + public function testItCreatesServiceWithInjectionsWithOptions(): void { - $options = ['foo' => 'bar']; + $options = [ + 'foo' => 'bar', + ]; $service = $this->prophesize(AutoWiringService::class); $service->resolveConstructorInjection( Argument::type(ContainerInterface::class), @@ -79,10 +77,7 @@ public function itCreatesServiceWithInjectionsWithOptions(): void ); } - /** - * @test - */ - public function itCreatesServiceFromCanonicalName(): void + public function testItCreatesServiceFromCanonicalName(): void { $service = $this->prophesize(AutoWiringService::class); $service->resolveConstructorInjection( @@ -108,10 +103,7 @@ public function itCreatesServiceFromCanonicalName(): void ); } - /** - * @test - */ - public function itCreatesServiceFromPluginManager(): void + public function testItCreatesServiceFromPluginManager(): void { $service = $this->prophesize(AutoWiringService::class); $service->resolveConstructorInjection( @@ -141,10 +133,7 @@ public function itCreatesServiceFromPluginManager(): void ); } - /** - * @test - */ - public function itCreatesServiceWithNoInjections(): void + public function testItCreatesServiceWithNoInjections(): void { $service = $this->prophesize(AutoWiringService::class); $service->resolveConstructorInjection( @@ -170,10 +159,7 @@ public function itCreatesServiceWithNoInjections(): void ); } - /** - * @test - */ - public function itThrowsExceptionIfClassNotSet(): void + public function testItThrowsExceptionIfClassNotSet(): void { $this->expectException(InvalidServiceException::class); @@ -186,10 +172,7 @@ public function itThrowsExceptionIfClassNotSet(): void ); } - /** - * @test - */ - public function itThrowsExceptionIfClassNotFound(): void + public function testItThrowsExceptionIfClassNotFound(): void { $this->expectException(InvalidServiceException::class); diff --git a/test/Unit/Factory/InjectionFactoryTest.php b/test/Unit/Factory/InjectionFactoryTest.php index f9fa509..890c97c 100644 --- a/test/Unit/Factory/InjectionFactoryTest.php +++ b/test/Unit/Factory/InjectionFactoryTest.php @@ -1,5 +1,7 @@ prophesize(InjectionService::class); $service->resolveConstructorInjection( @@ -42,7 +41,7 @@ public function itCreatesServiceWithInjections(): void $instance = $factory->createService( $container->reveal(), Service1::class, - Service1::class + Service1::class ); self::assertInstanceOf( @@ -51,10 +50,7 @@ public function itCreatesServiceWithInjections(): void ); } - /** - * @test - */ - public function itCreatesServiceFromCanonicalName(): void + public function testItCreatesServiceFromCanonicalName(): void { $service = $this->prophesize(InjectionService::class); $service->resolveConstructorInjection( @@ -79,10 +75,7 @@ public function itCreatesServiceFromCanonicalName(): void ); } - /** - * @test - */ - public function itCreatesServiceFromPluginManager(): void + public function testItCreatesServiceFromPluginManager(): void { $service = $this->prophesize(InjectionService::class); $service->resolveConstructorInjection( @@ -111,10 +104,7 @@ public function itCreatesServiceFromPluginManager(): void ); } - /** - * @test - */ - public function itCreatesServiceWithNoInjections(): void + public function testItCreatesServiceWithNoInjections(): void { $service = $this->prophesize(InjectionService::class); $service->resolveConstructorInjection( @@ -139,10 +129,7 @@ public function itCreatesServiceWithNoInjections(): void ); } - /** - * @test - */ - public function itThrowsExceptionIfClassNotFound(): void + public function testItThrowsExceptionIfClassNotFound(): void { $this->expectException(InvalidServiceException::class); diff --git a/test/Unit/Injection/AutoWiringContainerTest.php b/test/Unit/Injection/AutoWiringContainerTest.php index c8811e0..aba6e07 100644 --- a/test/Unit/Injection/AutoWiringContainerTest.php +++ b/test/Unit/Injection/AutoWiringContainerTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); diff --git a/test/Unit/Injection/AutoWiringPluginManagerTest.php b/test/Unit/Injection/AutoWiringPluginManagerTest.php index 2509464..0c8a9fe 100644 --- a/test/Unit/Injection/AutoWiringPluginManagerTest.php +++ b/test/Unit/Injection/AutoWiringPluginManagerTest.php @@ -1,5 +1,7 @@ prophesize(AbstractPluginManager::class); $pluginManager->has(Service1::class) @@ -45,10 +44,7 @@ public function itReturnsServiceFromContainer(): void ); } - /** - * @test - */ - public function itReturnsServiceFromParentLocator(): void + public function testItReturnsServiceFromParentLocator(): void { $pluginManager = $this->prophesize(AbstractPluginManager::class); $pluginManager->has(Service1::class) @@ -77,10 +73,7 @@ public function itReturnsServiceFromParentLocator(): void ); } - /** - * @test - */ - public function itThrowsExceptionIfServiceNotFound(): void + public function testItThrowsExceptionIfServiceNotFound(): void { $this->expectException(AutoWiringNotPossibleException::class); diff --git a/test/Unit/Injection/AutoWiringTest.php b/test/Unit/Injection/AutoWiringTest.php index 6717795..c65ea8e 100644 --- a/test/Unit/Injection/AutoWiringTest.php +++ b/test/Unit/Injection/AutoWiringTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); $container->has(Service1::class) @@ -38,10 +37,7 @@ public function itReturnsServiceFromContainer(): void ); } - /** - * @test - */ - public function itReturnsServiceFromParentLocator(): void + public function testItReturnsServiceFromParentLocator(): void { $container = $this->prophesize(ContainerInterface::class); $container->has(Service1::class) @@ -65,10 +61,7 @@ public function itReturnsServiceFromParentLocator(): void ); } - /** - * @test - */ - public function itThrowsExceptionIfServiceNotFound(): void + public function testItThrowsExceptionIfServiceNotFound(): void { $this->expectException(AutoWiringNotPossibleException::class); diff --git a/test/Unit/ModuleTest.php b/test/Unit/ModuleTest.php index bed4de3..f712080 100644 --- a/test/Unit/ModuleTest.php +++ b/test/Unit/ModuleTest.php @@ -1,8 +1,9 @@ prophesize(ContainerInterface::class); @@ -45,19 +44,19 @@ public function itCreatesResolverServiceWithDefaultResolvers(): void self::assertInstanceOf( ResolverService::class, $factory($container->reveal()), - 'factory should return instance of ' . ResolverService::class); + 'factory should return instance of ' . ResolverService::class + ); } - /** - * @test - */ - public function itCreatesResolverServiceWithAdditionalResolvers(): void + public function testItCreatesResolverServiceWithAdditionalResolvers(): void { $container = $this->prophesize(ContainerInterface::class); $container->get(ModuleConfig::class) ->willReturn( - ['autowire_resolver' => [ TestResolver::class ], ] + [ + 'autowire_resolver' => [TestResolver::class], + ] ); $container->get(ContainerResolver::class)->shouldBeCalled(); @@ -73,6 +72,7 @@ public function itCreatesResolverServiceWithAdditionalResolvers(): void self::assertInstanceOf( ResolverService::class, $factory($container->reveal()), - 'factory should return instance of ' . ResolverService::class); + 'factory should return instance of ' . ResolverService::class + ); } } diff --git a/test/Unit/Service/AutoWiring/LazyResolverServiceTest.php b/test/Unit/Service/AutoWiring/LazyResolverServiceTest.php index 4f341dc..84f1822 100644 --- a/test/Unit/Service/AutoWiring/LazyResolverServiceTest.php +++ b/test/Unit/Service/AutoWiring/LazyResolverServiceTest.php @@ -1,5 +1,7 @@ prophesize(ResolverServiceInterface::class); $resolverService->resolve('test', null) @@ -37,31 +36,27 @@ public function itResolvesResolverServiceLazy(): void $service->resolve('test'); } - /** - * @test - */ - public function itResolvesResolverServiceLazyWithOptions(): void + public function testItResolvesResolverServiceLazyWithOptions(): void { - $options = ['foo' => 'bar']; + $options = [ + 'foo' => 'bar', + ]; $resolverService = $this->prophesize(ResolverServiceInterface::class); $resolverService->resolve('test', $options) - ->willReturn([]); + ->willReturn([]); $container = $this->prophesize(ContainerInterface::class); $container->get(ResolverService::class) - ->willReturn($resolverService->reveal()) - ->shouldBeCalled(); + ->willReturn($resolverService->reveal()) + ->shouldBeCalled(); $service = new LazyResolverService($container->reveal()); $service->resolve('test', $options); } - /** - * @test - */ - public function itResolvesResolverServiceOnlyOnce(): void + public function testItResolvesResolverServiceOnlyOnce(): void { $resolverService = $this->prophesize(ResolverServiceInterface::class); $resolverService->resolve('test', null) diff --git a/test/Unit/Service/AutoWiring/Resolver/BuildInTypeWithDefaultResolverTest.php b/test/Unit/Service/AutoWiring/Resolver/BuildInTypeWithDefaultResolverTest.php index 7e7f6ad..1f01164 100644 --- a/test/Unit/Service/AutoWiring/Resolver/BuildInTypeWithDefaultResolverTest.php +++ b/test/Unit/Service/AutoWiring/Resolver/BuildInTypeWithDefaultResolverTest.php @@ -1,5 +1,7 @@ prophesize(ReflectionNamedType::class); @@ -70,10 +63,7 @@ public function itReturnsNullIfIsAbstractPluginManager(): void self::assertNull($injection); } - /** - * @test - */ - public function itReturnsNullIfOtherClass(): void + public function testItReturnsNullIfOtherClass(): void { $resolver = new ContainerInterfaceResolver(); @@ -87,10 +77,7 @@ public function itReturnsNullIfOtherClass(): void self::assertNull($injection); } - /** - * @test - */ - public function itReturnsNullIfClassDoesNotExists(): void + public function testItReturnsNullIfClassDoesNotExists(): void { $resolver = new ContainerInterfaceResolver(); @@ -104,10 +91,7 @@ public function itReturnsNullIfClassDoesNotExists(): void self::assertNull($injection); } - /** - * @test - */ - public function itReturnsNullIfParameterHasNoType(): void + public function testItReturnsNullIfParameterHasNoType(): void { $resolver = new ContainerInterfaceResolver(); diff --git a/test/Unit/Service/AutoWiring/Resolver/ContainerResolverTest.php b/test/Unit/Service/AutoWiring/Resolver/ContainerResolverTest.php index 8c8d0b9..aa5d2e7 100644 --- a/test/Unit/Service/AutoWiring/Resolver/ContainerResolverTest.php +++ b/test/Unit/Service/AutoWiring/Resolver/ContainerResolverTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); $container->has(Service1::class) @@ -40,10 +39,7 @@ public function itReturnsInjectionInterface(): void self::assertInstanceOf(InjectionInterface::class, $injection); } - /** - * @test - */ - public function itReturnsClassName(): void + public function testItReturnsClassName(): void { $container = $this->prophesize(ContainerInterface::class); $container->has(Service1::class) @@ -68,10 +64,7 @@ public function itReturnsClassName(): void ); } - /** - * @test - */ - public function itReturnsNullIfServiceNotFound(): void + public function testItReturnsNullIfServiceNotFound(): void { $container = $this->prophesize(ContainerInterface::class); $container->has(Service1::class) @@ -89,10 +82,7 @@ public function itReturnsNullIfServiceNotFound(): void self::assertNull($injection); } - /** - * @test - */ - public function itReturnsNullIfParameterHasNoType(): void + public function testItReturnsNullIfParameterHasNoType(): void { $container = $this->prophesize(ContainerInterface::class); diff --git a/test/Unit/Service/AutoWiring/Resolver/Factory/ContainerResolverFactoryTest.php b/test/Unit/Service/AutoWiring/Resolver/Factory/ContainerResolverFactoryTest.php index 91e4345..ef42850 100644 --- a/test/Unit/Service/AutoWiring/Resolver/Factory/ContainerResolverFactoryTest.php +++ b/test/Unit/Service/AutoWiring/Resolver/Factory/ContainerResolverFactoryTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); diff --git a/test/Unit/Service/AutoWiring/Resolver/Factory/PluginManagerResolverFactoryTest.php b/test/Unit/Service/AutoWiring/Resolver/Factory/PluginManagerResolverFactoryTest.php index 23738ce..676cfbe 100644 --- a/test/Unit/Service/AutoWiring/Resolver/Factory/PluginManagerResolverFactoryTest.php +++ b/test/Unit/Service/AutoWiring/Resolver/Factory/PluginManagerResolverFactoryTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); diff --git a/test/Unit/Service/AutoWiring/Resolver/Factory/TranslatorResolverFactoryTest.php b/test/Unit/Service/AutoWiring/Resolver/Factory/TranslatorResolverFactoryTest.php index 11f4eb7..3848a59 100644 --- a/test/Unit/Service/AutoWiring/Resolver/Factory/TranslatorResolverFactoryTest.php +++ b/test/Unit/Service/AutoWiring/Resolver/Factory/TranslatorResolverFactoryTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); diff --git a/test/Unit/Service/AutoWiring/Resolver/PluginManagerResolverTest.php b/test/Unit/Service/AutoWiring/Resolver/PluginManagerResolverTest.php index a542f65..99b4b23 100644 --- a/test/Unit/Service/AutoWiring/Resolver/PluginManagerResolverTest.php +++ b/test/Unit/Service/AutoWiring/Resolver/PluginManagerResolverTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); $resolver = new PluginManagerResolver($container->reveal()); @@ -171,10 +157,7 @@ public function itReturnsNullIfNoPluginManagerFound(): void ); } - /** - * @test - */ - public function itReturnsNullIfParameterHasNoType(): void + public function testItReturnsNullIfParameterHasNoType(): void { $container = $this->prophesize(ContainerInterface::class); @@ -188,9 +171,6 @@ public function itReturnsNullIfParameterHasNoType(): void self::assertNull($injection); } - /** - * @return array - */ public function getPluginManagerData(): array { return [ diff --git a/test/Unit/Service/AutoWiring/Resolver/RequestResolverTest.php b/test/Unit/Service/AutoWiring/Resolver/RequestResolverTest.php index ce8df1d..4ae4abb 100644 --- a/test/Unit/Service/AutoWiring/Resolver/RequestResolverTest.php +++ b/test/Unit/Service/AutoWiring/Resolver/RequestResolverTest.php @@ -1,5 +1,7 @@ prophesize(ReflectionNamedType::class); $type->getName()->willReturn(Response::class); $parameter = $this->prophesize(ReflectionParameter::class); @@ -54,10 +49,7 @@ public function itReturnsInjectionInterfaceForResponseClass(): void self::assertInstanceOf(AutoWiring::class, $injection); } - /** - * @test - */ - public function itReturnsNullIfNoResponse(): void + public function testItReturnsNullIfNoResponse(): void { $resolver = new ResponseResolver(); @@ -72,10 +64,7 @@ public function itReturnsNullIfNoResponse(): void ); } - /** - * @test - */ - public function itReturnsNullIfClassDoesNotExists(): void + public function testItReturnsNullIfClassDoesNotExists(): void { $resolver = new ResponseResolver(); @@ -90,10 +79,7 @@ public function itReturnsNullIfClassDoesNotExists(): void ); } - /** - * @test - */ - public function itReturnsNullIfParameterHasNoClass(): void + public function testItReturnsNullIfParameterHasNoClass(): void { $resolver = new ResponseResolver(); diff --git a/test/Unit/Service/AutoWiring/Resolver/TranslatorResolverTest.php b/test/Unit/Service/AutoWiring/Resolver/TranslatorResolverTest.php index 33b67f2..a38dcd9 100644 --- a/test/Unit/Service/AutoWiring/Resolver/TranslatorResolverTest.php +++ b/test/Unit/Service/AutoWiring/Resolver/TranslatorResolverTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); @@ -35,7 +34,9 @@ public function itReturnsInjectionInterfaceForTranslatorInterface( foreach ($containerHasCalls as $serviceName => $result) { $container->addMethodProphecy( (new MethodProphecy( - $container, 'has', [ Argument::exact($serviceName) ] + $container, + 'has', + [Argument::exact($serviceName)] )) ->willReturn($result) ->shouldBeCalled() @@ -55,12 +56,9 @@ public function itReturnsInjectionInterfaceForTranslatorInterface( } /** - * @test * @dataProvider containerHasCallsProvider - * - * @param array $containerHasCalls */ - public function itReturnsInjectionInterfaceForTranslatorClass( + public function testItReturnsInjectionInterfaceForTranslatorClass( array $containerHasCalls ): void { $container = $this->prophesize(ContainerInterface::class); @@ -68,7 +66,9 @@ public function itReturnsInjectionInterfaceForTranslatorClass( foreach ($containerHasCalls as $serviceName => $result) { $container->addMethodProphecy( (new MethodProphecy( - $container, 'has', [ Argument::exact($serviceName) ] + $container, + 'has', + [Argument::exact($serviceName)] )) ->willReturn($result) ); @@ -85,10 +85,7 @@ public function itReturnsInjectionInterfaceForTranslatorClass( self::assertInstanceOf(AutoWiring::class, $injection); } - /** - * @test - */ - public function itReturnsNullIfNoTranslatorRegistered(): void + public function testItReturnsNullIfNoTranslatorRegistered(): void { $container = $this->prophesize(ContainerInterface::class); @@ -109,10 +106,7 @@ public function itReturnsNullIfNoTranslatorRegistered(): void ); } - /** - * @test - */ - public function itReturnsNullIfReflectionParameterHasNoType(): void + public function testItReturnsNullIfReflectionParameterHasNoType(): void { $container = $this->prophesize(ContainerInterface::class); @@ -131,10 +125,7 @@ public function itReturnsNullIfReflectionParameterHasNoType(): void ); } - /** - * @test - */ - public function itReturnsNullIfNoTranslatorInterface(): void + public function testItReturnsNullIfNoTranslatorInterface(): void { $container = $this->prophesize(ContainerInterface::class); @@ -151,10 +142,7 @@ public function itReturnsNullIfNoTranslatorInterface(): void ); } - /** - * @test - */ - public function itReturnsNullIfParameterHasNoType(): void + public function testItReturnsNullIfParameterHasNoType(): void { $container = $this->prophesize(ContainerInterface::class); @@ -169,9 +157,6 @@ public function itReturnsNullIfParameterHasNoType(): void ); } - /** - * @return array - */ public function containerHasCallsProvider(): array { return [ @@ -182,15 +167,15 @@ public function containerHasCallsProvider(): array ], [ [ - 'MvcTranslator' => false, + 'MvcTranslator' => false, 'Laminas\I18n\Translator\TranslatorInterface' => true, ], ], [ [ - 'MvcTranslator' => false, + 'MvcTranslator' => false, 'Laminas\I18n\Translator\TranslatorInterface' => false, - 'Translator' => true, + 'Translator' => true, ], ], ]; diff --git a/test/Unit/Service/AutoWiring/ResolverServiceTest.php b/test/Unit/Service/AutoWiring/ResolverServiceTest.php index 6f6e1c6..dfb9764 100644 --- a/test/Unit/Service/AutoWiring/ResolverServiceTest.php +++ b/test/Unit/Service/AutoWiring/ResolverServiceTest.php @@ -1,5 +1,7 @@ prophesize(ResolverInterface::class); $resolver->resolve(Argument::type(ReflectionParameter::class)) @@ -35,20 +34,18 @@ public function itResolvesConstructorArguments(): void new AutoWiring(Service2::class) ); - $service = new ResolverService([ $resolver->reveal() ]); + $service = new ResolverService([$resolver->reveal()]); $injections = $service->resolve(Service1::class); self::assertCount(3, $injections); self::assertContainsOnlyInstancesOf( - InjectionInterface::class, $injections + InjectionInterface::class, + $injections ); } - /** - * @test - */ - public function itResolvesConstructorArgumentsWithOptionsParameter(): void + public function testItResolvesConstructorArgumentsWithOptionsParameter(): void { $resolver = $this->prophesize(ResolverInterface::class); $resolver->resolve(Argument::type(ReflectionParameter::class)) @@ -56,13 +53,16 @@ public function itResolvesConstructorArgumentsWithOptionsParameter(): void new AutoWiring(Service2::class) ); - $service = new ResolverService([ $resolver->reveal() ]); + $service = new ResolverService([$resolver->reveal()]); - $injections = $service->resolve(Service1::class, ['foo' => 'bar']); + $injections = $service->resolve(Service1::class, [ + 'foo' => 'bar', + ]); self::assertCount(3, $injections); self::assertContainsOnlyInstancesOf( - InjectionInterface::class, $injections + InjectionInterface::class, + $injections ); self::assertSame( 'bar', @@ -70,14 +70,11 @@ public function itResolvesConstructorArgumentsWithOptionsParameter(): void ); } - /** - * @test - */ - public function itReturnsEmptyArrayIfNoConstructorArguments(): void + public function testItReturnsEmptyArrayIfNoConstructorArguments(): void { $resolver = $this->prophesize(ResolverInterface::class); - $service = new ResolverService([ $resolver->reveal() ]); + $service = new ResolverService([$resolver->reveal()]); $injections = $service->resolve(Service2::class); @@ -85,13 +82,9 @@ public function itReturnsEmptyArrayIfNoConstructorArguments(): void } /** - * @test - * * @dataProvider exceptionServiceDataProvider - * - * @param string $serviceName */ - public function itThrowsExceptionIfDependencyCouldNotResolved(string $serviceName): void + public function testItThrowsExceptionIfDependencyCouldNotResolved(string $serviceName): void { $this->expectException(AutoWiringNotPossibleException::class); @@ -99,27 +92,23 @@ public function itThrowsExceptionIfDependencyCouldNotResolved(string $serviceNam $resolver->resolve(Argument::type(ReflectionParameter::class)) ->willReturn(null); - $service = new ResolverService([ $resolver->reveal() ]); + $service = new ResolverService([$resolver->reveal()]); $service->resolve($serviceName); } /** - * @test - * * @dataProvider exceptionServiceDataProvider - * - * @param string $serviceName */ - public function itShouldAddTheResolveClassToExceptionIfDependencyCouldNotResolved(string $serviceName): void + public function testItShouldAddTheResolveClassToExceptionIfDependencyCouldNotResolved(string $serviceName): void { $this->expectExceptionMessage($serviceName); $resolver = $this->prophesize(ResolverInterface::class); $resolver->resolve(Argument::type(ReflectionParameter::class)) - ->willReturn(null); + ->willReturn(null); - $service = new ResolverService([ $resolver->reveal() ]); + $service = new ResolverService([$resolver->reveal()]); $service->resolve($serviceName); } @@ -127,9 +116,9 @@ public function itShouldAddTheResolveClassToExceptionIfDependencyCouldNotResolve public function exceptionServiceDataProvider(): array { return [ - [ Service1::class ], - [ ServiceNoTypeHint::class ], - [ ServiceBuildInType::class ], + [Service1::class], + [ServiceNoTypeHint::class], + [ServiceBuildInType::class], ]; } } diff --git a/test/Unit/Service/AutoWiringServiceTest.php b/test/Unit/Service/AutoWiringServiceTest.php index a48f9c8..e4a76d6 100644 --- a/test/Unit/Service/AutoWiringServiceTest.php +++ b/test/Unit/Service/AutoWiringServiceTest.php @@ -1,5 +1,7 @@ buildCacheKey(Service1::class); $resolver = $this->prophesize(ResolverService::class); @@ -40,8 +39,8 @@ public function itResolvesConstructorArguments(): void $resolver->resolve(Service1::class, null) ->willReturn([ - $injection->reveal(), - ]); + $injection->reveal(), + ]); $cache = $this->prophesize(CacheService::class); $cache->has($cacheKey)->willReturn(false); @@ -62,14 +61,13 @@ public function itResolvesConstructorArguments(): void self::assertCount(1, $injections); } - /** - * @test - */ - public function itResolvesConstructorArgumentsWithOptions(): void + public function testItResolvesConstructorArgumentsWithOptions(): void { $cacheKey = $this->buildCacheKey(Service1::class); $resolver = $this->prophesize(ResolverService::class); - $options = ['foo' => 'bar']; + $options = [ + 'foo' => 'bar', + ]; $injection = $this->prophesize(InjectionInterface::class); $injection->addMethodProphecy( @@ -87,9 +85,9 @@ public function itResolvesConstructorArgumentsWithOptions(): void $resolver->resolve(Service1::class, $options) ->willReturn([ - $injection->reveal(), - $optionsInjection->reveal(), - ]); + $injection->reveal(), + $optionsInjection->reveal(), + ]); $cache = $this->prophesize(CacheService::class); $cache->has($cacheKey)->willReturn(false); @@ -111,10 +109,7 @@ public function itResolvesConstructorArgumentsWithOptions(): void self::assertCount(2, $injections); } - /** - * @test - */ - public function itUsesCacheItemWhenFound(): void + public function testItUsesCacheItemWhenFound(): void { $cacheKey = $this->buildCacheKey(Service1::class); $resolverService = $this->prophesize(ResolverService::class); @@ -122,13 +117,13 @@ public function itUsesCacheItemWhenFound(): void $injection = $this->prophesize(InjectionInterface::class); $injection->addMethodProphecy( (new MethodProphecy($injection, '__invoke', [Argument::type(ContainerInterface::class)])) - ->willReturn(new Service2()) + ->willReturn(new Service2()) ); $cache = $this->prophesize(CacheService::class); $cache->has($cacheKey)->willReturn(true); $cache->get($cacheKey)->willReturn([ - $injection->reveal() + $injection->reveal(), ]); $service = new AutoWiringService( @@ -146,19 +141,18 @@ public function itUsesCacheItemWhenFound(): void self::assertCount(1, $injections); } - /** - * @test - */ - public function itDoesNotCacheOptions(): void + public function testItDoesNotCacheOptions(): void { $cacheKey = $this->buildCacheKey(Service1::class); $resolverService = $this->prophesize(ResolverService::class); - $options = ['foo' => 'bar']; + $options = [ + 'foo' => 'bar', + ]; $injection = $this->prophesize(InjectionInterface::class); $injection->addMethodProphecy( (new MethodProphecy($injection, '__invoke', [Argument::type(ContainerInterface::class)])) - ->willReturn(new Service2()) + ->willReturn(new Service2()) ); $optionsInjection = $this->prophesize(InjectionInterface::class); @@ -195,10 +189,7 @@ public function itDoesNotCacheOptions(): void self::assertCount(2, $injections); } - /** - * @test - */ - public function itUsesResolverWhenCacheItemIsNotAnArray(): void + public function testItUsesResolverWhenCacheItemIsNotAnArray(): void { $cacheKey = $this->buildCacheKey(Service1::class); $resolverService = $this->prophesize(ResolverService::class); @@ -206,7 +197,7 @@ public function itUsesResolverWhenCacheItemIsNotAnArray(): void $injection = $this->prophesize(InjectionInterface::class); $injection->addMethodProphecy( (new MethodProphecy($injection, '__invoke', [Argument::type(ContainerInterface::class)])) - ->willReturn(new Service2()) + ->willReturn(new Service2()) ); $resolverService->resolve(Service1::class, null) @@ -232,10 +223,7 @@ public function itUsesResolverWhenCacheItemIsNotAnArray(): void self::assertCount(1, $injections); } - /** - * @test - */ - public function itReturnsFalseWhenNoInjectionsAvailable(): void + public function testItReturnsFalseWhenNoInjectionsAvailable(): void { $cacheKey = $this->buildCacheKey(Service2::class); $resolverService = $this->prophesize(ResolverService::class); diff --git a/test/Unit/Service/Cache/MemoryTest.php b/test/Unit/Service/Cache/MemoryTest.php index dc567df..b2678ef 100644 --- a/test/Unit/Service/Cache/MemoryTest.php +++ b/test/Unit/Service/Cache/MemoryTest.php @@ -10,10 +10,7 @@ class MemoryTest extends TestCase { - /** - * @test - */ - public function itStoresCachedContents(): void + public function testItStoresCachedContents(): void { $cache = new Memory(); @@ -34,10 +31,7 @@ public function itStoresCachedContents(): void ); } - /** - * @test - */ - public function itHandlesNotStoredContents(): void + public function testItHandlesNotStoredContents(): void { $cache = new Memory(); @@ -52,10 +46,7 @@ public function itHandlesNotStoredContents(): void ); } - /** - * @test - */ - public function itDeletesStoredContents(): void + public function testItDeletesStoredContents(): void { $cache = new Memory(); @@ -77,10 +68,7 @@ public function itDeletesStoredContents(): void ); } - /** - * @test - */ - public function itClearsStoredContents(): void + public function testItClearsStoredContents(): void { $cache = new Memory(); @@ -109,13 +97,9 @@ public function itClearsStoredContents(): void } /** - * @test * @dataProvider badMethodDataProvider - * - * @param string $methodName - * @param array $methodParams */ - public function itThrowsExceptionForNotImplementedMethods(string $methodName, array $methodParams): void + public function testItThrowsExceptionForNotImplementedMethods(string $methodName, array $methodParams): void { $this->expectException(BadMethodCallException::class); diff --git a/test/Unit/Service/CacheServiceTest.php b/test/Unit/Service/CacheServiceTest.php index ed4203a..8d177cc 100644 --- a/test/Unit/Service/CacheServiceTest.php +++ b/test/Unit/Service/CacheServiceTest.php @@ -1,5 +1,7 @@ expectException(ConfigPathNotFoundException::class); diff --git a/test/Unit/Service/Extractor/AnnotationExtractorTest.php b/test/Unit/Service/Extractor/AnnotationExtractorTest.php index fd22e74..20fcde4 100644 --- a/test/Unit/Service/Extractor/AnnotationExtractorTest.php +++ b/test/Unit/Service/Extractor/AnnotationExtractorTest.php @@ -1,5 +1,7 @@ prophesize(AnnotationInterface::class); @@ -33,7 +32,7 @@ public function itResolvesPropertyAnnotations(): void Argument::type(ReflectionProperty::class), Argument::exact(AnnotationInterface::class) )->willReturn($annotation->reveal()) - ->shouldBeCalledTimes(3); + ->shouldBeCalledTimes(3); $extractor = new AnnotationExtractor($reader->reveal()); @@ -43,10 +42,7 @@ public function itResolvesPropertyAnnotations(): void self::assertContainsOnlyInstancesOf(AnnotationInterface::class, $injections); } - /** - * @test - */ - public function itResolvesConstructorAnnotations(): void + public function testItResolvesConstructorAnnotations(): void { $annotation = $this->prophesize(AnnotationInterface::class); @@ -64,10 +60,7 @@ public function itResolvesConstructorAnnotations(): void self::assertContainsOnlyInstancesOf(AnnotationInterface::class, $injections); } - /** - * @test - */ - public function itReturnsEmptyArrayIfNoConstructorIsDefined(): void + public function testItReturnsEmptyArrayIfNoConstructorIsDefined(): void { $reader = $this->prophesize(AnnotationReader::class); @@ -78,10 +71,7 @@ public function itReturnsEmptyArrayIfNoConstructorIsDefined(): void self::assertCount(0, $injections); } - /** - * @test - */ - public function itReturnsEmptyArrayIfNoConstructorAnnotationIsDefined(): void + public function testItReturnsEmptyArrayIfNoConstructorAnnotationIsDefined(): void { $reader = $this->prophesize(AnnotationReader::class); $reader->getMethodAnnotations( diff --git a/test/Unit/Service/Extractor/AttributeExtractorTest.php b/test/Unit/Service/Extractor/AttributeExtractorTest.php index 8709224..dc4469d 100644 --- a/test/Unit/Service/Extractor/AttributeExtractorTest.php +++ b/test/Unit/Service/Extractor/AttributeExtractorTest.php @@ -17,14 +17,11 @@ class AttributeExtractorTest extends TestCase { use ProphecyTrait; - /** - * @test - */ - public function itResolvesPropertyAnnotations(): void + public function testItResolvesPropertyAnnotations(): void { $isPhp8OrAbove = version_compare(PHP_VERSION, '8.0.0') >= 0; - if (!$isPhp8OrAbove) { + if (! $isPhp8OrAbove) { $this->markTestSkipped('Not a php version of 8.0 or above'); } @@ -36,14 +33,11 @@ public function itResolvesPropertyAnnotations(): void self::assertContainsOnlyInstancesOf(InjectionInterface::class, $injections); } - /** - * @test - */ - public function itResolvesConstructorAnnotations(): void + public function testItResolvesConstructorAnnotations(): void { $isPhp8OrAbove = version_compare(PHP_VERSION, '8.0.0') >= 0; - if (!$isPhp8OrAbove) { + if (! $isPhp8OrAbove) { $this->markTestSkipped('Not a php version of 8.0 or above'); } @@ -55,10 +49,7 @@ public function itResolvesConstructorAnnotations(): void self::assertContainsOnlyInstancesOf(InjectionInterface::class, $injections); } - /** - * @test - */ - public function itReturnsEmptyArrayIfNoConstructorIsDefined(): void + public function testItReturnsEmptyArrayIfNoConstructorIsDefined(): void { $extractor = new AttributeExtractor(); @@ -67,14 +58,11 @@ public function itReturnsEmptyArrayIfNoConstructorIsDefined(): void self::assertCount(0, $injections); } - /** - * @test - */ - public function itReturnsEmptyArrayIfNoConstructorAttributeIsDefined(): void + public function testItReturnsEmptyArrayIfNoConstructorAttributeIsDefined(): void { $isPhp8OrAbove = version_compare(PHP_VERSION, '8.0.0') >= 0; - if (!$isPhp8OrAbove) { + if (! $isPhp8OrAbove) { $this->markTestSkipped('Not a php version of 8.0 or above'); } diff --git a/test/Unit/Service/Extractor/ExtractorChainTest.php b/test/Unit/Service/Extractor/ExtractorChainTest.php index 4989a19..1e68f68 100644 --- a/test/Unit/Service/Extractor/ExtractorChainTest.php +++ b/test/Unit/Service/Extractor/ExtractorChainTest.php @@ -15,10 +15,7 @@ class ExtractorChainTest extends TestCase { use ProphecyTrait; - /** - * @test - */ - public function itCallExtractorsForPropertyAnnotations(): void + public function testItCallExtractorsForPropertyAnnotations(): void { $extractor1 = $this->prophesize(ExtractorInterface::class); $extractor2 = $this->prophesize(ExtractorInterface::class); @@ -38,14 +35,12 @@ public function itCallExtractorsForPropertyAnnotations(): void ); self::assertCount( - 0, $extractor->getPropertiesInjections(Service1::class) + 0, + $extractor->getPropertiesInjections(Service1::class) ); } - /** - * @test - */ - public function itOnlyCallsOneExtractorIfInjectionsFoundInProperties(): void + public function testItOnlyCallsOneExtractorIfInjectionsFoundInProperties(): void { $extractor1 = $this->prophesize(ExtractorInterface::class); $extractor2 = $this->prophesize(ExtractorInterface::class); @@ -53,7 +48,7 @@ public function itOnlyCallsOneExtractorIfInjectionsFoundInProperties(): void $injection = $this->prophesize(InjectionInterface::class); $extractor1->getPropertiesInjections(Service1::class) - ->willReturn([ $injection->reveal() ]) + ->willReturn([$injection->reveal()]) ->shouldBeCalled(); $extractor2->getPropertiesInjections(Service1::class) ->willReturn([]) @@ -67,14 +62,12 @@ public function itOnlyCallsOneExtractorIfInjectionsFoundInProperties(): void ); self::assertCount( - 1, $extractor->getPropertiesInjections(Service1::class) + 1, + $extractor->getPropertiesInjections(Service1::class) ); } - /** - * @test - */ - public function itCallExtractorsForConstructorInjections(): void + public function testItCallExtractorsForConstructorInjections(): void { $extractor1 = $this->prophesize(ExtractorInterface::class); $extractor2 = $this->prophesize(ExtractorInterface::class); @@ -94,15 +87,12 @@ public function itCallExtractorsForConstructorInjections(): void ); self::assertCount( - 0, $extractor->getConstructorInjections(Service1::class) + 0, + $extractor->getConstructorInjections(Service1::class) ); } - - /** - * @test - */ - public function itOnlyCallsOneExtractorIfInjectionsFoundInConstructor(): void + public function testItOnlyCallsOneExtractorIfInjectionsFoundInConstructor(): void { $extractor1 = $this->prophesize(ExtractorInterface::class); $extractor2 = $this->prophesize(ExtractorInterface::class); @@ -110,7 +100,7 @@ public function itOnlyCallsOneExtractorIfInjectionsFoundInConstructor(): void $injection = $this->prophesize(InjectionInterface::class); $extractor1->getConstructorInjections(Service1::class) - ->willReturn([ $injection->reveal() ]) + ->willReturn([$injection->reveal()]) ->shouldBeCalled(); $extractor2->getConstructorInjections(Service1::class) ->willReturn([]) @@ -124,7 +114,8 @@ public function itOnlyCallsOneExtractorIfInjectionsFoundInConstructor(): void ); self::assertCount( - 1, $extractor->getConstructorInjections(Service1::class) + 1, + $extractor->getConstructorInjections(Service1::class) ); } } diff --git a/test/Unit/Service/Extractor/Factory/AnnotationExtractorFactoryTest.php b/test/Unit/Service/Extractor/Factory/AnnotationExtractorFactoryTest.php index efbcbfd..e733f95 100644 --- a/test/Unit/Service/Extractor/Factory/AnnotationExtractorFactoryTest.php +++ b/test/Unit/Service/Extractor/Factory/AnnotationExtractorFactoryTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); diff --git a/test/Unit/Service/Extractor/Factory/ExtractorFactoryTest.php b/test/Unit/Service/Extractor/Factory/ExtractorFactoryTest.php index bf6f72d..a82d53b 100644 --- a/test/Unit/Service/Extractor/Factory/ExtractorFactoryTest.php +++ b/test/Unit/Service/Extractor/Factory/ExtractorFactoryTest.php @@ -1,5 +1,7 @@ = 0; - $moduleConfig = new Config(['extractor' => YamlExtractor::class]); + $moduleConfig = new Config([ + 'extractor' => YamlExtractor::class, + ]); $yamlExtractor = $this->prophesize(YamlExtractor::class); $annotationExtractor = $this->prophesize(AnnotationExtractor::class); @@ -72,10 +73,7 @@ public function itReturnsExtractorDefinedInConfig(): void self::assertContainsOnlyInstancesOf(ExtractorInterface::class, $chain); } - /** - * @test - */ - public function itReturnsAnnotationExtractorIfNoneDefined(): void + public function testItReturnsAnnotationExtractorIfNoneDefined(): void { $isPhp8OrAbove = version_compare(PHP_VERSION, '8.0.0') >= 0; diff --git a/test/Unit/Service/Extractor/Factory/YamlExtractorFactoryTest.php b/test/Unit/Service/Extractor/Factory/YamlExtractorFactoryTest.php index f3bda3f..a21c6c8 100644 --- a/test/Unit/Service/Extractor/Factory/YamlExtractorFactoryTest.php +++ b/test/Unit/Service/Extractor/Factory/YamlExtractorFactoryTest.php @@ -1,5 +1,7 @@ [ 'file' => '' ]]); + $moduleConfig = new Config([ + 'extractor_options' => [ + 'file' => '', + ], + ]); $container = $this->prophesize(ContainerInterface::class); $container->get(ModuleConfig::class) diff --git a/test/Unit/Service/Extractor/YamlExtractorTest.php b/test/Unit/Service/Extractor/YamlExtractorTest.php index 1b0f60d..2b34a4f 100644 --- a/test/Unit/Service/Extractor/YamlExtractorTest.php +++ b/test/Unit/Service/Extractor/YamlExtractorTest.php @@ -1,5 +1,7 @@ expectException(InvalidArgumentException::class); @@ -117,10 +101,7 @@ public function itThrowsExceptionIfConfigurationKeyTypeMisses(): void $extractor->getConstructorInjections(Service1::class); } - /** - * @test - */ - public function itThrowsExceptionIfTypeIsUnknown(): void + public function testItThrowsExceptionIfTypeIsUnknown(): void { $this->expectException(InjectionTypeUnknownException::class); @@ -133,10 +114,7 @@ public function itThrowsExceptionIfTypeIsUnknown(): void $extractor->getConstructorInjections(Service2::class); } - /** - * @test - */ - public function itThrowsExceptionIfTypeIsNotOfTypeInjectionInterface(): void + public function testItThrowsExceptionIfTypeIsNotOfTypeInjectionInterface(): void { $this->expectException(InjectionTypeUnknownException::class); diff --git a/test/Unit/Service/Factory/CacheServiceFactoryTest.php b/test/Unit/Service/Factory/CacheServiceFactoryTest.php index 832a243..2806f69 100644 --- a/test/Unit/Service/Factory/CacheServiceFactoryTest.php +++ b/test/Unit/Service/Factory/CacheServiceFactoryTest.php @@ -1,5 +1,7 @@ prophesize(ContainerInterface::class); @@ -38,15 +37,14 @@ public function itInstancesCacheServiceWithoutConfig(): void ); } - /** - * @test - */ - public function itInstancesCacheServiceWithConfigString(): void + public function testItInstancesCacheServiceWithConfigString(): void { $container = $this->prophesize(ContainerInterface::class); $container->get(ModuleConfig::class) - ->willReturn(['cache' => Memory::class]); + ->willReturn([ + 'cache' => Memory::class, + ]); $container->get(Memory::class) ->willReturn(new Memory()) ->shouldBeCalled(); @@ -62,18 +60,17 @@ public function itInstancesCacheServiceWithConfigString(): void ); } - /** - * @test - */ - public function itInstancesCacheServiceWithConfigCallable(): void + public function testItInstancesCacheServiceWithConfigCallable(): void { $container = $this->prophesize(ContainerInterface::class); $container->get(ModuleConfig::class) - ->willReturn(['cache' => static function (ContainerInterface $containerArgument) use ($container){ - self::assertSame($container->reveal(), $containerArgument); - return new Memory(); - }]); + ->willReturn([ + 'cache' => static function (ContainerInterface $containerArgument) use ($container) { + self::assertSame($container->reveal(), $containerArgument); + return new Memory(); + }, + ]); $factory = new CacheServiceFactory(); diff --git a/test/Unit/Service/InjectionServiceTest.php b/test/Unit/Service/InjectionServiceTest.php index 5dc80e9..348c6d3 100644 --- a/test/Unit/Service/InjectionServiceTest.php +++ b/test/Unit/Service/InjectionServiceTest.php @@ -1,5 +1,7 @@ buildCacheKey(Service1::class); $extractor = $this->prophesize(ExtractorInterface::class); @@ -43,7 +42,7 @@ public function itResolvesConstructorArguments(): void $extractor->getConstructorInjections(Service1::class) ->willReturn([ $injection->reveal(), - ]); + ]); $cache = $this->prophesize(CacheService::class); $cache->has($cacheKey)->willReturn(false); @@ -64,10 +63,7 @@ public function itResolvesConstructorArguments(): void self::assertCount(1, $injections); } - /** - * @test - */ - public function itResolvesPropertyInjections(): void + public function testItResolvesPropertyInjections(): void { $cacheKey = $this->buildCacheKey(Service1::class); $extractor = $this->prophesize(ExtractorInterface::class); @@ -82,8 +78,8 @@ public function itResolvesPropertyInjections(): void ->willReturn([]); $extractor->getPropertiesInjections(Service1::class) ->willReturn([ - $injection->reveal(), - ]); + $injection->reveal(), + ]); $cache = $this->prophesize(CacheService::class); $cache->has($cacheKey)->willReturn(false); @@ -104,10 +100,7 @@ public function itResolvesPropertyInjections(): void self::assertCount(1, $injections); } - /** - * @test - */ - public function itUsesCacheItemWhenFound(): void + public function testItUsesCacheItemWhenFound(): void { $cacheKey = $this->buildCacheKey(Service1::class); $extrator = $this->prophesize(ExtractorInterface::class); @@ -115,13 +108,13 @@ public function itUsesCacheItemWhenFound(): void $injection = $this->prophesize(InjectionInterface::class); $injection->addMethodProphecy( (new MethodProphecy($injection, '__invoke', [Argument::type(ContainerInterface::class)])) - ->willReturn(new Service2()) + ->willReturn(new Service2()) ); $cache = $this->prophesize(CacheService::class); $cache->has($cacheKey)->willReturn(true); $cache->get($cacheKey)->willReturn([ - $injection->reveal() + $injection->reveal(), ]); $service = new InjectionService( @@ -139,10 +132,7 @@ public function itUsesCacheItemWhenFound(): void self::assertCount(1, $injections); } - /** - * @test - */ - public function itUsesExtractorWhenCacheItemIsNotAnArray(): void + public function testItUsesExtractorWhenCacheItemIsNotAnArray(): void { $cacheKey = $this->buildCacheKey(Service1::class); $extractor = $this->prophesize(ExtractorInterface::class); @@ -150,15 +140,15 @@ public function itUsesExtractorWhenCacheItemIsNotAnArray(): void $injection = $this->prophesize(InjectionInterface::class); $injection->addMethodProphecy( (new MethodProphecy($injection, '__invoke', [Argument::type(ContainerInterface::class)])) - ->willReturn(new Service2()) + ->willReturn(new Service2()) ); $extractor->getConstructorInjections(Service1::class) ->willReturn([]); $extractor->getPropertiesInjections(Service1::class) ->willReturn([ - $injection->reveal(), - ]); + $injection->reveal(), + ]); $cache = $this->prophesize(CacheService::class); $cache->has($cacheKey)->willReturn(true)->shouldBeCalled(); @@ -180,10 +170,7 @@ public function itUsesExtractorWhenCacheItemIsNotAnArray(): void self::assertCount(1, $injections); } - /** - * @test - */ - public function itReturnsFalseWhenNoInjectionsAvaible(): void + public function testItReturnsFalseWhenNoInjectionsAvaible(): void { $cacheKey = $this->buildCacheKey(Service2::class); $extractor = $this->prophesize(ExtractorInterface::class); diff --git a/test/resources/application_config.php b/test/resources/application_config.php index 5db44d5..fa01d53 100644 --- a/test/resources/application_config.php +++ b/test/resources/application_config.php @@ -1,5 +1,7 @@ $modules, + 'modules' => $modules, 'module_listener_options' => [ 'config_glob_paths' => [ __DIR__ . '/config.php', diff --git a/test/resources/config.php b/test/resources/config.php index 581ec71..4740b77 100644 --- a/test/resources/config.php +++ b/test/resources/config.php @@ -1,26 +1,28 @@ [ 'factories' => [ - \Reinfi\DependencyInjection\Test\Service\Service1::class => \Reinfi\DependencyInjection\Factory\AutoWiringFactory::class, - \Reinfi\DependencyInjection\Test\Service\Service2::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, - \Reinfi\DependencyInjection\Test\Service\Service3::class => \Reinfi\DependencyInjection\Test\Service\Factory\Service3Factory::class, - \Reinfi\DependencyInjection\Test\Service\ServiceAnnotation::class => \Reinfi\DependencyInjection\Factory\InjectionFactory::class, - \Reinfi\DependencyInjection\Test\Service\ServiceAnnotationConstructor::class => \Reinfi\DependencyInjection\Factory\InjectionFactory::class, - \Reinfi\DependencyInjection\Test\Service\ServiceContainer::class => \Reinfi\DependencyInjection\Factory\AutoWiringFactory::class, - \Reinfi\DependencyInjection\Test\Service\ServiceBuildInTypeWithDefault::class => \Reinfi\DependencyInjection\Factory\AutoWiringFactory::class, + \Reinfi\DependencyInjection\Test\Service\Service1::class => \Reinfi\DependencyInjection\Factory\AutoWiringFactory::class, + \Reinfi\DependencyInjection\Test\Service\Service2::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, + \Reinfi\DependencyInjection\Test\Service\Service3::class => \Reinfi\DependencyInjection\Test\Service\Factory\Service3Factory::class, + \Reinfi\DependencyInjection\Test\Service\ServiceAnnotation::class => \Reinfi\DependencyInjection\Factory\InjectionFactory::class, + \Reinfi\DependencyInjection\Test\Service\ServiceAnnotationConstructor::class => \Reinfi\DependencyInjection\Factory\InjectionFactory::class, + \Reinfi\DependencyInjection\Test\Service\ServiceContainer::class => \Reinfi\DependencyInjection\Factory\AutoWiringFactory::class, + \Reinfi\DependencyInjection\Test\Service\ServiceBuildInTypeWithDefault::class => \Reinfi\DependencyInjection\Factory\AutoWiringFactory::class, \Reinfi\DependencyInjection\Test\Service\ServiceBuildInTypeWithDefaultUsingConstant::class => \Reinfi\DependencyInjection\Factory\AutoWiringFactory::class, - 'service_with_closure_as_factory' => function ( + 'service_with_closure_as_factory' => function ( ServiceLocatorInterface $locator ) { return new \stdClass(); }, ], ], - 'test' => [ + 'test' => [ 'value' => 1, ], ];