mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-16 22:58:15 +01:00
parent
ec02613432
commit
70c96493b4
@ -251,7 +251,7 @@ class TokenStream {
|
||||
private function calcIndentMap(): array {
|
||||
$indentMap = [];
|
||||
$indent = 0;
|
||||
foreach ($this->tokens as $token) {
|
||||
foreach ($this->tokens as $i => $token) {
|
||||
$indentMap[] = $indent;
|
||||
|
||||
if ($token->id === \T_WHITESPACE) {
|
||||
@ -259,6 +259,10 @@ class TokenStream {
|
||||
$newlinePos = \strrpos($content, "\n");
|
||||
if (false !== $newlinePos) {
|
||||
$indent = \strlen($content) - $newlinePos - 1;
|
||||
} elseif ($i === 1 && $this->tokens[0]->id === \T_OPEN_TAG &&
|
||||
$this->tokens[0]->text[\strlen($this->tokens[0]->text) - 1] === "\n") {
|
||||
// Special case: Newline at the end of opening tag followed by whitespace.
|
||||
$indent = \strlen($content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,3 +50,14 @@ class Test {
|
||||
// some code
|
||||
}
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
class Example {
|
||||
}
|
||||
-----
|
||||
$stmts[0]->setDocComment(new Comment\Doc("/** foo */"));
|
||||
-----
|
||||
<?php
|
||||
/** foo */
|
||||
class Example {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user