diff --git a/phpstan.neon b/phpstan.neon index 9bdd6dc..e067269 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -62,3 +62,7 @@ parameters: # Nette changed return typehint - message: "#^Parameter \\#2 \\$array of function implode expects array\\, array\\\\|string\\> given\\.$#" path: %currentWorkingDirectory%/src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php + + # Support for doctrine/annotations ^1 + - message: "#^Call to function method_exists\\(\\) with 'Doctrine\\\\\\\\Common\\\\\\\\Annotations\\\\\\\\AnnotationRegistry' and 'registerUniqueLoader' will always evaluate to false\\.$#" + path: src/Core/DI/LoaderFactory/DualReaderFactory.php diff --git a/src/Core/DI/LoaderFactory/DualReaderFactory.php b/src/Core/DI/LoaderFactory/DualReaderFactory.php index 5ef8bb0..a3e7e0e 100644 --- a/src/Core/DI/LoaderFactory/DualReaderFactory.php +++ b/src/Core/DI/LoaderFactory/DualReaderFactory.php @@ -3,6 +3,7 @@ namespace Apitte\Core\DI\LoaderFactory; use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\Reader; use Koriym\Attributes\AttributeReader; use Koriym\Attributes\DualReader; @@ -16,6 +17,10 @@ class DualReaderFactory public function create(): Reader { $annotationReader = new AnnotationReader(); + if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { + AnnotationRegistry::registerUniqueLoader('class_exists'); + } + $attributeReader = new AttributeReader(); return new DualReader($annotationReader, $attributeReader);