DoctrineExtensions icon indicating copy to clipboard operation
DoctrineExtensions copied to clipboard

Reduce deprecations due to FieldMapping array access

Open Jean85 opened this issue 1 year ago • 5 comments

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 ODM class (since there is no deprecation there)
    • reverted all the times where it was inside an isset call (it wouldn't work)
    • removed the parentheses manually when it was already followed by a ?? (so it's a concatenation)

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.

Jean85 avatar Oct 18 '24 22:10 Jean85

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.

Jean85 avatar Oct 18 '24 22:10 Jean85

Ok that's all for me. Let me know if there are more ways to fetch the FieldMapping object that I should inspect.

Jean85 avatar Oct 18 '24 22:10 Jean85

Check the changes in the YAML mapping drivers, some of those are parsing the YAML files as arrays and not from the metadata objects.

mbabker avatar Oct 18 '24 22:10 mbabker

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 avatar Oct 18 '24 23:10 mbabker

@mbabker I addressed your comments with some reverts; it may be a good idea to squash this PR while merging.

Jean85 avatar Oct 19 '24 21:10 Jean85

Thanks @mbabker, I've addressed all the comments of your review.

Jean85 avatar Oct 23 '24 07:10 Jean85

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.

Files with missing lines Patch % Lines
.../ReferenceIntegrity/ReferenceIntegrityListener.php 75.00% 3 Missing :warning:
src/Blameable/Mapping/Driver/Xml.php 0.00% 1 Missing :warning:
src/Blameable/Mapping/Driver/Yaml.php 0.00% 1 Missing :warning:
src/IpTraceable/Mapping/Driver/Xml.php 0.00% 1 Missing :warning:
src/IpTraceable/Mapping/Driver/Yaml.php 0.00% 1 Missing :warning:
src/SoftDeleteable/Mapping/Validator.php 50.00% 1 Missing :warning:
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.

codecov[bot] avatar Nov 11 '24 13:11 codecov[bot]

Good job @Jean85!

phansys avatar Jan 14 '25 00:01 phansys