Skip to content

Commit

Permalink
Merge pull request #173 from franmomu/fix_template
Browse files Browse the repository at this point in the history
Fix annotation template and add more phpdoc
  • Loading branch information
greg0ire authored May 15, 2021
2 parents 653d54d + c73f704 commit 08d3e6e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ public function setMetadataFor($className, $class)
* @psalm-param class-string $name
*
* @return string[]
* @psalm-return class-string[]
*/
protected function getParentClasses($name)
{
Expand Down Expand Up @@ -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<T> $className
*
* @return ClassMetadata
* @return ClassMetadata<T>
* @psalm-return CMTemplate
*
* @template T of object
*/
abstract protected function newClassMetadataInstance($className);

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Persistence/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/**
* @template T of object
* @implements ClassMetadata<T>
* @template-implements ClassMetadata<T>
*/
final class TestClassMetadata implements ClassMetadata
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Persistence\Mapping\ReflectionService;

/**
* @template CMTemplate of ClassMetadata
* @template-extends AbstractClassMetadataFactory<CMTemplate>
*/
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;
Expand Down
3 changes: 3 additions & 0 deletions tests/Doctrine/Tests/Persistence/PersistentObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public function testAddInvalidCollection(): void
}
}

/**
* @template-implements ClassMetadata<TestObject>
*/
class TestObjectMetadata implements ClassMetadata
{
/**
Expand Down

0 comments on commit 08d3e6e

Please sign in to comment.