1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2025-01-22 13:51:12 +01:00

Throw when printin EncapsedStringPart

This needs to go through something like Encapsed or ShellExec to
determine quotation type. Explicitly throw an exception to avoid
getting an undefined method error.
This commit is contained in:
Nikita Popov 2018-06-03 13:29:49 +02:00
parent 3ce5e628a7
commit 6526ea2497
2 changed files with 14 additions and 0 deletions

View File

@ -198,6 +198,10 @@ class Standard extends PrettyPrinterAbstract
return preg_match('/^-?[0-9]+$/', $stringValue) ? $stringValue . '.0' : $stringValue;
}
protected function pScalar_EncapsedStringPart(Scalar\EncapsedStringPart $node) {
throw new \LogicException('Cannot directly print EncapsedStringPart');
}
// Assignments
protected function pExpr_Assign(Expr\Assign $node) {

View File

@ -208,6 +208,16 @@ class PrettyPrinterTest extends CodeTestAbstract
$prettyPrinter->prettyPrint($stmts);
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage Cannot directly print EncapsedStringPart
*/
public function testPrettyPrintEncapsedStringPart() {
$expr = new Node\Scalar\EncapsedStringPart('foo');
$prettyPrinter = new PrettyPrinter\Standard;
$prettyPrinter->prettyPrintExpr($expr);
}
/**
* @dataProvider provideTestFormatPreservingPrint
* @covers \PhpParser\PrettyPrinter\Standard<extended>