You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php
$out=array_map(function($test) { if($test) return 1; else return 2; }, $input);
$out=array_map(function($test) { if($test) return 1; else return 2; }, $input); // this line is as the above but with a trailing comment
when I run vendor/bin/phpcbf test.php, I get the following fixed file
<?php
$out=array_map(
function ($test) {
if($test) { return 1;
} else { return 2;
}
}, $input
);
$out=array_map(
function ($test) {
if($test) { return 1; else { return 2;
}
}, $input
); // this line is as the above but with a trailing comment
}
Notice the if brace did not close before the else, and that the array_map parentheses close too early.
I'm using "squizlabs/php_codesniffer": "^2.7" in my composer.json file
The text was updated successfully, but these errors were encountered:
Confirming that before the fix, if you run with the PSR2 standard, you get this:
<?php
$out=array_map(function ($test) {
if ($test) {
return 1;
} else {
return 2;
}
}, $input);
$out=array_map(function ($test) {
if ($test) {
return 1;
else {
return 2;
}
}, $input); // this line is as the above but with a trailing comment
}
After the fix, if you run with the PSR2 standard, you get this:
<?php
$out=array_map(function ($test) {
if ($test) {
return 1;
} else {
return 2;
}
}, $input);
$out=array_map(function ($test) {
if ($test) {
return 1;
} else {
return 2;
}
}, $input); // this line is as the above but with a trailing comment
Thanks for the bug report. It was very clear and helpful.
Uh oh!
There was an error while loading. Please reload this page.
I have a file
test.php
with the following contentwhen I run
vendor/bin/phpcbf test.php
, I get the following fixed fileNotice the
if
brace did not close before theelse
, and that thearray_map
parentheses close too early.I'm using
"squizlabs/php_codesniffer": "^2.7"
in mycomposer.json
fileThe text was updated successfully, but these errors were encountered: