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:
parent
3ce5e628a7
commit
6526ea2497
@ -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) {
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user