Disallows direct call of __invoke()
.
Sniff disallows usage of references.
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>
Enforces configurable number of spaces after reference.
Sniff provides the following settings:
spacesCountAfterReference
: the number of spaces after&
.
Requires assertion via assert
instead of inline documentation comments.
Sniff provides the following settings:
enableIntegerRanges
(defaults tofalse
): enables support forpositive-int
,negative-int
andint<0, 100>
.enableAdvancedStringTypes
(defaults tofalse
): enables support forcallable-string
,numeric-string
andnon-empty-string
.
Requires nowdoc syntax instead of heredoc when possible.
PHP optimizes some internal functions into special opcodes on VM level. Such optimization results in much faster execution compared to calling standard functions. This only works when these functions are not invoked with argument unpacking (...
).
The list of these functions varies across PHP versions, but is the same as functions that must be referenced by their global name (either by \
prefix or using use function
), not a fallback name inside namespaced code.
Enforces using short form of list syntax, [...]
instead of list(...)
.
Enforces using shorthand cast operators, forbids use of unset and binary cast operators: (bool)
instead of (boolean)
, (int)
instead of (integer)
, (float)
instead of (double)
or (real)
. (binary)
and (unset)
are forbidden.
Looks for useless parentheses.
Sniff provides the following settings:
ignoreComplexTernaryConditions
(defaults tofalse
): ignores complex ternary conditions - condition must contain&&
,||
etc. or end of line.
Looks for useless semicolons.