spaze/coding-standard
spaze/coding-standard provides PHP_CodeSniffer rule sets to enforce consistent PHP coding style and quality across projects. Install via Composer as a dev dependency and run PHPCS with the included standards; CI workflows validate XML and rules.
PSR12.Files.FileHeader.SpacingAfterBlock with all the new modular rules, previously, just some were excluded (#31)Support and requires PHP_CodeSniffer 4.0 (#29, #30)
PSR12.Files.FileHeader.SpacingAfterBlock with the new modular rules
Checks for missing constant typehints (#26) docs
installed_paths config in ruleset file (#24)Report useless:
Internal changes:
composer require without the --dev option, prompt users if they would like to add these packages to require-dev instead of require (#13)Requires slevomat/coding-standard 8.1 (#11)
[] required (#8)enum cases must be below use Traits and above constants in a class (#9), slevomat/coding-standard requires it to be specifiedRequire latest code sniffer and Slevomat's coding standard to fully support PHP 8.1
Exclude PSR12.Classes.OpeningBraceSpace.Found (#5) because an opening brace is required before first method and the new rule contradicts the existing one.
Add trailing comma rules requiring a trailing comma in the following situations:
SlevomatCodingStandard.Arrays.TrailingArrayComma
This sniff enforces trailing commas in multi-line arrays and requires short array syntax [].
SlevomatCodingStandard.Functions.RequireTrailingCommaInCall
This sniff enforces trailing commas in multi-line calls.
SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration
This sniff enforces trailing commas in multi-line declarations.
Because types are not specified in docblocks but directly in code, which is even more true with PHP 8 and union types.
Because
class Waldo
{
use Something;
use SomethingElse;
private Foo $foo;
private Bar $bar;
}
looks better when written like
class Waldo
{
use Something;
use SomethingElse;
private Foo $foo;
private Bar $bar;
}
Use int instead of integer and bool instead of boolean
TraitUseDeclaration
Prohibits multiple traits separated by commas in one use statement.
UnusedUses
Looks for unused imports from other namespaces.
UselessAlias
Looks for use alias that is same as unqualified name.
slevomat/coding-standard 7.0.0 renames some DeclareStrictTypes options and changes their meaning: previously newlines were counted, now just lines are counted. Where there was one newline between the opening tag and the declare statement, there's now no line (but still one newline).
Add rule to check order of classes structure, i.e. use first, then constants, properties, abstract methods, constructor, other methods.
uses (thanks @ruudk)Can now be used for PHP 8 projects too (#1, thanks @xificurk)
How can I help you explore Laravel packages today?