pmjones/php-styler
PHP-Styler is a PHP 8.1+ code formatter that completely rewrites formatting for consistent spacing, indentation, and line wrapping. It preserves program logic and comments, aims for diff-friendly output, and supports customizable styles, rules, and parses via a token-based pipeline.
Strengths:
NormalizeMemberOrder rule introduces configurable class member reordering (e.g., traits, constants, methods), which aligns well with Laravel’s emphasis on structured, maintainable code. This is particularly useful for large Laravel applications where class organization can become chaotic (e.g., app/Models/ with bloated Eloquent models).NormalizeMemberSpacing to a LineRule ensures more accurate spacing adjustments post-assembly, reducing edge cases in Laravel’s complex class structures (e.g., nested traits, abstract classes).__construct, __toString, etc.) via TMagicMethod tokens improves parsing accuracy for Laravel’s core components (e.g., Illuminate\Support\Traits\Macroable, Illuminate\Database\Eloquent\Model).Foo::match(), $obj->static) and named arguments (e.g., case: in function calls) reduce false positives in Laravel’s heavily namespaced codebase (e.g., Illuminate\Contracts\, Laravel\Prompts\).Weaknesses:
cache parameter and --force flag eliminates incremental formatting, forcing full reformats on every run. This increases CI/CD runtime and may disrupt workflows relying on cached outputs (e.g., nightly builds).php-styler.php configs using cached files.NormalizeMemberOrder may disrupt Laravel’s intentional class member ordering (e.g., grouped properties in app/Providers/AppServiceProvider.php for service binding logic).AMemberNormalizer and AMemberClosing interfaces introduce hidden dependencies. Custom rules or Laravel-specific extensions may break if these interfaces change in future releases..blade.php files remains a risk for false reformatting.Laravel Compatibility:
cache from php-styler.php).__call, __get in dynamic proxies) reduces edge cases.Toolchain Synergy:
composer cs-check) will run slower due to full reformats, but functionality remains intact.--workers=auto) and strategic sequencing (e.g., run after other checks).High:
--force flag requires immediate config updates across all Laravel projects using php-styler. Risk of build failures if not addressed.NormalizeMemberOrder + NormalizeMemberSpacing may conflict with Laravel’s legacy class structures (e.g., app/Providers/ with mixed member ordering)..blade.php files.AMemberNormalizer) change.Mitigation:
php-styler.php to remove cache and adjust exclusion lists (e.g., config/, routes/, .blade.php).NormalizeMemberOrder in a non-critical directory (e.g., app/Console/) before full adoption.--workers=auto and run php-styler in parallel with other checks (e.g., PHPStan).php-styler.php config for rollback.--force impact CI/CD pipelines? Are there alternatives (e.g., external caching)?php-styler.php configs?NormalizeMemberOrder be disabled for Laravel’s legacy directories (e.g., app/Providers/) to preserve existing conventions?CONSTANT, METHOD, MAGIC_METHOD) sufficient for Laravel’s use cases, or will custom rules be needed?--workers=auto)?.blade.php files be explicitly excluded, or is a custom parser needed for embedded PHP?php-styler releases (e.g., interface modifications)?php-styler.php.php artisan style:apply) is unaffected but may need wrapper scripts to handle removed flags.php-styler.php to remove cache parameter and any --force references.config/, routes/, .blade.php, and vendor/ to mitigate risks.php-styler check in a staging environment to validate no false positives.NormalizeMemberOrder in a low-risk directory (e.g., app/Console/).app/Models/).preview mode to review changes before full application.app/Http/Controllers/ and app/Models/ with exclusion lists for problematic files.composer cs-check) with --workers=auto.php-styler apply --workers=auto in parallel with other checks.php-styler releases and update configs proactively.__call, __get) reduces edge cases in dynamic proxies..blade.php files must be excluded or parsed customly.NormalizeMemberOrder may conflict with intentional classHow can I help you explore Laravel packages today?