1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

FPPP: Fix comment indentation (#443)

This commit is contained in:
Nikita Popov 2017-11-13 13:27:27 +01:00
parent fa174b093f
commit 336a49b428
3 changed files with 30 additions and 5 deletions

View File

@ -1,7 +1,9 @@
Version 4.0.0-dev
-----------------
Nothing yet.
### Fixed
* Fixed comment indentation in formatting-preserving pretty printer.
Version 4.0.0-alpha2 (2017-11-10)
---------------------------------

View File

@ -721,6 +721,9 @@ abstract class PrettyPrinterAbstract
continue;
}
$origIndentLevel = $this->indentLevel;
$this->setIndentLevel($this->origTokens->getIndentationBefore($itemStartPos) + $indentAdjustment);
$comments = $arrItem->getComments();
$origComments = $origArrItem->getComments();
if ($comments !== $origComments) {
@ -741,9 +744,6 @@ abstract class PrettyPrinterAbstract
} else {
$result .= $this->origTokens->getTokenCode($pos, $itemStartPos, $indentAdjustment);
}
$origIndentLevel = $this->indentLevel;
$this->setIndentLevel($this->origTokens->getIndentationBefore($itemStartPos) + $indentAdjustment);
} else if ($diffType === DiffElem::TYPE_ADD) {
if (null === $insertStr) {
// We don't have insertion information for this list type

View File

@ -26,4 +26,27 @@ $foo;
/* bar */
// foo
$baz;
$baz;
-----
<?php
class Test {
/**
* @expectedException \FooException
*/
public function test() {
// some code
}
}
-----
$method = $stmts[0]->stmts[0];
$method->setAttribute('comments', [new Comment\Doc("/**\n *\n */")]);
-----
<?php
class Test {
/**
*
*/
public function test() {
// some code
}
}