diff --git a/lib/PhpParser/PrettyPrinter/Standard.php b/lib/PhpParser/PrettyPrinter/Standard.php index 545d521..9696330 100644 --- a/lib/PhpParser/PrettyPrinter/Standard.php +++ b/lib/PhpParser/PrettyPrinter/Standard.php @@ -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) { diff --git a/test/PhpParser/PrettyPrinterTest.php b/test/PhpParser/PrettyPrinterTest.php index e47a9b9..b155571 100644 --- a/test/PhpParser/PrettyPrinterTest.php +++ b/test/PhpParser/PrettyPrinterTest.php @@ -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