Describe the bug
After upgrading to PHP_CodeSniffer 3.13.0, phpcbf fails to fix files containing a large number of fully qualified namespace violations. The command outputs "*** Reached maximum number of loops with 0 violations left unfixed ***" and reverts all fixes.
I have a PHP file with many fully qualified class names (e.g., \Full\Namespace\Class::class)
Run phpcbf on the file with rules that convert FQCN to short names with use statements
Observe the failure with PHPCS 3.13.0+
The same file fixes correctly with PHPCS 3.12.2
PHPCS 3.13.0+: Fails with loop limit error, no fixes applied
PHPCS 3.12.2: Works correctly, all fixes applied.
Code sample
# many cases when I use the full namespace to create the class, like
$one = new \One\Class();
$two = new \Two\Class();
....
$array = [new \Array\Class(), [new \Array1\Class(), new \Array1\Class()]]
# class has ~100 issues like this, might be some cs issues like withspace, missed docblock, etc.
Custom ruleset
I have a lot of rules.
To reproduce
Steps to reproduce the behavior:
- Create a file called
test.php with the code sample above...
- Run
phpcs test.php ...
- See the error message displayed
Expected behavior
A clear and concise description of what you expected to happen.
Versions (please complete the following information)
|
|
| Operating System |
(e.g., [Ubuntu 22.04.5 LTS) |
| PHP version |
(e.g., 7.2, 8.1) |
| PHP_CodeSniffer version |
(e.g., 3.13.0) |
| Standard |
(dfferent) |
| Install type |
(e.g. Composer local |
Additional context
Add any other context about the problem here.
Please confirm
Describe the bug
After upgrading to PHP_CodeSniffer 3.13.0, phpcbf fails to fix files containing a large number of fully qualified namespace violations. The command outputs "*** Reached maximum number of loops with 0 violations left unfixed ***" and reverts all fixes.
I have a PHP file with many fully qualified class names (e.g., \Full\Namespace\Class::class)
Run phpcbf on the file with rules that convert FQCN to short names with use statements
Observe the failure with PHPCS 3.13.0+
The same file fixes correctly with PHPCS 3.12.2
PHPCS 3.13.0+: Fails with loop limit error, no fixes applied
PHPCS 3.12.2: Works correctly, all fixes applied.
Code sample
Custom ruleset
I have a lot of rules.
To reproduce
Steps to reproduce the behavior:
test.phpwith the code sample above...phpcs test.php ...Expected behavior
A clear and concise description of what you expected to happen.
Versions (please complete the following information)
Additional context
Add any other context about the problem here.
Please confirm
4.xbranch of PHP_CodeSniffer.