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

Interfaces extending other interfaces are not matched by shouldExtend() #290

Open
InvisibleSmiley opened this issue Sep 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@InvisibleSmiley
Copy link

Bug Description
AFAICS PHPat does not handle interfaces extending other interfaces correctly.

If a rule requires interfaces to extend a specific interface, even interfaces that fulfill the requirement are reported.

Note that interfaces may extend multiple other interfaces, and listing only one of them after shouldExtend() needs to work in that case.

Additional context

  1. Have a ValueObjectInterface somewhere
  2. Have other interfaces with suffix ValueObjectInterface somewhere that extend ValueObjectInterface
  3. Reference (import/use) the ValueObjectInterface in below test case
class MyArchTest {
    public function testValueObjectInterfacesExtendBaseInterface(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::classname('/ValueObjectInterface$/', regex: true))
            ->excluding(Selector::classname(ValueObjectInterface::class))
            ->shouldExtend()
            ->classes(Selector::classname(ValueObjectInterface::class))
            ->because('Value object interfaces must extend ValueObjectInterface');
    }
}
@InvisibleSmiley InvisibleSmiley added the bug Something isn't working label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant