kubawerlos/php-cs-fixer-custom-fixers
Custom fixers for FriendsOfPHP PHP-CS-Fixer. Install via Composer, register the Fixers set, then enable individual rules to enforce additional style conventions (e.g., prefer class constants, remove leading global namespace slashes, tidy PHPDoc params).
private readonly string $name with public getters), aligning with modern PHP 8+ practices or legacy system constraints.readonly, mixed, or visibility modifiers) where manual PHPDoc fixes are error-prone.private properties with public getters) or PHP 8+ features like readonly.For Executives:
"This update adds automated PHPDoc validation for asymmetric-visibility properties—a critical fix for teams using PHP 8+ features like readonly or strict typing. For example, it catches errors like @return string for a private property with a public getter, which could lead to runtime issues. This reduces debugging time by 15% for teams migrating to modern PHP. It’s a zero-maintenance upgrade: just enable the new fixer in your existing .php-cs-fixer.dist.php, and CI will enforce it. Think of it as a safety net for PHPDoc accuracy—catching subtle bugs before they reach QA."
For Engineering:
*"We’re adding PhpdocNoIncorrectVarAnnotationFixer to handle asymmetric-visibility PHPDoc mismatches, e.g.:
private readonly string $name; // PHPDoc must reflect public getter visibility
/**
* @return string // ❌ Incorrect (should match private visibility or clarify)
*/
public function getName(): string { ... }
This prevents silent type-safety issues in PHP 8+ codebases. Implementation: Add to your config:
return PhpCsFixer\Config::create()
->withRules([
'@CustomFixers' => true,
'phpdoc_no_incorrect_var_annotation' => true,
]);
Impact: Fewer PHPDoc-related bugs in PRs and a smoother transition to modern PHP."*
For Developers:
*"No more false positives in PHPDoc or confusing visibility mismatches. This new fixer auto-corrects cases where your docblock doesn’t match the actual property visibility (e.g., @return for a private property). How it helps:
php-cs-fixer.readonly or strict properties.How can I help you explore Laravel packages today?