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

phpcbf FAILED TO FIX files #3702

Open samoralespu opened 2 years ago

samoralespu commented 2 years ago

Describe the bug I run phpcbf command, it fixed a lot of files, but it left this message "A TOTAL OF 43 ERRORS WERE FIXED IN 2 FILES" PHPCBF FAILED TO FIX 2 FILES

Code sample This is how I'm running the phpcbf

vendor/bin/phpcbf --standard=PSR12 app\views -n 

To reproduce Steps to reproduce the behavior:

  1. Create a file called _app_link_list.php with the code sample above:
    
    <div class='centered'>
    <table id='core_track_app_links' class="table table-hover">
      <thead class="table-dark">
         <tr>
            <th class='main_sortable sort_str'>App Name</th>
            <th>URL</th>
            <th>Actions</th> 
         </tr>
      </thead>
      <tbody>
         <?php
         foreach ($g_app as $app) {
            $line_class = "table_line_normal";
         ?>
            <tr class='<?php echo $line_class ?> row_line'>
               <td class='<?php echo $line_class ?>'> <?php echo $app->app_name ?></td>
               <td class='<?php echo $line_class ?>'> <?php echo $app->url ?></td>
               <td><?php
               link_edit_modal(["app_links", "update", "write"], "modal_app_links", "", 
                    ["action"=>"update", 
                     "id"      =>$app->id, 
                     "app_name"=>$app->app_name, 
                     "url"     =>$app->url
                     ]);
                link_remove_jquery(["app_links","delete","write"], "SaveAppNames(\"delete\",\"".$app->id."\")");
                     ?>
                </td>
            </tr>
         <?php
         }
         ?>
      </tbody>
    </table>
    </div>
2. Run `phpcbf
3. See error message displayed

PHPCBF FAILED TO FIX 2 FILES


Pd: this is just one of two files.

**Versions :**
 - OS: Windows 10
 - PHP: 8.1
 - PHPCS: 3.7.1
 - Standard: PSR12

Edit:
It was because of this:
`<td><?php`
I splited the line and it worked propperly.
I think it's a bug.

The other file error was because I was calling a function like this:
`generateSelectRequestMethods("id",$filter_endpoint_request,"filter_endpoint_request","onchange='filter_list(\"endpoints_table\",\"filter_endpoint_request\",0,5,\"row_line\",0)'",)
`

I guess that this final "," caused the program to fail, I think this is also a bug.
jrfnl commented 1 year ago

@samoralespu Your issue has gotten little attention as the report is pretty unclear. The bug report template asks for a small code sample to reproduce the issue with. The code sample as provided generates 27 different errors, so it is unclear what you are reporting.

It was because of this: <td><?php I splited the line and it worked propperly. I think it's a bug.

I can see there is some sort of conflict, but with 27 errors in the original code sample, there is too much noise. Please provide a small isolated code sample to make the issue reproducible.

The other file error was because I was calling a function like this:

I guess that this final "," caused the program to fail, I think this is also a bug.

This issue has been fixed via PR #3805 and the fix will be included in PHPCS 3.8.0.