CS Fixers

PHP-CS-Fixer and PHP_CodeSniffer

PHP-CS-Fixer 13,556 (github.com/PHP-CS-Fixer/PHP-CS-Fixer (https://github.com/PHP-CS-Fixer/PHP-CS-Fixer 13,556 ), 3.95.27, friendsofphp/php-cs-fixer) rewrites files to match rule sets; Laravel Pint 3,168 (Laravel) is built on it. PHP_CodeSniffer 1,557 (github.com/PHPCSStandards/PHP_CodeSniffer (https://github.com/PHPCSStandards/PHP_CodeSniffer 1,557 ), 4.0.4, squizlabs/php_codesniffer) reports with phpcs and repairs with phpcbf. Both meet style/DiscountRule.php, written in no style at all:

Show what PER-CS 3.0 would change, without changing anythingPHP
vendor/bin/php-cs-fixer fix --dry-run --diff --rules=@PER-CS3.0 style/DiscountRule.php
Output
...
-  const RATE=0.1;
-  public function Apply( Product $p ) : int {
-    if($p->stock>10){ return (int)round($p->priceCents*(1-self::RATE)); }
-    else return $p->priceCents;
-  }
+    public const RATE = 0.1;
+    public function Apply(Product $p): int
+    {
+        if ($p->stock > 10) {
+            return (int) round($p->priceCents * (1 - self::RATE));
...

The fixer kept discount_rule and Apply, since renaming breaks callers. phpcs --standard=PSR12 reports 28 errors and says PHPCBF CAN FIX THE 26 MARKED SNIFF VIOLATIONS AUTOMATICALLY; the two it cannot fix are Class name "discount_rule" is not in PascalCase format and the method name.

Commit a .php-cs-fixer.dist.php, run the fixer in a pre-commit hook, and fail CI on --dry-run.