arkitect icon indicating copy to clipboard operation
arkitect copied to clipboard

Traverse also interfaces

Open javaDeveloperKid opened this issue 1 year ago • 4 comments

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.

javaDeveloperKid avatar Dec 16 '22 11:12 javaDeveloperKid

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

AlessandroMinoccheri avatar Dec 17 '22 08:12 AlessandroMinoccheri

In my case, I wanted to forbid Interface suffix.

javaDeveloperKid avatar Dec 19 '22 17:12 javaDeveloperKid

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?

AlessandroMinoccheri avatar Jan 04 '23 09:01 AlessandroMinoccheri

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');

Et3rnel avatar Jul 19 '23 10:07 Et3rnel