mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
How to create schema using Schema tool in v2.9.x? #6697
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @simPod on GitHub (Apr 19, 2021).
Originally assigned to: @greg0ire on GitHub.
SchemaTool::createSchema()expectslist<Doctrine\ORM\Mapping\ClassMetadata>.I used to pass in metadata created as
$entityManager->getMetadataFactory()->getAllMetadata()that returnsarray<Doctrine\Persistence\Mapping>so it's incompatible now.I checked this I but seems to have the same issue
bcb4889a2c/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php (L58-L66)@greg0ire commented on GitHub (Apr 19, 2021):
That was me in
71044894a1, right? But the class metadata factory of the entity manager can only returnDoctrine\ORM\Mapping\ClassMetadata, right?I think something similar to
06fadcdd8c/lib/Doctrine/ORM/EntityManagerInterface.php (L37-L38)could be contributed toDoctrine\ORM\Mapping\ClassMetadataFactoryto declare thatgetAllMetadata()in fact returns alist<Doctrine\ORM\Mapping\ClassMetadata>.Can you try adding such a comment in that class to confirm that it does solve the issue?
UPD: the above has been contributed to 2.8.x, but is not yet merged up, so you would have to copy that too.
According to PHP or PHPStan? I'm trying to determine if there is a BC-break here , e.g. is there a reasonable scenario where we would really pass non-instances
Doctrine\ORM\Mapping\ClassMetadata.@beberlei commented on GitHub (Apr 19, 2021):
Wouldn't AbstractClassMetadataFactory need to implement Psalm generics/template to make this possible?
@greg0ire commented on GitHub (Apr 19, 2021):
I think it would be one way to do it, but there is I think another way to do this by using
@method. And that one does not involve changingdoctrine/persistence. A PR is on the way, and I think doing this@methodtrick will greatly reduce the baseline too :)