php-parser/test_old/testExpressions.php

43 lines
790 B
PHP
Raw Normal View History

<?php
$exprs = <<<'EXPRS'
a::$b
$a::$b
a::${b}
$a::${b}
a::$$b
$a::$$b
2011-05-31 18:33:38 +02:00
a::$b()
a::$b[c]()
EXPRS;
2011-06-05 18:47:52 +02:00
require_once '../lib/PHPParser/Autoloader.php';
PHPParser_Autoloader::register();
2011-06-05 18:40:04 +02:00
$parser = new PHPParser_Parser;
include './testFormatting.html';
echo '<table>
<tr>
<td>Expression</td>
<td>Result</td>
</tr>';
foreach (explode("\n", $exprs) as $expr) {
if ('' === $expr) {
continue;
}
try {
2011-06-05 18:40:04 +02:00
$parser->parse(new PHPParser_Lexer('<?php ' . $expr . ';'));
echo '<tr><td>' . $expr . '</td><td class="pass">PASS</td></tr>';
} catch (PHPParser_Error $e) {
echo '<tr><td>' . $expr . '</td><td class="fail">FAIL</td></tr>';
echo '<tr><td colspan="2">' . $e->getMessage() . '</td></tr>';
}
}
echo '</table>';