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

Adds appliesTo to verify if a given rule should be applied #454

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

micheleorselli
Copy link
Contributor

This is a tentative fix for #434. It introduces a new method, appliesTo, which is used to decide if a given rules should be applied to the class under examination, eg:

  • final classes, enums, interfaces, trait, cannot be abstract so we exclude them when we check if a given class is abstract or not, because they cannot have that property by definition.

Caveat: with this fix a rule defined in that way

$rule = Rule::allClasses()
            ->that(new ResideInOneOfTheseNamespaces('App\Abstract'))
            ->should(new IsAbstract())
            ->because('we want to prefix abstract classes');

would miss any final class present in the namesapce App\Abstract. Is that what we want?

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.71%. Comparing base (13d5528) to head (b61a388).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #454      +/-   ##
============================================
+ Coverage     93.62%   93.71%   +0.08%     
- Complexity      593      597       +4     
============================================
  Files            69       69              
  Lines          1601     1608       +7     
============================================
+ Hits           1499     1507       +8     
+ Misses          102      101       -1     

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

@fain182
Copy link
Collaborator

fain182 commented Feb 27, 2025

would miss any final class present in the namespace App\Abstract. Is that what we want?

I don't think this would be the expected behaviour from our users....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants