Reduce deprecations due to FieldMapping array access
Fixes #2827, at least in large part.
I did a simple regex find&replace of access to $mapping['...'], and then:
- added parentheses everywhere, since
??(null coalescing) has one of the lowest operator precedence in PHP - removed the parentheses (with another regex) when:
- it was already inside a pair of them
- it was an argument (so already separated by parentheses and\or a comma)
- reviewed all the changes manually and:
- reverted the changes in the
ODMclass (since there is no deprecation there) - reverted all the times where it was inside an
issetcall (it wouldn't work) - removed the parentheses manually when it was already followed by a
??(so it's a concatenation)
- reverted the changes in the
I realize this may not cover all the places where this deprecation may be triggered, but I'm sure that all my changes are covering some, so it's a good start.
Ok I renamed my first commit (since it addressed only variables named $mapping) and added a second one for $fieldMapping. I'll proceed to add more stuff.
Ok that's all for me. Let me know if there are more ways to fetch the FieldMapping object that I should inspect.
Check the changes in the YAML mapping drivers, some of those are parsing the YAML files as arrays and not from the metadata objects.
Likewise, anything that's in MongoDB ODM specific code (like document repository classes) doesn't need to change as the deprecations only affect the ORM.
@mbabker I addressed your comments with some reverts; it may be a good idea to squash this PR while merging.
Thanks @mbabker, I've addressed all the comments of your review.
Codecov Report
Attention: Patch coverage is 84.00000% with 8 lines in your changes missing coverage. Please review.
Project coverage is 78.67%. Comparing base (
ee63c20) to head (4a89cd3). Report is 3 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #2889 +/- ##
==========================================
- Coverage 78.82% 78.67% -0.15%
==========================================
Files 167 167
Lines 8637 8752 +115
==========================================
+ Hits 6808 6886 +78
- Misses 1829 1866 +37
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Good job @Jean85!