-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Phpstan requires that the template can be resolved in all cases, while Psalm seems to tolerate this ambiguous situation. See phpstan/phpstan#5175 (comment)
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Doctrine\StaticAnalysis; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Doctrine\ORM\Mapping\ClassMetadata; | ||
|
||
/** | ||
* EntityManagerInterface::getClassMetadata() is templated only for Psalm, | ||
* because of limitations in PHPStan. | ||
* | ||
* @see https://github.com/phpstan/phpstan/issues/5175#issuecomment-861437050 | ||
*/ | ||
abstract class GetMetadata | ||
{ | ||
/** | ||
* @param string|object $class | ||
* @phpstan-param class-string|object $class | ||
*/ | ||
abstract public function getEntityManager($class): EntityManagerInterface; | ||
|
||
/** | ||
* @psalm-param class-string<TObject> $class | ||
* @phpstan-param class-string $class | ||
* | ||
* @psalm-return ClassMetadata<TObject> | ||
* @phpstan-return ClassMetadata<object> | ||
* | ||
* @psalm-template TObject of object | ||
*/ | ||
public function __invoke(string $class): ClassMetadata | ||
{ | ||
return $this->getEntityManager($class)->getClassMetadata($class); | ||
} | ||
} |