Pattern: Use of forbidden class
Issue: -
Reports usage of forbidden classes, interfaces, parent classes and traits. And provide the following settings:
forbiddenClasses
: forbids creating instances withnew
keyword or accessing with::
operatorforbiddenExtends
: forbids extending withextends
keywordforbiddenInterfaces
: forbids usage inimplements
sectionforbiddenTraits
: forbids imports withuse
keyword
Optionally can be passed as an alternative for auto fixes. See phpcs.xml
file example:
<rule ref="SlevomatCodingStandard.PHP.ForbiddenClasses">
<properties>
<property name="forbiddenClasses" type="array">
<element key="Validator" value="Illuminate\Support\Facades\Validator"/>
</property>
<property name="forbiddenTraits" type="array">
<element key="\AuthTrait" value="null"/>
</property>
</properties>
</rule>