Skip to content

Can exclude disallowed classes based on attribute

Latest
Compare
Choose a tag to compare
@spaze spaze released this 10 Apr 23:20
· 4 commits to main since this release
1c5e699

Allow excluding disallowed classes based on attribute (#319, thanks @morrislaptop)

If you disallow multiple classes or namespaces using an fnmatch wildcard, for example like this:

    disallowedClasses:
        -
            class: 'Foo\Bar\*Something'

... then there may be one or more classes that you'd like to exclude from all the *Something classes for some reason. Previously, starting with 2.15.0, you could exclude them by name using the exclude option:

            exclude:
                - 'Foo\Bar\NotThisSomething'

This release brings a new directive called excludeWithAttribute which you can also use to exclude items from the original set, but based on whether they have the specified attribute:

    disallowedClasses:
        -
            class: 'Foo\Bar\*Something'
            excludeWithAttribute:
                - 'MyApp\ThisAttribute'

Then if you have two classes like this:

namespace Foo\Bar;

class ThisSomething
{
}

#[\MyApp\ThisAttribute]
class ThatSomething
{
}

then only ThisSomething class would be disallowed.

excludeWithAttribute is supported for classes and namespaces for now, and supports fnmatch patterns.

Internal changes

  • Make tests green when running with zend.assertions=1 (#321)