diff --git a/README.md b/README.md index 8329732..f0331d6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ DotKernel component used to create services through [Laminas Service Manager](ht This package can clean up your code, by getting rid of all the factories you write, sometimes just to inject a dependency or two. ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-annotated-services) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.1.4) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.1.5) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/network) diff --git a/composer.json b/composer.json index 3b2b671..37d6284 100644 --- a/composer.json +++ b/composer.json @@ -21,14 +21,14 @@ ], "require": { "php": "~8.1.0 || ~8.2.0 || ~8.3.0", - "laminas/laminas-servicemanager": "^3.10", - "doctrine/annotations": "^1.13", - "doctrine/cache": "^1.13", - "doctrine/orm" : "^2.11" + "laminas/laminas-servicemanager": "^3.22.1", + "doctrine/annotations": "^2.0.1", + "doctrine/cache": "^2.2.0", + "doctrine/orm" : "^2.17.3" }, "require-dev": { - "phpunit/phpunit": "^10.2", - "vimeo/psalm": "^5.13", + "phpunit/phpunit": "^10.5.9", + "vimeo/psalm": "^5.20", "laminas/laminas-coding-standard": "^2.5" }, "autoload": { diff --git a/src/Factory/AbstractAnnotatedFactory.php b/src/Factory/AbstractAnnotatedFactory.php index 5700a13..bc4d523 100644 --- a/src/Factory/AbstractAnnotatedFactory.php +++ b/src/Factory/AbstractAnnotatedFactory.php @@ -5,17 +5,16 @@ namespace Dot\AnnotatedServices\Factory; use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\Common\Annotations\AnnotationRegistry; -use Doctrine\Common\Annotations\CachedReader; +use Doctrine\Common\Annotations\PsrCachedReader; use Doctrine\Common\Annotations\Reader; -use Doctrine\Common\Cache\Cache; +use Psr\Cache\CacheItemPoolInterface; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; abstract class AbstractAnnotatedFactory { - public const CACHE_SERVICE = 'Dot\AnnotatedServices\Cache'; + public const CACHE_SERVICE = CacheItemPoolInterface::class; protected ?Reader $annotationReader = null; public function setAnnotationReader(Reader $annotationReader): void { @@ -32,12 +31,10 @@ protected function createAnnotationReader(ContainerInterface $container): Reader return $this->annotationReader; } - AnnotationRegistry::registerLoader('class_exists'); - if (! $container->has(self::CACHE_SERVICE)) { return $this->annotationReader = new AnnotationReader(); } else { - /** @var Cache $cache */ + /** @var CacheItemPoolInterface $cache */ $cache = $container->get(self::CACHE_SERVICE); $debug = false; if ($container->has('config')) { @@ -46,7 +43,7 @@ protected function createAnnotationReader(ContainerInterface $container): Reader $debug = (bool) $config['debug']; } } - return $this->annotationReader = new CachedReader(new AnnotationReader(), $cache, $debug); + return $this->annotationReader = new PsrCachedReader(new AnnotationReader(), $cache, $debug); } } }