diff --git a/lib/Doctrine/Persistence/Mapping/AbstractClassMetadataFactory.php b/lib/Doctrine/Persistence/Mapping/AbstractClassMetadataFactory.php index 4310bbd6..f378503c 100644 --- a/lib/Doctrine/Persistence/Mapping/AbstractClassMetadataFactory.php +++ b/lib/Doctrine/Persistence/Mapping/AbstractClassMetadataFactory.php @@ -313,6 +313,7 @@ public function setMetadataFor($className, $class) * @psalm-param class-string $name * * @return string[] + * @psalm-return class-string[] */ protected function getParentClasses($name) { @@ -428,9 +429,12 @@ abstract protected function doLoadMetadata($class, $parent, $rootEntityFound, ar * Creates a new ClassMetadata instance for the given class name. * * @param string $className + * @psalm-param class-string $className * - * @return ClassMetadata + * @return ClassMetadata * @psalm-return CMTemplate + * + * @template T of object */ abstract protected function newClassMetadataInstance($className); diff --git a/lib/Doctrine/Persistence/Mapping/ClassMetadata.php b/lib/Doctrine/Persistence/Mapping/ClassMetadata.php index e44e9afd..cce22daa 100644 --- a/lib/Doctrine/Persistence/Mapping/ClassMetadata.php +++ b/lib/Doctrine/Persistence/Mapping/ClassMetadata.php @@ -7,7 +7,7 @@ /** * Contract for a Doctrine persistence layer ClassMetadata class to implement. * - * @template T of object + * @template-covariant T of object */ interface ClassMetadata { diff --git a/tests/Doctrine/Tests/Persistence/Mapping/Fixtures/TestClassMetadata.php b/tests/Doctrine/Tests/Persistence/Mapping/Fixtures/TestClassMetadata.php index 719d4d8f..2ef68e17 100644 --- a/tests/Doctrine/Tests/Persistence/Mapping/Fixtures/TestClassMetadata.php +++ b/tests/Doctrine/Tests/Persistence/Mapping/Fixtures/TestClassMetadata.php @@ -10,7 +10,7 @@ /** * @template T of object - * @implements ClassMetadata + * @template-implements ClassMetadata */ final class TestClassMetadata implements ClassMetadata { diff --git a/tests/Doctrine/Tests/Persistence/Mapping/TestClassMetadataFactory.php b/tests/Doctrine/Tests/Persistence/Mapping/TestClassMetadataFactory.php index 9420b4b8..4877e1e3 100644 --- a/tests/Doctrine/Tests/Persistence/Mapping/TestClassMetadataFactory.php +++ b/tests/Doctrine/Tests/Persistence/Mapping/TestClassMetadataFactory.php @@ -9,17 +9,27 @@ use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Persistence\Mapping\ReflectionService; +/** + * @template CMTemplate of ClassMetadata + * @template-extends AbstractClassMetadataFactory + */ class TestClassMetadataFactory extends AbstractClassMetadataFactory { /** @var MappingDriver */ public $driver; - /** @var ClassMetadata */ + /** + * @var ClassMetadata + * @psalm-var CMTemplate + */ public $metadata; /** @var callable|null */ public $fallbackCallback; + /** + * @psalm-param CMTemplate $metadata + */ public function __construct(MappingDriver $driver, ClassMetadata $metadata) { $this->driver = $driver; diff --git a/tests/Doctrine/Tests/Persistence/PersistentObjectTest.php b/tests/Doctrine/Tests/Persistence/PersistentObjectTest.php index 29e01c73..126700c5 100644 --- a/tests/Doctrine/Tests/Persistence/PersistentObjectTest.php +++ b/tests/Doctrine/Tests/Persistence/PersistentObjectTest.php @@ -166,6 +166,9 @@ public function testAddInvalidCollection(): void } } +/** + * @template-implements ClassMetadata + */ class TestObjectMetadata implements ClassMetadata { /**