-
Notifications
You must be signed in to change notification settings - Fork 82
Closed
Description
Validation code
<?php
require __DIR__ . '/vendor/autoload.php';
$input = <<<'EOS'
<?php if (true): ?><?= 'x' ?><?php endif; ?>
EOS;
$ast = (new Microsoft\PhpParser\Parser())->parseSourceFile($input);
$f = function (Microsoft\PhpParser\Node $node, string $indent = '') use (&$f) {
echo $indent . get_class($node) . PHP_EOL;
foreach ($node->getChildNodes() as $child) {
$f($child, $indent . ' ');
}
};
$f($ast);Expected output
Should include EchoExpression and StringLiteral.
Microsoft\PhpParser\Node\SourceFileNode
Microsoft\PhpParser\Node\Statement\InlineHtml
Microsoft\PhpParser\Node\Statement\IfStatementNode
Microsoft\PhpParser\Node\ReservedWord
Microsoft\PhpParser\Node\Statement\InlineHtml
Microsoft\PhpParser\Node\Statement\ExpressionStatement
Microsoft\PhpParser\Node\Expression\EchoExpression
Microsoft\PhpParser\Node\DelimitedList\ExpressionList
Microsoft\PhpParser\Node\StringLiteral
Microsoft\PhpParser\Node\Statement\InlineHtml
Microsoft\PhpParser\Node\Statement\InlineHtml
Actual output
EchoExpression and StringLiteral are not included.
Microsoft\PhpParser\Node\SourceFileNode
Microsoft\PhpParser\Node\Statement\InlineHtml
Microsoft\PhpParser\Node\Statement\IfStatementNode
Microsoft\PhpParser\Node\ReservedWord
Microsoft\PhpParser\Node\Statement\InlineHtml
Microsoft\PhpParser\Node\Statement\InlineHtml
Microsoft\PhpParser\Node\Statement\InlineHtml
Metadata
Metadata
Assignees
Labels
No labels