|
16 | 16 | use PhpParser\Node\Stmt\Class_;
|
17 | 17 | use PhpParser\Node\Stmt\ClassConst;
|
18 | 18 | use PhpParser\Node\Stmt\ClassMethod;
|
| 19 | +use PhpParser\Node\Stmt\Else_; |
| 20 | +use PhpParser\Node\Stmt\ElseIf_; |
19 | 21 | use PhpParser\Node\Stmt\Enum_;
|
20 | 22 | use PhpParser\Node\Stmt\Interface_;
|
21 | 23 | use PhpParser\Node\Stmt\Namespace_;
|
| 24 | +use PhpParser\Node\Stmt\Nop; |
22 | 25 | use PhpParser\Node\Stmt\Property;
|
23 | 26 | use PhpParser\Node\Stmt\TryCatch;
|
24 | 27 | use PhpParser\Node\Stmt\UseUse;
|
@@ -876,6 +879,24 @@ protected function createCommentNopAttributes(array $comments) {
|
876 | 879 | return $attributes;
|
877 | 880 | }
|
878 | 881 |
|
| 882 | + /** @param ElseIf_|Else_ $node */ |
| 883 | + protected function fixupAlternativeElse($node) { |
| 884 | + // Make sure a trailing nop statement carrying comments is part of the node. |
| 885 | + $numStmts = \count($node->stmts); |
| 886 | + if ($numStmts !== 0 && $node->stmts[$numStmts - 1] instanceof Nop) { |
| 887 | + $nopAttrs = $node->stmts[$numStmts - 1]->getAttributes(); |
| 888 | + if (isset($nopAttrs['endLine'])) { |
| 889 | + $node->setAttribute('endLine', $nopAttrs['endLine']); |
| 890 | + } |
| 891 | + if (isset($nopAttrs['endFilePos'])) { |
| 892 | + $node->setAttribute('endFilePos', $nopAttrs['endFilePos']); |
| 893 | + } |
| 894 | + if (isset($nopAttrs['endTokenPos'])) { |
| 895 | + $node->setAttribute('endTokenPos', $nopAttrs['endTokenPos']); |
| 896 | + } |
| 897 | + } |
| 898 | + } |
| 899 | + |
879 | 900 | protected function checkClassModifier($a, $b, $modifierPos) {
|
880 | 901 | try {
|
881 | 902 | Class_::verifyClassModifier($a, $b);
|
|
0 commit comments