First stable 1.0 release. The standard has been reorganized around a clear division of roles, with PHP-CS-Fixer promoted to the primary tool.
Tool roles (breaking)
- PHP-CS-Fixer is now the primary tool. It owns all code formatting (based on PER-CS 3.0) and auto-fixes it. Use the shared config:
return Config::create(__DIR__); - PHP_CodeSniffer is now supplementary. Its ruleset was slimmed by ~50 sniffs: all formatting checks duplicated by PHP-CS-Fixer were removed (the whole PSR12 ruleset, array formatting, whitespace/spacing, string quoting, use-statement ordering, and more). It now focuses on what the fixer cannot express: structural and semantic checks, Laravel conventions, naming, complexity.
- PHP_CodeSniffer alone is no longer a complete standard. Run both tools together (
composer cs).
Requirements (breaking)
- PHP ^8.4 (was ^8.3)
- PHP_CodeSniffer ^4.0
Main coding-style changes
- PHP 8.4 modernization:
@PHP8x4Migration+@PHP8x4Migration:riskypresets enabled (risky rules on by default). - PHPUnit:
@PHPUnit10x0Migration:riskypreset; test method names are snake_case (php_unit_method_casing), with the PSR1 CamelCaps sniff excluded fortests/.php_unit_strictis disabled: theassertEqualstoassertSamerewrite is delegated to Rector'sAssertEqualsToSameRector, which only rewrites provably-scalar assertions and so avoids breaking object and array value comparisons. - Line length: was a hard 120 error; now 180 warning / 220 error (soft-wrap era).
- Imports: global functions are imported (
global_namespace_import), classes and constants stay fully qualified; unneeded import aliases removed. - PHPDoc: single-line docblocks for constants, properties and methods where they fit (
phpdoc_line_span);@inheritdocnormalized to@inheritDoc; noise annotations (@author,@package,@since, ...) stripped; types ordered. - Class structure: fixed member order enforced (
ordered_class_elements); one blank line between methods. - Modern PHP:
is_null()→null ===-free comparisons, cast functions → native casts (modernize_types_casting),and/or→&&/||,heredoc→nowdocwhen possible, elvis operator where shorter, native constant/function casing. - Strings: single quotes by default, no concat spacing (
'hello'.$name),mb_*string functions enforced. - Arrow functions are not forced: long closure syntax stays when more readable (
use_arrow_functionsdisabled).
Developer experience
composer csnow chains PHP-CS-Fixer and phpcbf, identical locally and in CI.- Single auto-fix CI workflow replaces the previous two style workflows; it runs Rector, PHP-CS-Fixer and phpcbf, then commits fixes back (copyable example). It now uses
stefanzweifel/git-auto-commit-actionv7. - Custom sniffs are now documented in one place, including the previously undocumented
Functions.MissingOptionalArgument: docs/README.md - Rector added to the toolchain (
composer rector).
Upgrading from 0.x
- Bump PHP to 8.4 and this package to
1.0.0. - Replace your PHP-CS-Fixer config with
Config::create(__DIR__)(see README). - Keep
<rule ref="IxDFCodingStandard"/>inphpcs.xml; remove any formatting sniff overrides that no longer exist. - Run
composer csand review the (large, mostly mechanical) diff.
What's Changed
- Modernize coding standard: PHP 8.4, PER-CS 3, Rector, dedup rules by @alies-dev in #42
- Update stefanzweifel/git-auto-commit-action action to v7 in #44
Full Changelog: 0.8.0...1.0.0