Skip to content

Commit

Permalink
add phpstan, fix docblocks, also run phpstan in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikbosch committed May 16, 2024
1 parent ce391cf commit e1d8906
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ jobs:
run: composer install --classmap-authoritative

- name: Run tests
run: ./vendor/bin/phpunit
run: composer test
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -38,5 +39,11 @@
},
"provide": {
"psr/container-implementation": "^1.0"
},
"scripts": {
"test": [
"./vendor/bin/phpunit",
"./vendor/bin/phpstan analyse -l 5 src"
]
}
}
1 change: 0 additions & 1 deletion src/Injection/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Injection/InjectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Injection/LazyGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Injection/LazyInclude.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Injection/LazyRequire.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/Injection/LazyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
*/
Expand All @@ -47,6 +45,8 @@ public function __construct(string $key)
*
* Returns the lazy value.
*
* @param Resolver $resolver The Resolver that holds the values.
*
* @return mixed
*
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Resolver/AutoResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Aura\Di\Injection\LazyNew;
use ReflectionClass;
use ReflectionException;
use ReflectionNamedType;
use ReflectionParameter;

/**
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Resolver/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e1d8906

Please sign in to comment.