- Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
I've found an incorrect fix of PHPCBF.
It is about a 'function() use() {' which will be "fixed" into 'function() { use()', which will obviously break the code, and make it not work properly anymore.
I've listed here the errors and test case, I've used a custom standard, but I suspect the 'Squiz.Functions.MultiLineFunctionDeclaration.BraceOnNewLine' to cause this failed fix.
Thanks in advance
PHPCS
---------------------------------------------------------------------- FOUND 4 ERRORS AFFECTING 4 LINES ---------------------------------------------------------------------- 26 | ERROR | [x] Expected 1 space after USE keyword; found 0 | | (Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterUse) 33 | ERROR | [x] Expected 1 space after USE keyword; found 0 | | (Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterUse) 34 | ERROR | [x] Opening brace should be on the same line as the | | declaration | | (Squiz.Functions.MultiLineFunctionDeclaration.BraceOnNewLine) 42 | ERROR | [x] Opening brace should be on the same line as the | | declaration | | (Squiz.Functions.MultiLineFunctionDeclaration.BraceOnNewLine) ---------------------------------------------------------------------- PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY ----------------------------------------------------------------------
PHPCBF
Processing Test.php [PHP => 178 tokens in 46 lines]... DONE in 8ms (4 fixable violations) => Fixing file: 0/4 violations remaining [made 4 passes]... DONE in 60ms Patched 1 file Time: 96ms; Memory: 5.25Mb
BEFORE
<?php namespace Test\Test; class Test { public function testA() { function ($param) use($result) { return null; } } public function testB() { function ($param) use($result) { return null; } } public function testC() { function ($param) use ($result) { return null; } } }
AFTER
<?php namespace Test\Test; class Test { public function testA() { function ($param) use ($result) { return null; } } public function testB() { function ($param) { use ($result) // <-- WRONG return null; } } public function testC() { function ($param) { use ($result) // <-- WRONG return null; } } }