-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHPCBF adds brace for ELSE IF split over multiple lines #558
Comments
Can you please specify standard used and error reported in original code. |
Command So I've used the psr2 standard and could you explain what you meant by 'error reported in original code.' because this test snippet does reproduce the fatal code change |
This is result of |
Snippet <?php
namespace test;
class Test
{
public function test($test)
{
if ($test) {
} else
if ($test) {
} else {
}
}
} Command 9 | ERROR | [x] Expected 1 space after ELSE keyword; newline found Generic.ControlStructures.InlineControlStructure.NotAllowed |
This was a problem with the inline control structure sniff not understanding that the You need to run PHPCBF a couple of times over this specific code block because the sniff to get it perfect (due to a conflict between the indent, newline and elseif sniffs in this specific case) but you will end up with this: <?php
namespace test;
class Test
{
public function test($test)
{
if ($test) {
} elseif ($test) {
} else {
}
}
} |
…cessary-string-concat Generic/UnnecessaryStringConcat: improve code coverage
PHPCBF is currently fixing bracketless if-else statements incorrectly and causing a fatal error.
Which means that the code won't run, because of the 2 else statements in a row, as seen in my example.
Before:
After:
Log:
Processing test.php [PHP => 53 tokens in 12 lines]... DONE in 3ms (9 fixable violations)
=> Fixing file: 0/9 violations remaining [made 6 passes]... DONE in 61ms
Patched 1 file
Time: 146ms; Memory: 5.25Mb
Version:
PHP_CodeSniffer version 2.3.0 (stable) by Squiz (http://www.squiz.net)
The text was updated successfully, but these errors were encountered: