addiks / more-php-cs-fixers
Extension for PHP-CS-Fixer with more fixers
Installs: 2 624
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- friendsofphp/php-cs-fixer: ^3.2.0
- webmozart/assert: ^1.3
Requires (Dev)
- infection/infection: *
- php-cs-fixer/accessible-object: ^1.1
- php-cs-fixer/phpunit-constraint-isidenticalstring: ^1.2
- php-cs-fixer/phpunit-constraint-xmlmatchesxsd: ^1.2.1
- phpspec/prophecy: ^1.15
- phpspec/prophecy-phpunit: ^2.0
- phpstan/phpstan: ^0.12.31
- phpunit/phpunit: ^9.0
- phpunitgoodpractices/polyfill: ^1.5
- phpunitgoodpractices/traits: ^1.9.1
- symfony/phpunit-bridge: ^6.0
- vimeo/psalm: ^4.4
This package is auto-updated.
Last update: 2024-10-29 05:23:14 UTC
README
More PHP-CS-Fixer's
This repository contains a few additional fixers for the PHP-CS-Fixer project:
- Add a blank line before doc-comments
- Add a blank line before else- and elseif-codeblocks
- Add a blank line before catch- and finally-codeblocks
Setup
1. Install package via composer:
composer require addiks/more-php-cs-fixers
2. Register fixers in PHP-CS-Fixer configuration (file .php_cs
).:
<?php +use Addiks\MorePhpCsFixers\Whitespace\BlankLineBeforeCatchBlockFixer; +use Addiks\MorePhpCsFixers\Whitespace\BlankLineBeforeElseBlockFixer; +use Addiks\MorePhpCsFixers\Whitespace\BlankLineBeforeDocCommentFixer; $config = PhpCsFixer\Config::create(); +$config->registerCustomFixers([ + new BlankLineBeforeCatchBlockFixer(), + new BlankLineBeforeElseBlockFixer(), + new BlankLineBeforeDocCommentFixer(), +]); +$config->setRules([ + 'Addiks/blank_line_before_catch_block': true, + 'Addiks/blank_line_before_else_block': true, + 'Addiks/blank_line_before_doccomment': true, +]); return $config;
The fixers
Addiks/blank_line_before_catch_block
<?php try { foo(); + } catch (\Exception $b) { bar(); + } finally { baz(); }
Addiks/blank_line_before_else_block
<?php if ($a) { foo(); + } elseif ($b) { bar(); + } else { baz(); }
Addiks/blank_line_before_doccomment
<?php
/** @var string $foo */
$foo = "Lorem ipsum";
+
/** @var string $bar */
$bar = "dolor sit amet";
Addiks/correct_order_in_var_doccomment
<?php -/** @var $foo string */ +/** @var string $foo */
Addiks/nullable_in_doccomment
<?php -/** @var ?string $foo */ +/** @var string|null $foo */
Addiks/array_in_doccomment
<?php -/** @var string[] $foo */ +/** @var array<string> $foo */