diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index fb7fc77..b7d3200 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -28,4 +28,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.0', '8.1', '8.2'] + ['8.0', '8.1', '8.2', '8.3'] diff --git a/CHANGELOG.md b/CHANGELOG.md index c429d91..e090bef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 2.1.1 under development -- no changes in this release. +- Enh #65: Minor refactoring of `CallableFactory` and `ListenerCollectionFactory` (@vjik) ## 2.1.0 November 04, 2023 diff --git a/composer.json b/composer.json index db84e2e..54d595b 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "rector/rector": "^0.19.0", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^4.30|^5.6", + "vimeo/psalm": "^4.30|^5.21", "yiisoft/config": "^1.3", "yiisoft/di": "^1.2", "yiisoft/test-support": "^1.3" diff --git a/psalm.xml b/psalm.xml index f4ceced..d091d59 100644 --- a/psalm.xml +++ b/psalm.xml @@ -9,5 +9,11 @@ > + + + + + + diff --git a/src/CallableFactory.php b/src/CallableFactory.php index 870c5e7..f985dd5 100644 --- a/src/CallableFactory.php +++ b/src/CallableFactory.php @@ -33,7 +33,6 @@ public function __construct( */ public function create(mixed $definition): callable { - /** @var mixed */ $callable = $this->prepare($definition); if (is_callable($callable)) { @@ -45,10 +44,8 @@ public function create(mixed $definition): callable /** * @throws ContainerExceptionInterface Error while retrieving the entry from container. - * - * @return mixed */ - private function prepare(mixed $definition) + private function prepare(mixed $definition): mixed { if (is_string($definition) && $this->container->has($definition)) { return $this->container->get($definition); @@ -62,7 +59,6 @@ private function prepare(mixed $definition) [$className, $methodName] = $definition; if (!class_exists($className) && $this->container->has($className)) { - /** @var mixed */ return [ $this->container->get($className), $methodName, diff --git a/src/ListenerCollectionFactory.php b/src/ListenerCollectionFactory.php index 4200700..be57e8a 100644 --- a/src/ListenerCollectionFactory.php +++ b/src/ListenerCollectionFactory.php @@ -39,11 +39,9 @@ public function create(array $eventListeners): ListenerCollection ); } - /** @var mixed */ foreach ($listeners as $callable) { $listener = - /** @return mixed */ - fn (object $event) => $this->injector->invoke( + fn (object $event): mixed => $this->injector->invoke( $this->callableFactory->create($callable), [$event] ); diff --git a/src/ListenerConfigurationChecker.php b/src/ListenerConfigurationChecker.php index 3bbd22c..70c79e9 100644 --- a/src/ListenerConfigurationChecker.php +++ b/src/ListenerConfigurationChecker.php @@ -51,7 +51,6 @@ public function check(array $configuration): void ); } - /** @var mixed */ foreach ($listeners as $listener) { try { if (!$this->isCallable($listener)) {