The _braces_ rules is moving PHP closing tag next to previous closing brace and I don't see why (which fixer says so) nor how to prevent it from doing it.
=> 7.3.17-1+ubuntu18.04.1+deb.sury.org+1
=> PHP CS Fixer 2.16.3 Yellow Bird
=> ./vendor/bin/php-cs-fixer fix --diff -v --using-cache=no
.php_cs.dist file):<?php
$finder = PhpCsFixer\Finder::create()
->in('samples')
;
return PhpCsFixer\Config::create()
->setFinder($finder)
;
<?php
if (true) {
?>
<hr />
<?php
if (true) {
echo 'x';
}
?>
<hr />
<?php
}
The _braces_ rule is triggered and the second PHP closing tag ?> (from line 10) moves next to the previous closing brace } (to line 9).
--- Original
+++ New
@@ @@
echo 'x';
- }
- ?>
+ } ?>
<hr />
<?php
}
Here is sample "fixed" by PHP CS Fixer:
<?php
if (true) {
?>
<hr />
<?php
if (true) {
echo 'x';
} ?>
<hr />
<?php
}
I expected no changes, at least not for the PHP closing tag ?>.
<?php
if (true) {
?>
<hr />
<?php
if (true) {
echo 'x';
}
?>
<hr />
<?php
}
Hi and thanks for reporting,
Wondering if can fix this in https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4884 or if its worth fixing in the current fixer, WDYT @julienfalque ?
I'd vote for fixing the bug in #4884 to avoid fixing it twice, but that means it will not be released until the PR is merged, which might be in a while.
Waiting for #4884 is fine for me: as long as you got the info :)
Actually this is already fixed by #4884: I added a test case and it passes without extra changes.
Thanks for checking this :+1:
I guess I can close this issue andl watch #4884.
Most helpful comment
I'd vote for fixing the bug in #4884 to avoid fixing it twice, but that means it will not be released until the PR is merged, which might be in a while.