Skip to content

Commit

Permalink
add phpstan, fix docblocks, also run phpstan in ci (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikbosch authored May 16, 2024
1 parent 9aca93e commit 3d78b7c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 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
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
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 $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 3d78b7c

Please sign in to comment.