diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03b217c..eef2d27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,4 +52,4 @@ jobs: run: composer install --classmap-authoritative - name: Run tests - run: ./vendor/bin/phpunit \ No newline at end of file + run: composer test \ No newline at end of file diff --git a/composer.json b/composer.json index c24bcf7..f01cffd 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "require-dev": { "producer/producer": "^2.3", "yoast/phpunit-polyfills": "^2.0", - "phpunit/phpunit": "^9.0 || ^10.0" + "phpunit/phpunit": "^9.0 || ^10.0", + "phpstan/phpstan": "^1.11.1" }, "autoload-dev": { "psr-4": { @@ -38,5 +39,11 @@ }, "provide": { "psr/container-implementation": "^1.0" + }, + "scripts": { + "test": [ + "./vendor/bin/phpunit", + "./vendor/bin/phpstan analyse -l 5 src" + ] } } diff --git a/src/Injection/Factory.php b/src/Injection/Factory.php index 5ece7f8..ffe8015 100644 --- a/src/Injection/Factory.php +++ b/src/Injection/Factory.php @@ -73,7 +73,6 @@ public function withContext(Blueprint $contextualBlueprint): self * factory can make its own, using sequential params in a function; then * the factory call can be replaced by a call to this Factory. * - * @param array $params * @return object */ public function __invoke(Resolver $resolver): object diff --git a/src/Injection/InjectionFactory.php b/src/Injection/InjectionFactory.php index 47834c2..6296a7e 100644 --- a/src/Injection/InjectionFactory.php +++ b/src/Injection/InjectionFactory.php @@ -92,7 +92,7 @@ public function newLazyCallable($callable): LazyCallable * * Returns a new LazyGet. * - * @param ContainerInterface $container The service container. + * @param Container $container The service container. * * @param string $service The service to retrieve. * diff --git a/src/Injection/LazyGet.php b/src/Injection/LazyGet.php index 40498da..c3dec8a 100644 --- a/src/Injection/LazyGet.php +++ b/src/Injection/LazyGet.php @@ -44,10 +44,10 @@ class LazyGet implements LazyInterface * * Constructor. * - * @param ContainerInterface $container The service container. - * * @param string $service The service to retrieve. * + * @param ?ContainerInterface $delegatedContainer The service container. + * */ public function __construct(string $service, ?ContainerInterface $delegatedContainer = null) { diff --git a/src/Injection/LazyInclude.php b/src/Injection/LazyInclude.php index 1ef471c..71930bd 100644 --- a/src/Injection/LazyInclude.php +++ b/src/Injection/LazyInclude.php @@ -33,7 +33,7 @@ class LazyInclude implements LazyInterface * * Constructor. * - * @param string|LazyInterface $file The file to include. + * @param string $file The file to include. * */ public function __construct(string $file) diff --git a/src/Injection/LazyRequire.php b/src/Injection/LazyRequire.php index 29a2c98..1532654 100644 --- a/src/Injection/LazyRequire.php +++ b/src/Injection/LazyRequire.php @@ -33,7 +33,7 @@ class LazyRequire implements LazyInterface * * Constructor. * - * @param string|LazyInterface $file The file to require. + * @param string $file The file to require. * */ public function __construct(string $file) diff --git a/src/Injection/LazyValue.php b/src/Injection/LazyValue.php index e4f468a..9a8205b 100644 --- a/src/Injection/LazyValue.php +++ b/src/Injection/LazyValue.php @@ -33,8 +33,6 @@ class LazyValue implements LazyInterface * * Constructor. * - * @param Resolver $resolver The Resolver that holds the values. - * * @param string $key The value key to retrieve. * */ @@ -47,6 +45,8 @@ public function __construct(string $key) * * Returns the lazy value. * + * @param Resolver $resolver The Resolver that holds the values. + * * @return mixed * */ diff --git a/src/Resolver/AutoResolver.php b/src/Resolver/AutoResolver.php index 0038ec7..6750b41 100644 --- a/src/Resolver/AutoResolver.php +++ b/src/Resolver/AutoResolver.php @@ -12,6 +12,7 @@ use Aura\Di\Injection\LazyNew; use ReflectionClass; use ReflectionException; +use ReflectionNamedType; use ReflectionParameter; /** @@ -59,7 +60,7 @@ protected function getUnifiedParam(ReflectionParameter $rparam, string $class, a } try { - $rtype = $rparam->getType() + $rtype = $rparam->getType() instanceof ReflectionNamedType ? new ReflectionClass($rparam->getType()->getName()) : null ; } catch (ReflectionException $re) { diff --git a/src/Resolver/Resolver.php b/src/Resolver/Resolver.php index 903eeff..9f83b05 100644 --- a/src/Resolver/Resolver.php +++ b/src/Resolver/Resolver.php @@ -141,7 +141,7 @@ public function &__get($key): array * @param object|callable $val The service object; or callable. * */ - public function setService(string $service, object $val): void + public function setService(string $service, object|callable $val): void { $this->services[$service] = $val; }