php-collective/code-sniffer
PHP CodeSniffer rulesets from PhpCollective: PSR-2 compliant with many extra sniffs/fixers (incl. PSR-12) plus a stricter PhpCollectiveStrict standard. Install via Composer, configure phpcs.xml, run phpcs/phpcbf to check and auto-fix code style.
conditions checks + cached arrow-function scopes in ConsistentIndentSniff (#63)UseStatementsTrait::getUseStatements and bound the throw class-name lookup to the current statement (#64)parseUseStatements / getNamespace) and dedupe per-doc-block processing (#65)UseStatementSniff::getUseStatements across phpcbf fix iterations (#66)Combined, these cut composer cs-check wall-clock time roughly in half on large method-heavy codebases. On an 11k-line CakePHP controller the slowest single file went from ~40s to ~6s; on a 1095-file project the whole-codebase scan dropped from ~2m08s to ~30s with parallel=16.
Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.6.1...0.6.2
DocBlockTagOrder to class, interface, and trait docblocks with a new configurable classOrder property (#59)DocBlockTagOrder via a new innerOrder property and separate InnerOrderInvalid error code, so inner ordering can be enabled and scoped independently of bucket ordering (#60)Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.6.0...0.6.1
[@param](https://github.com/param) lists, which could cause an infinite fixer loop with DocBlockParamTypeMismatchSniff (#58)PhpCollective.ControlStructures.DisallowAlternativeControlStructures → Universal.ControlStructures.DisallowAlternativeSyntax, PhpCollective.WhiteSpace.CommaSpacing → Universal.WhiteSpace.CommaSpacing (#55)ReferenceUsedNamesOnly (#57)Partial namespace references (e.g. Mockery\MockInterface when only Mockery is imported) are now flagged and must be imported via a full use statement. To keep the previous behavior, override the property in your project's phpcs.xml:
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowPartialUses" value="true"/>
</properties>
</rule>
Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.5.5...0.6.0
mb_strtoupper() (#49)Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.5.4...0.5.5
checkReturnTypeHint property to detect invalid : void return type hints on magic methods (__construct, __destruct, __clone)hasReturnType() to properly detect return type declarations on interface and abstract methods. Previously, methods with return types but no body (e.g., public function foo(): string;) incorrectly triggered ReturnMissingInInterface errors.Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.5.3...0.5.4
PHP 8+ Attribute Support: FQCNs in attributes are now detected and auto-fixed
// Before
#[\Foo\Bar\SomeAttribute]
class MyClass {}
// After
use Foo\Bar\SomeAttribute;
#[SomeAttribute]
class MyClass {}
PHP 8.1+ Enum Support: Enum implements clauses are now handled
// Before
enum Status: string implements \Foo\Bar\SomeInterface {}
// After
use Foo\Bar\SomeInterface;
enum Status: string implements SomeInterface {}
Only fully qualified names (starting with \) are auto-fixed. Partially qualified names (e.g., Foo\Bar without leading \) are intentionally not auto-fixed right now.
Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.5.2...0.5.3
array{...}) - https://github.com/php-collective/code-sniffer/pull/45Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.5.1...0.5.2
[@param](https://github.com/param) annotations - https://github.com/php-collective/code-sniffer/pull/44Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.5.0...0.5.1
[@param](https://github.com/param) annotations by @dereuromark in https://github.com/php-collective/code-sniffer/pull/42The attribute usage is now the same as class usage. This seems to make sense moving forward and to not clash with other sniffer packages - and triggers now the major.
Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.4.6...0.5.0
Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.4.3...0.4.4
Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.4.2...0.4.3
"squizlabs/php_codesniffer": "^4.0.0" now.params better. Only require them once they are needed (missing type on a param or a random param defined already that cannot be removed).none/assoc/all (default assoc).This package now also includes phpcsstandards/phpcsextra dependency for even better sniff experience.
Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.2.21...0.3.0
Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.2.19...0.2.20
Also added
Support for Slevomat V8.16 included.
[@property](https://github.com/property) annotations.PhpCollective.Commenting.DisallowShorthandNullableTypeHint to replace Nullable ? in docblocks with |null verbosely.Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.2.7...0.2.8
Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.2.5...0.2.6
Full Changelog: https://github.com/php-collective/code-sniffer/compare/0.2.4...0.2.5
How can I help you explore Laravel packages today?