You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At least \Doctrine\ORM\Mapping\ClassMetadataFactory::doLoadMetadata and \Doctrine\ORM\Mapping\ClassMetadataFactory::validateRuntimeMetadata (with the changes of #8402) use \Doctrine\Persistence\Mapping\ClassMetadata (an interface) as DocBlock type-hints for parameters, but access \Doctrine\ORM\Mapping\ClassMetadataInfo::$discriminatorMap through it.
This causes PHPStan and Psalm to complain, since Interfaces cannot have properties.
When code like $parent->discriminatorMap is supposed to be kept as-is (that is, no corresponding method added in the ClassMetadata interface), the type hints need to be changed. This might cascade through a chain of called methods, though.
The text was updated successfully, but these errors were encountered:
I don't think changing the type declarations is an option for doLoadMetadata: it's forbidden to narrow them down since that would break the LSP.
Instead we could throw if anything else than an ORM ClassMetadata is passed.
For validateRuntimeMetadata() it's another story since there is no method override. We can change the type declaration 👍
After doing that, we should regenerate PHPStan and Psalm baselines in case they contain something about this.
This was sparked by #8402:
At least
\Doctrine\ORM\Mapping\ClassMetadataFactory::doLoadMetadata
and\Doctrine\ORM\Mapping\ClassMetadataFactory::validateRuntimeMetadata
(with the changes of #8402) use\Doctrine\Persistence\Mapping\ClassMetadata
(an interface) as DocBlock type-hints for parameters, but access\Doctrine\ORM\Mapping\ClassMetadataInfo::$discriminatorMap
through it.This causes PHPStan and Psalm to complain, since
Interfaces cannot have properties
.When code like
$parent->discriminatorMap
is supposed to be kept as-is (that is, no corresponding method added in theClassMetadata
interface), the type hints need to be changed. This might cascade through a chain of called methods, though.The text was updated successfully, but these errors were encountered: