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

Traverse also interfaces #325

Open
ghost opened this issue Dec 16, 2022 · 4 comments
Open

Traverse also interfaces #325

ghost opened this issue Dec 16, 2022 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 16, 2022

Feature Request

Q A
New Feature yes
RFC yes/no
BC Break yes/no

Summary

Currently interfaces are not traversed therefore we can't create rules for them.

@AlessandroMinoccheri
Copy link
Member

Hi @javaDeveloperKid can you please provide an example? Thanks!

@ghost
Copy link
Author

ghost commented Dec 19, 2022

In my case, I wanted to forbid Interface suffix.

@AlessandroMinoccheri
Copy link
Member

If I understood well your issue @javaDeveloperKid to avoid the suffix Interface you can use this rule:

$rules = Rule::allClasses()
    ->that(new ResideInOneOfTheseNamespaces('App'))
    ->should(new NotHaveNameMatching('*Interface'))
    ->because('*Interface is not a valid suffix name');

What do you think?

@Et3rnel
Copy link

Et3rnel commented Jul 19, 2023

I think you can achieve that with this rule:

$rules[] = Rule::allClasses()
    ->that(new ResideInOneOfTheseNamespaces('App'))
    ->andThat(new IsInterface())
    ->should(new NotHaveNameMatching('*Interface'))
    ->because('interface names should not end with Interface');

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