PHP_CodeSniffer
PHP_CodeSniffer copied to clipboard
[Question] Possible to ignore only one speciifc PSR12 rule?
Running phpcbf for PSR12 I get:
<?php
declare(strict_types=1);
namespace App\Services;
use App\Entity\User;
use App\Entity\Car;
use function Service\api;
Which is correct by PSR12 Standard, unfortunately PHP-CS-FIXER do not fully support this yet and when I run both phpcbf and php-cs-fixer, php-cs-fixer is removing the blank line between the imports, and phpcbf is readding causing an issue.
Is it possible to ignore this specific rule (no blank lines between grouped imports)? I checked from php-cs-fixer side but it would mean removing the no_extra_blank_lines fixer which would affect more than just this. Any help would be appreciated.
Related issue on php-cs-fixer: https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/3582
@Gabb1995 At this time that's not possible, though there's been a PR open to allow for this for nearly two years already: https://github.com/squizlabs/PHP_CodeSniffer/pull/2729
Out of curiosity - why are you using both PHPCS as well as CS-Fixer ? PHPCS ships with the phpcbf
tool, which allows you to autofix things (but based on the violations flagged by PHPCS, so there would be no conflicts).
We use php-cs-fixer with the symfony ruleset and some other specific rules.
Great answer here: https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/3459#issuecomment-443420577