squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.67k stars 1.48k forks source link

fails after php tag #3652

Open ghost opened 2 years ago

ghost commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

Some files have errors and cannot be repaired, so the code has been truncated to make it shorter and easier to understand.

I don't know if it's a bug or not. But other tools don't fail.

phpcbf --version PHP_CodeSniffer version 3.7.1 (stable) by Squiz (http://www.squiz.net)

Code sample

<?php

function test()
{
?> <?php

printf("%d",
1);
}

To reproduce Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...
  3. See error message displayed

PHPCS output here

C:\tmp>phpcbf --standard=PSR2 -v text2.php
Registering sniffs in the PSR2 standard... DONE (43 sniffs registered)
Creating file list... DONE (1 files in queue)
Changing into directory C:\tmp
Processing text2.php [PHP => 28 tokens in 9 lines]... DONE in 24ms (4 fixable violations)
        => Fixing file: 1/4 violations remaining [made 50 passes]... ERROR in 551ms

PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
C:\tmp\text2.php                                      FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 3 ERRORS WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------

Time: 826ms; Memory: 8MB
jrfnl commented 2 years ago

Confirmed as reproducable.

Looks like a fixer conflict between the Generic.WhiteSpace.ScopeIndent sniff and the PEAR.Functions.FunctionCallSignature sniff.