FPPP: Fall back if comment in list node changes (#420)

This commit is contained in:
Nikita Popov 2017-10-02 21:17:41 +02:00
parent cc600b67f6
commit f6cc85a796
2 changed files with 17 additions and 0 deletions

View File

@ -663,6 +663,12 @@ abstract class PrettyPrinterAbstract
return null;
}
if ($arrItem->getComments() !== $origArrItem->getComments()) {
// Comments changed, fall back
// TODO This should only reprint the changed comments
return null;
}
$itemStartPos = $origArrItem->getStartTokenPos();
$itemEndPos = $origArrItem->getEndTokenPos();
if ($itemStartPos < 0 || $itemEndPos < 0) {

View File

@ -0,0 +1,11 @@
Fallback on comment change (for now at least)
-----
<?php
// Test
foo();
-----
$stmts[0]->setAttribute('comments', []);
-----
<?php
foo();