-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix property access for field mapping type #7223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.x
Are you sure you want to change the base?
Conversation
|
I have converted it to draft. |
| $fieldMapping = $entityDto->getClassMetadata()->getFieldMapping($propertyName); | ||
|
|
||
| return self::$doctrineTypeToFilterClass[$fieldMapping['type']] ?? TextFilter::class; | ||
| if (version_compare(InstalledVersions::getVersion('doctrine/orm'), '3.0', '<')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix we use in other parts of the code:
EasyAdminBundle/src/Orm/EntityRepository.php
Lines 301 to 310 in e373893
| // In Doctrine ORM 3.x, FieldMapping implements \ArrayAccess; in 4.x it's an object with properties | |
| $fieldMapping = $associatedEntityDto->getClassMetadata()->getFieldMapping($propertyName); | |
| // In Doctrine ORM 2.x, getFieldMapping() returns an array | |
| /** @phpstan-ignore-next-line function.impossibleType */ | |
| if (\is_array($fieldMapping)) { | |
| /** @phpstan-ignore-next-line cast.useless */ | |
| $fieldMapping = (object) $fieldMapping; | |
| } | |
| /** @phpstan-ignore-next-line function.alreadyNarrowedType */ | |
| $propertyDataType = property_exists($fieldMapping, 'type') ? $fieldMapping->type : $fieldMapping['type']; |
It's a bit convoluted 😐 but it covers Doctrine ORM 2.x, 3.x and 4.x.
Will address
19x: Using ArrayAccess on Doctrine\ORM\Mapping\FieldMapping is deprecated and will not be possible in Doctrine ORM 4.0. Use the corresponding property instead. (ArrayAccessImplementation.php:31 called by FieldFactory.php:180, https://github.com/doctrine/orm/pull/11211, package doctrine/orm)