Skip to content

Commit 1453551

Browse files
committed
Ast: PhpNode - fixed parsing of Foo::class in global namespace
1 parent f5c6dad commit 1453551

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/Ast/PhpNode.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public static function parse(NodeParser $parser)
7575
} elseif ($parser->isCurrent(T_NAMESPACE)) {
7676
$child = NamespaceNode::parse($parser->createSubParser());
7777

78+
} elseif ($parser->isCurrent(T_DOUBLE_COLON)) { // static call or property/constant
79+
$parser->consumeAsUnknowContent(T_DOUBLE_COLON);
80+
$parser->tryConsumeAsUnknowContent(T_CLASS);
81+
7882
} elseif ($parser->isCurrent(T_USE)) {
7983
$child = UseNode::parse($parser->createSubParser());
8084

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CzProject\PhpSimpleAst\Ast\PhpString
2+
children: array (1)
3+
| 0 => CzProject\PhpSimpleAst\Ast\PhpNode
4+
| | openTag: '<?php\n'
5+
| | children: array (1)
6+
| | | 0 => CzProject\PhpSimpleAst\Ast\UnknowNode
7+
| | | | content: string
8+
| | | | | '\n
9+
| | | | | echo \Foo\Bar::class;\n
10+
| | | | | test(\Foo\Bar::class, 'Lorem ipsum');\n'
11+
| | closeTag: null
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
echo \Foo\Bar::class;
4+
test(\Foo\Bar::class, 'Lorem ipsum');

0 commit comments

Comments
 (0)