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