mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
Throw if pretty-printing Error node
This commit is contained in:
parent
ba57202ed7
commit
fd7ac25108
@ -485,6 +485,10 @@ class Standard extends PrettyPrinterAbstract
|
||||
|
||||
// Other
|
||||
|
||||
protected function pExpr_Error(Expr\Error $node) {
|
||||
throw new \LogicException('Cannot pretty-print AST with Error nodes');
|
||||
}
|
||||
|
||||
protected function pExpr_Variable(Expr\Variable $node) {
|
||||
if ($node->name instanceof Expr) {
|
||||
return '${' . $this->p($node->name) . '}';
|
||||
|
@ -183,4 +183,14 @@ class PrettyPrinterTest extends CodeTestAbstract
|
||||
[new DNumber(-\NAN), '\NAN'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot pretty-print AST with Error nodes
|
||||
*/
|
||||
public function testPrettyPrintWithError() {
|
||||
$stmts = [new Expr\PropertyFetch(new Expr\Variable('a'), new Expr\Error())];
|
||||
$prettyPrinter = new PrettyPrinter\Standard;
|
||||
$prettyPrinter->prettyPrint($stmts);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user