mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Field mapping definitions are different in ClassMetadataInfo #6876
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 @laryjulien on GitHub (Nov 19, 2021).
Bug Report
Summary
Not sure that it is really a bug but psalm annotations are defined differently for the same element. So phpstan is considering it as an error.
Current behavior
In https://github.com/doctrine/orm/blob/2.10.x/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L451,
fieldMappingsproperty is defined with:But in https://github.com/doctrine/orm/blob/2.10.x/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1303,
getFieldMappingmethod is defined to return:How to reproduce
We are currently working on fixing issues due to upgrading phpstan to 1.x on API Platform, those lines (https://github.com/api-platform/core/blob/main/src/Doctrine/Orm/Metadata/Property/DoctrineOrmPropertyMetadataFactory.php#L80):
generate this error in phpstan:
Expected behavior
From my point of view but I may be wrong, @psalm-return annotation should be the same as in property definition.
I may provide a PR to change this if it is needed.
@greg0ire commented on GitHub (Nov 19, 2021):
This looks related to https://github.com/doctrine/orm/pull/8556 cc @VincentLanglet
I think a PR would be more than welcome. To avoid further desynchronization, it might be handy to use a type: https://psalm.dev/docs/annotating_code/supported_annotations/#psalm-type