php-collective/code-sniffer
PHP_CodeSniffer ruleset from PhpCollective. PSR-2 compliant with many extra sniffs/fixers (incl. PSR-12) plus an optional stricter standard (PhpCollectiveStrict). Install via Composer and run phpcs/phpcbf, or wire into CI/IDE.
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?