Skip to content
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

Fix the strict option on applyOnClassMethods. #1044

Conversation

tvbeek
Copy link
Member

@tvbeek tvbeek commented Oct 29, 2023

Type: bugfix
Issue: Resolves #1020
Breaking change: no

The CountInLoopExpression use the applyOnClassMethods, that method didn't check the strict option on the ruleset.

The ruleset set the strict on the rule if the function is available. This will prevent a BC break.

@tvbeek tvbeek self-assigned this Oct 29, 2023
@codecov
Copy link

codecov bot commented Oct 29, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2a667f9) 92.52% compared to head (c93e65d) 92.53%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1044      +/-   ##
============================================
+ Coverage     92.52%   92.53%   +0.01%     
- Complexity     1236     1239       +3     
============================================
  Files           111      111              
  Lines          3399     3404       +5     
============================================
+ Hits           3145     3150       +5     
  Misses          254      254              
Files Coverage Δ
src/main/php/PHPMD/AbstractRule.php 84.21% <100.00%> (+0.64%) ⬆️
src/main/php/PHPMD/RuleSet.php 87.03% <100.00%> (+0.49%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@kylekatarnls kylekatarnls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember if the PHP level allows it but maybe it could be instanceof StrictRule instead of method_exists

@tvbeek
Copy link
Member Author

tvbeek commented Oct 30, 2023

I don't remember if the PHP level allows it but maybe it could be instanceof StrictRule instead of method_exists

I have thought about it but then with an interface, that is something we don't use a lot. And to have it functional for every rule I thought this is the best option.

But if preferred I can do an instance of AbstractRule check.

@AJenbo
Copy link
Member

AJenbo commented Oct 30, 2023

I would prefer it but can live with both

@kylekatarnls kylekatarnls merged commit 59fa602 into phpmd:master Oct 30, 2023
31 checks passed
@tvbeek tvbeek deleted the fix_1020-strict-with-CountInLoopExpression-rule branch October 31, 2023 08:19
@ravage84 ravage84 added this to the 2.16.0 milestone May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

--strict option is ignored by CountInLoopExpression rule
4 participants