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

False positives for IsAbstract expression #434

Open
davidcv91 opened this issue Jun 5, 2024 · 1 comment
Open

False positives for IsAbstract expression #434

davidcv91 opened this issue Jun 5, 2024 · 1 comment

Comments

@davidcv91
Copy link

Bug Report

Q A
BC Break yes
Library Version 0.3.33
PHP version 8.1.28

Summary

IsAbstract() finds classes that are not abstract

Apparently, the bug was added on this commit

Current behavior

App\MyClass has 1 violations
  should have a name that matches Abstract* because we want to prefix abstract classes

How to reproduce

Add the following rule:

Rule::allClasses()
        ->that(new IsAbstract())
        ->should(new HaveNameMatching('Abstract*'))
        ->because('we want to prefix abstract classes');

And create a class like:

final class MyClass
{
}

Expected behavior

No errors reported

@courtney-miles
Copy link

I have also found this to be unexpected matching and am compensating by specifically excluding everything else:

Rule::allClasses()
        ->that(new IsAbstract())
        ->that(new IsNotInterface())
        ->that(new IsNotTrait())
        ->that(new IsNotFinal())
        ->should(new HaveNameMatching('Abstract*'))
        ->because('we want to prefix abstract classes');

I'm trying to understand what problem #425 will have fixed and can't see it.

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

No branches or pull requests

2 participants