package updates
This commit is contained in:
@@ -123,39 +123,31 @@ DOC;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Unexpected node of type "Stmt_Echo"
|
||||
*/
|
||||
public function testInvalidStmtError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Unexpected node of type "Stmt_Echo"');
|
||||
$this->createClassBuilder('Test')
|
||||
->addStmt(new Stmt\Echo_([]))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Doc comment must be a string or an instance of PhpParser\Comment\Doc
|
||||
*/
|
||||
public function testInvalidDocComment() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Doc comment must be a string or an instance of PhpParser\Comment\Doc');
|
||||
$this->createClassBuilder('Test')
|
||||
->setDocComment(new Comment('Test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Name cannot be empty
|
||||
*/
|
||||
public function testEmptyName() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Name cannot be empty');
|
||||
$this->createClassBuilder('Test')
|
||||
->extend('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Name must be a string or an instance of Node\Name
|
||||
*/
|
||||
public function testInvalidName() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Name must be a string or an instance of Node\Name');
|
||||
$this->createClassBuilder('Test')
|
||||
->extend(['Foo']);
|
||||
}
|
||||
|
||||
@@ -92,29 +92,23 @@ class FunctionTest extends TestCase
|
||||
], []), $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage void type cannot be nullable
|
||||
*/
|
||||
public function testInvalidNullableVoidType() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('void type cannot be nullable');
|
||||
$this->createFunctionBuilder('test')->setReturnType('?void');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Expected parameter node, got "Name"
|
||||
*/
|
||||
public function testInvalidParamError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Expected parameter node, got "Name"');
|
||||
$this->createFunctionBuilder('test')
|
||||
->addParam(new Node\Name('foo'))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Expected statement or expression node
|
||||
*/
|
||||
public function testAddNonStmt() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Expected statement or expression node');
|
||||
$this->createFunctionBuilder('test')
|
||||
->addStmt(new Node\Name('Test'));
|
||||
}
|
||||
|
||||
@@ -79,11 +79,9 @@ class InterfaceTest extends TestCase
|
||||
]), $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Unexpected node of type "Stmt_PropertyProperty"
|
||||
*/
|
||||
public function testInvalidStmtError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Unexpected node of type "Stmt_PropertyProperty"');
|
||||
$this->builder->addStmt(new Stmt\PropertyProperty('invalid'));
|
||||
}
|
||||
|
||||
|
||||
@@ -135,33 +135,27 @@ class MethodTest extends TestCase
|
||||
], []), $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot add statements to an abstract method
|
||||
*/
|
||||
public function testAddStmtToAbstractMethodError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Cannot add statements to an abstract method');
|
||||
$this->createMethodBuilder('test')
|
||||
->makeAbstract()
|
||||
->addStmt(new Print_(new String_('test')))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot make method with statements abstract
|
||||
*/
|
||||
public function testMakeMethodWithStmtsAbstractError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Cannot make method with statements abstract');
|
||||
$this->createMethodBuilder('test')
|
||||
->addStmt(new Print_(new String_('test')))
|
||||
->makeAbstract()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Expected parameter node, got "Name"
|
||||
*/
|
||||
public function testInvalidParamError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Expected parameter node, got "Name"');
|
||||
$this->createMethodBuilder('test')
|
||||
->addParam(new Node\Name('foo'))
|
||||
;
|
||||
|
||||
@@ -129,19 +129,15 @@ class ParamTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Parameter type cannot be void
|
||||
*/
|
||||
public function testVoidTypeError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Parameter type cannot be void');
|
||||
$this->createParamBuilder('test')->setType('void');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Type must be a string, or an instance of Name, Identifier or NullableType
|
||||
*/
|
||||
public function testInvalidTypeError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Type must be a string, or an instance of Name, Identifier or NullableType');
|
||||
$this->createParamBuilder('test')->setType(new \stdClass);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,9 @@ class TraitTest extends TestCase
|
||||
]), $trait);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Unexpected node of type "Stmt_Echo"
|
||||
*/
|
||||
public function testInvalidStmtError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Unexpected node of type "Stmt_Echo"');
|
||||
$this->createTraitBuilder('Test')
|
||||
->addStmt(new Stmt\Echo_([]))
|
||||
;
|
||||
|
||||
+12
-24
@@ -55,65 +55,53 @@ class TraitUseAdaptationTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot set alias for not alias adaptation buider
|
||||
*/
|
||||
public function testAsOnNotAlias() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Cannot set alias for not alias adaptation buider');
|
||||
$this->createTraitUseAdaptationBuilder('Test', 'foo')
|
||||
->insteadof('AnotherTrait')
|
||||
->as('bar')
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot add overwritten traits for not precedence adaptation buider
|
||||
*/
|
||||
public function testInsteadofOnNotPrecedence() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Cannot add overwritten traits for not precedence adaptation buider');
|
||||
$this->createTraitUseAdaptationBuilder('Test', 'foo')
|
||||
->as('bar')
|
||||
->insteadof('AnotherTrait')
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Precedence adaptation must have trait
|
||||
*/
|
||||
public function testInsteadofWithoutTrait() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Precedence adaptation must have trait');
|
||||
$this->createTraitUseAdaptationBuilder(null, 'foo')
|
||||
->insteadof('AnotherTrait')
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot set access modifier for not alias adaptation buider
|
||||
*/
|
||||
public function testMakeOnNotAlias() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Cannot set access modifier for not alias adaptation buider');
|
||||
$this->createTraitUseAdaptationBuilder('Test', 'foo')
|
||||
->insteadof('AnotherTrait')
|
||||
->makePublic()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Multiple access type modifiers are not allowed
|
||||
*/
|
||||
public function testMultipleMake() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Multiple access type modifiers are not allowed');
|
||||
$this->createTraitUseAdaptationBuilder(null, 'foo')
|
||||
->makePrivate()
|
||||
->makePublic()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Type of adaptation is not defined
|
||||
*/
|
||||
public function testUndefinedType() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Type of adaptation is not defined');
|
||||
$this->createTraitUseAdaptationBuilder(null, 'foo')
|
||||
->getNode()
|
||||
;
|
||||
|
||||
@@ -45,11 +45,9 @@ class TraitUseTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Adaptation must have type TraitUseAdaptation
|
||||
*/
|
||||
public function testInvalidAdaptationNode() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Adaptation must have type TraitUseAdaptation');
|
||||
$this->createTraitUseBuilder('Test')
|
||||
->with(new Stmt\Echo_([]))
|
||||
;
|
||||
|
||||
+12
-24
@@ -69,19 +69,15 @@ class BuilderFactoryTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Expected at least two expressions
|
||||
*/
|
||||
public function testConcatOneError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Expected at least two expressions');
|
||||
(new BuilderFactory())->concat("a");
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Expected string or Expr
|
||||
*/
|
||||
public function testConcatInvalidExpr() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Expected string or Expr');
|
||||
(new BuilderFactory())->concat("a", 42);
|
||||
}
|
||||
|
||||
@@ -218,35 +214,27 @@ class BuilderFactoryTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Expected string or instance of Node\Identifier
|
||||
*/
|
||||
public function testInvalidIdentifier() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Expected string or instance of Node\Identifier');
|
||||
(new BuilderFactory())->classConstFetch('Foo', new Expr\Variable('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Expected string or instance of Node\Identifier or Node\Expr
|
||||
*/
|
||||
public function testInvalidIdentifierOrExpr() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Expected string or instance of Node\Identifier or Node\Expr');
|
||||
(new BuilderFactory())->staticCall('Foo', new Name('bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Name must be a string or an instance of Node\Name or Node\Expr
|
||||
*/
|
||||
public function testInvalidNameOrExpr() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Name must be a string or an instance of Node\Name or Node\Expr');
|
||||
(new BuilderFactory())->funcCall(new Node\Stmt\Return_());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Variable name must be string or Expr
|
||||
*/
|
||||
public function testInvalidVar() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Variable name must be string or Expr');
|
||||
(new BuilderFactory())->var(new Node\Stmt\Return_());
|
||||
}
|
||||
|
||||
|
||||
@@ -73,11 +73,9 @@ class ConstExprEvaluatorTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \PhpParser\ConstExprEvaluationException
|
||||
* @expectedExceptionMessage Expression of type Expr_Variable cannot be evaluated
|
||||
*/
|
||||
public function testEvaluateFails() {
|
||||
$this->expectException(ConstExprEvaluationException::class);
|
||||
$this->expectExceptionMessage('Expression of type Expr_Variable cannot be evaluated');
|
||||
$evaluator = new ConstExprEvaluator();
|
||||
$evaluator->evaluateDirectly(new Expr\Variable('a'));
|
||||
}
|
||||
|
||||
@@ -7,11 +7,9 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ThrowingTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \PhpParser\Error
|
||||
* @expectedExceptionMessage Test
|
||||
*/
|
||||
public function testHandleError() {
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Test');
|
||||
$errorHandler = new Throwing();
|
||||
$errorHandler->handleError(new Error('Test'));
|
||||
}
|
||||
|
||||
+2
-4
@@ -94,11 +94,9 @@ class ErrorTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage Invalid position information
|
||||
*/
|
||||
public function testInvalidPosInfo() {
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('Invalid position information');
|
||||
$error = new Error('Some error', [
|
||||
'startFilePos' => 10,
|
||||
'endFilePos' => 11,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace PhpParser\Lexer;
|
||||
|
||||
use PhpParser\ErrorHandler;
|
||||
use PhpParser\LexerTest;
|
||||
use PhpParser\Parser\Tokens;
|
||||
|
||||
@@ -63,12 +64,11 @@ class EmulativeTest extends LexerTest
|
||||
$lexer = $this->getLexer();
|
||||
$lexer->startLexing('<?php ' . $code);
|
||||
|
||||
foreach ($expectedTokens as $expectedToken) {
|
||||
list($expectedTokenType, $expectedTokenText) = $expectedToken;
|
||||
$this->assertSame($expectedTokenType, $lexer->getNextToken($text));
|
||||
$this->assertSame($expectedTokenText, $text);
|
||||
$tokens = [];
|
||||
while (0 !== $token = $lexer->getNextToken($text)) {
|
||||
$tokens[] = [$token, $text];
|
||||
}
|
||||
$this->assertSame(0, $lexer->getNextToken());
|
||||
$this->assertSame($expectedTokens, $tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,6 +85,29 @@ class EmulativeTest extends LexerTest
|
||||
$this->assertSame(0, $lexer->getNextToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestLexNewFeatures
|
||||
*/
|
||||
public function testErrorAfterEmulation($code) {
|
||||
$errorHandler = new ErrorHandler\Collecting;
|
||||
$lexer = $this->getLexer([]);
|
||||
$lexer->startLexing('<?php ' . $code . "\0", $errorHandler);
|
||||
|
||||
$errors = $errorHandler->getErrors();
|
||||
$this->assertCount(1, $errors);
|
||||
|
||||
$error = $errors[0];
|
||||
$this->assertSame('Unexpected null byte', $error->getRawMessage());
|
||||
|
||||
$attrs = $error->getAttributes();
|
||||
$expPos = strlen('<?php ' . $code);
|
||||
$expLine = 1 + substr_count('<?php ' . $code, "\n");
|
||||
$this->assertSame($expPos, $attrs['startFilePos']);
|
||||
$this->assertSame($expPos, $attrs['endFilePos']);
|
||||
$this->assertSame($expLine, $attrs['startLine']);
|
||||
$this->assertSame($expLine, $attrs['endLine']);
|
||||
}
|
||||
|
||||
public function provideTestLexNewFeatures() {
|
||||
return [
|
||||
['yield from', [
|
||||
@@ -128,6 +151,43 @@ class EmulativeTest extends LexerTest
|
||||
[Tokens::T_END_HEREDOC, 'NOWDOC'],
|
||||
[ord(';'), ';'],
|
||||
]],
|
||||
|
||||
// Flexible heredoc/nowdoc
|
||||
["<<<LABEL\nLABEL,", [
|
||||
[Tokens::T_START_HEREDOC, "<<<LABEL\n"],
|
||||
[Tokens::T_END_HEREDOC, "LABEL"],
|
||||
[ord(','), ','],
|
||||
]],
|
||||
["<<<LABEL\n LABEL,", [
|
||||
[Tokens::T_START_HEREDOC, "<<<LABEL\n"],
|
||||
[Tokens::T_END_HEREDOC, " LABEL"],
|
||||
[ord(','), ','],
|
||||
]],
|
||||
["<<<LABEL\n Foo\n LABEL;", [
|
||||
[Tokens::T_START_HEREDOC, "<<<LABEL\n"],
|
||||
[Tokens::T_ENCAPSED_AND_WHITESPACE, " Foo\n"],
|
||||
[Tokens::T_END_HEREDOC, " LABEL"],
|
||||
[ord(';'), ';'],
|
||||
]],
|
||||
["<<<A\n A,<<<A\n A,", [
|
||||
[Tokens::T_START_HEREDOC, "<<<A\n"],
|
||||
[Tokens::T_END_HEREDOC, " A"],
|
||||
[ord(','), ','],
|
||||
[Tokens::T_START_HEREDOC, "<<<A\n"],
|
||||
[Tokens::T_END_HEREDOC, " A"],
|
||||
[ord(','), ','],
|
||||
]],
|
||||
["<<<LABEL\nLABELNOPE\nLABEL\n", [
|
||||
[Tokens::T_START_HEREDOC, "<<<LABEL\n"],
|
||||
[Tokens::T_ENCAPSED_AND_WHITESPACE, "LABELNOPE\n"],
|
||||
[Tokens::T_END_HEREDOC, "LABEL"],
|
||||
]],
|
||||
// Interpretation changed
|
||||
["<<<LABEL\n LABEL\nLABEL\n", [
|
||||
[Tokens::T_START_HEREDOC, "<<<LABEL\n"],
|
||||
[Tokens::T_END_HEREDOC, " LABEL"],
|
||||
[Tokens::T_STRING, "LABEL"],
|
||||
]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -235,11 +235,9 @@ class LexerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \PhpParser\Error
|
||||
* @expectedExceptionMessage __HALT_COMPILER must be followed by "();"
|
||||
*/
|
||||
public function testHandleHaltCompilerError() {
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('__HALT_COMPILER must be followed by "();"');
|
||||
$lexer = $this->getLexer();
|
||||
$lexer->startLexing('<?php ... __halt_compiler invalid ();');
|
||||
|
||||
|
||||
+14
-28
@@ -51,35 +51,27 @@ class NameTest extends TestCase
|
||||
$this->assertNull($name->slice(-2, -2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
* @expectedExceptionMessage Offset 4 is out of bounds
|
||||
*/
|
||||
public function testSliceOffsetTooLarge() {
|
||||
$this->expectException(\OutOfBoundsException::class);
|
||||
$this->expectExceptionMessage('Offset 4 is out of bounds');
|
||||
(new Name('foo\bar\baz'))->slice(4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
* @expectedExceptionMessage Offset -4 is out of bounds
|
||||
*/
|
||||
public function testSliceOffsetTooSmall() {
|
||||
$this->expectException(\OutOfBoundsException::class);
|
||||
$this->expectExceptionMessage('Offset -4 is out of bounds');
|
||||
(new Name('foo\bar\baz'))->slice(-4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
* @expectedExceptionMessage Length 4 is out of bounds
|
||||
*/
|
||||
public function testSliceLengthTooLarge() {
|
||||
$this->expectException(\OutOfBoundsException::class);
|
||||
$this->expectExceptionMessage('Length 4 is out of bounds');
|
||||
(new Name('foo\bar\baz'))->slice(0, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
* @expectedExceptionMessage Length -4 is out of bounds
|
||||
*/
|
||||
public function testSliceLengthTooSmall() {
|
||||
$this->expectException(\OutOfBoundsException::class);
|
||||
$this->expectExceptionMessage('Length -4 is out of bounds');
|
||||
(new Name('foo\bar\baz'))->slice(0, -4);
|
||||
}
|
||||
|
||||
@@ -131,27 +123,21 @@ class NameTest extends TestCase
|
||||
$this->assertSame('namespace\foo', $name->toCodeString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Expected string, array of parts or Name instance
|
||||
*/
|
||||
public function testInvalidArg() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Expected string, array of parts or Name instance');
|
||||
Name::concat('foo', new \stdClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Name cannot be empty
|
||||
*/
|
||||
public function testInvalidEmptyString() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Name cannot be empty');
|
||||
new Name('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Name cannot be empty
|
||||
*/
|
||||
public function testInvalidEmptyArray() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Name cannot be empty');
|
||||
new Name([]);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,11 +98,9 @@ OUT;
|
||||
$this->assertSame($this->canonicalize($expected), $this->canonicalize($dump));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Can only dump nodes and arrays.
|
||||
*/
|
||||
public function testError() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Can only dump nodes and arrays.');
|
||||
$dumper = new NodeDumper;
|
||||
$dumper->dump(new \stdClass);
|
||||
}
|
||||
|
||||
@@ -117,11 +117,9 @@ class NodeTraverserTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Invalid node structure: Contains nested arrays
|
||||
*/
|
||||
public function testInvalidDeepArray() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Invalid node structure: Contains nested arrays');
|
||||
$strNode = new String_('Foo');
|
||||
$stmts = [[[$strNode]]];
|
||||
|
||||
@@ -167,6 +165,42 @@ class NodeTraverserTest extends TestCase
|
||||
$this->assertEquals($stmts, $traverser->traverse($stmts));
|
||||
}
|
||||
|
||||
public function testDontTraverseCurrentAndChildren() {
|
||||
// print 'str'; -($foo * $foo);
|
||||
$strNode = new String_('str');
|
||||
$printNode = new Expr\Print_($strNode);
|
||||
$varNode = new Expr\Variable('foo');
|
||||
$mulNode = new Expr\BinaryOp\Mul($varNode, $varNode);
|
||||
$divNode = new Expr\BinaryOp\Div($varNode, $varNode);
|
||||
$negNode = new Expr\UnaryMinus($mulNode);
|
||||
$stmts = [$printNode, $negNode];
|
||||
|
||||
$visitor1 = $this->getMockBuilder(NodeVisitor::class)->getMock();
|
||||
$visitor2 = $this->getMockBuilder(NodeVisitor::class)->getMock();
|
||||
|
||||
$visitor1->expects($this->at(1))->method('enterNode')->with($printNode)
|
||||
->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN));
|
||||
$visitor1->expects($this->at(2))->method('leaveNode')->with($printNode);
|
||||
|
||||
$visitor1->expects($this->at(3))->method('enterNode')->with($negNode);
|
||||
$visitor2->expects($this->at(1))->method('enterNode')->with($negNode);
|
||||
|
||||
$visitor1->expects($this->at(4))->method('enterNode')->with($mulNode)
|
||||
->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN));
|
||||
$visitor1->expects($this->at(5))->method('leaveNode')->with($mulNode)->willReturn($divNode);
|
||||
|
||||
$visitor1->expects($this->at(6))->method('leaveNode')->with($negNode);
|
||||
$visitor2->expects($this->at(2))->method('leaveNode')->with($negNode);
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor1);
|
||||
$traverser->addVisitor($visitor2);
|
||||
|
||||
$resultStmts = $traverser->traverse($stmts);
|
||||
|
||||
$this->assertInstanceOf(Expr\BinaryOp\Div::class, $resultStmts[1]->expr);
|
||||
}
|
||||
|
||||
public function testStopTraversal() {
|
||||
$varNode1 = new Expr\Variable('a');
|
||||
$varNode2 = new Expr\Variable('b');
|
||||
|
||||
+23
-28
@@ -13,29 +13,23 @@ abstract class ParserTest extends TestCase
|
||||
/** @returns Parser */
|
||||
abstract protected function getParser(Lexer $lexer);
|
||||
|
||||
/**
|
||||
* @expectedException \PhpParser\Error
|
||||
* @expectedExceptionMessage Syntax error, unexpected EOF on line 1
|
||||
*/
|
||||
public function testParserThrowsSyntaxError() {
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Syntax error, unexpected EOF on line 1');
|
||||
$parser = $this->getParser(new Lexer());
|
||||
$parser->parse('<?php foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \PhpParser\Error
|
||||
* @expectedExceptionMessage Cannot use foo as self because 'self' is a special class name on line 1
|
||||
*/
|
||||
public function testParserThrowsSpecialError() {
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Cannot use foo as self because \'self\' is a special class name on line 1');
|
||||
$parser = $this->getParser(new Lexer());
|
||||
$parser->parse('<?php use foo as self;');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \PhpParser\Error
|
||||
* @expectedExceptionMessage Unterminated comment on line 1
|
||||
*/
|
||||
public function testParserThrowsLexerError() {
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Unterminated comment on line 1');
|
||||
$parser = $this->getParser(new Lexer());
|
||||
$parser->parse('<?php /*');
|
||||
}
|
||||
@@ -109,11 +103,9 @@ EOC;
|
||||
], $var->getAttributes());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RangeException
|
||||
* @expectedExceptionMessage The lexer returned an invalid token (id=999, value=foobar)
|
||||
*/
|
||||
public function testInvalidToken() {
|
||||
$this->expectException(\RangeException::class);
|
||||
$this->expectExceptionMessage('The lexer returned an invalid token (id=999, value=foobar)');
|
||||
$lexer = new InvalidTokenLexer;
|
||||
$parser = $this->getParser($lexer);
|
||||
$parser->parse('dummy');
|
||||
@@ -123,7 +115,7 @@ EOC;
|
||||
* @dataProvider provideTestExtraAttributes
|
||||
*/
|
||||
public function testExtraAttributes($code, $expectedAttributes) {
|
||||
$parser = $this->getParser(new Lexer);
|
||||
$parser = $this->getParser(new Lexer\Emulative);
|
||||
$stmts = $parser->parse("<?php $code;");
|
||||
$node = $stmts[0] instanceof Stmt\Expression ? $stmts[0]->expr : $stmts[0];
|
||||
$attributes = $node->getAttributes();
|
||||
@@ -152,17 +144,20 @@ EOC;
|
||||
['"foo$bar"', ['kind' => String_::KIND_DOUBLE_QUOTED]],
|
||||
['b"foo$bar"', ['kind' => String_::KIND_DOUBLE_QUOTED]],
|
||||
['B"foo$bar"', ['kind' => String_::KIND_DOUBLE_QUOTED]],
|
||||
["<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']],
|
||||
["<<<STR\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
|
||||
["<<<\"STR\"\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
|
||||
["b<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']],
|
||||
["B<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']],
|
||||
["<<< \t 'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']],
|
||||
["<<<'\xff'\n\xff\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => "\xff"]],
|
||||
["<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
|
||||
["b<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
|
||||
["B<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
|
||||
["<<< \t \"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
|
||||
["<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
|
||||
["<<<STR\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
|
||||
["<<<\"STR\"\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
|
||||
["b<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
|
||||
["B<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
|
||||
["<<< \t 'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
|
||||
["<<<'\xff'\n\xff\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => "\xff", 'docIndentation' => '']],
|
||||
["<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
|
||||
["b<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
|
||||
["B<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
|
||||
["<<< \t \"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
|
||||
["<<<STR\n STR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => ' ']],
|
||||
["<<<STR\n\tSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => "\t"]],
|
||||
["<<<'STR'\n Foo\n STR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR', 'docIndentation' => ' ']],
|
||||
["die", ['kind' => Expr\Exit_::KIND_DIE]],
|
||||
["die('done')", ['kind' => Expr\Exit_::KIND_DIE]],
|
||||
["exit", ['kind' => Expr\Exit_::KIND_EXIT]],
|
||||
|
||||
@@ -184,11 +184,9 @@ class PrettyPrinterTest extends CodeTestAbstract
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot pretty-print AST with Error nodes
|
||||
*/
|
||||
public function testPrettyPrintWithError() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Cannot pretty-print AST with Error nodes');
|
||||
$stmts = [new Stmt\Expression(
|
||||
new Expr\PropertyFetch(new Expr\Variable('a'), new Expr\Error())
|
||||
)];
|
||||
@@ -196,11 +194,9 @@ class PrettyPrinterTest extends CodeTestAbstract
|
||||
$prettyPrinter->prettyPrint($stmts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot pretty-print AST with Error nodes
|
||||
*/
|
||||
public function testPrettyPrintWithErrorInClassConstFetch() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Cannot pretty-print AST with Error nodes');
|
||||
$stmts = [new Stmt\Expression(
|
||||
new Expr\ClassConstFetch(new Name('Foo'), new Expr\Error())
|
||||
)];
|
||||
@@ -208,11 +204,9 @@ class PrettyPrinterTest extends CodeTestAbstract
|
||||
$prettyPrinter->prettyPrint($stmts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot directly print EncapsedStringPart
|
||||
*/
|
||||
public function testPrettyPrintEncapsedStringPart() {
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('Cannot directly print EncapsedStringPart');
|
||||
$expr = new Node\Scalar\EncapsedStringPart('foo');
|
||||
$prettyPrinter = new PrettyPrinter\Standard;
|
||||
$prettyPrinter->prettyPrintExpr($expr);
|
||||
|
||||
@@ -0,0 +1,359 @@
|
||||
Flexible heredoc/nowdoc (PHP 7.3)
|
||||
-----
|
||||
<?php
|
||||
|
||||
$ary = [
|
||||
<<<FOO
|
||||
Test
|
||||
FOO,
|
||||
<<<'BAR'
|
||||
Test
|
||||
BAR,
|
||||
];
|
||||
|
||||
<<<'END'
|
||||
END;
|
||||
|
||||
<<<END
|
||||
|
||||
END;
|
||||
|
||||
<<<END
|
||||
@@{ " " }@@
|
||||
END;
|
||||
|
||||
<<<'END'
|
||||
a
|
||||
b
|
||||
|
||||
c
|
||||
|
||||
d
|
||||
e
|
||||
END;
|
||||
|
||||
<<<END
|
||||
a
|
||||
b
|
||||
$test
|
||||
d
|
||||
e
|
||||
END;
|
||||
|
||||
<<<'END'
|
||||
|
||||
a
|
||||
|
||||
b
|
||||
|
||||
c
|
||||
|
||||
d
|
||||
|
||||
e
|
||||
|
||||
END;
|
||||
|
||||
<<<END
|
||||
a\r\n
|
||||
\ta\n
|
||||
b\r\n
|
||||
$test\n
|
||||
d\r\n
|
||||
e\n
|
||||
END;
|
||||
|
||||
<<<BAR
|
||||
$one-
|
||||
BAR;
|
||||
|
||||
<<<BAR
|
||||
$two -
|
||||
BAR;
|
||||
|
||||
<<<BAR
|
||||
$three -
|
||||
BAR;
|
||||
|
||||
<<<BAR
|
||||
$four-$four
|
||||
BAR;
|
||||
|
||||
<<<BAR
|
||||
$five-$five-
|
||||
BAR;
|
||||
|
||||
<<<BAR
|
||||
$six-$six-$six
|
||||
BAR;
|
||||
|
||||
<<<BAR
|
||||
$seven
|
||||
-
|
||||
BAR;
|
||||
|
||||
<<<BAR
|
||||
$eight
|
||||
-
|
||||
BAR;
|
||||
|
||||
<<<BAR
|
||||
$nine
|
||||
BAR;
|
||||
|
||||
<<<BAR
|
||||
-
|
||||
BAR;
|
||||
|
||||
<<<BAR
|
||||
-
|
||||
BAR;
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Expression(
|
||||
expr: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: ary
|
||||
)
|
||||
expr: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: Test
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: Test
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Expression(
|
||||
expr: Scalar_String(
|
||||
value:
|
||||
)
|
||||
)
|
||||
2: Stmt_Expression(
|
||||
expr: Scalar_String(
|
||||
value:
|
||||
)
|
||||
)
|
||||
3: Stmt_Expression(
|
||||
expr: Scalar_String(
|
||||
value:
|
||||
)
|
||||
)
|
||||
4: Stmt_Expression(
|
||||
expr: Scalar_String(
|
||||
value: a
|
||||
b
|
||||
|
||||
c
|
||||
|
||||
d
|
||||
e
|
||||
)
|
||||
)
|
||||
5: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Scalar_EncapsedStringPart(
|
||||
value: a
|
||||
b
|
||||
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: test
|
||||
)
|
||||
2: Scalar_EncapsedStringPart(
|
||||
value:
|
||||
d
|
||||
e
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
6: Stmt_Expression(
|
||||
expr: Scalar_String(
|
||||
value:
|
||||
a
|
||||
|
||||
b
|
||||
|
||||
c
|
||||
|
||||
d
|
||||
|
||||
e
|
||||
|
||||
)
|
||||
)
|
||||
7: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Scalar_EncapsedStringPart(
|
||||
value: a
|
||||
|
||||
@@{ "\t" }@@a
|
||||
|
||||
b
|
||||
|
||||
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: test
|
||||
)
|
||||
2: Scalar_EncapsedStringPart(
|
||||
value:
|
||||
|
||||
d
|
||||
|
||||
e
|
||||
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
8: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: one
|
||||
)
|
||||
1: Scalar_EncapsedStringPart(
|
||||
value: -
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
9: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: two
|
||||
)
|
||||
1: Scalar_EncapsedStringPart(
|
||||
value: -
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
10: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: three
|
||||
)
|
||||
1: Scalar_EncapsedStringPart(
|
||||
value: -
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
11: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: four
|
||||
)
|
||||
1: Scalar_EncapsedStringPart(
|
||||
value: -
|
||||
)
|
||||
2: Expr_Variable(
|
||||
name: four
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
12: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: five
|
||||
)
|
||||
1: Scalar_EncapsedStringPart(
|
||||
value: -
|
||||
)
|
||||
2: Expr_Variable(
|
||||
name: five
|
||||
)
|
||||
3: Scalar_EncapsedStringPart(
|
||||
value: -
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
13: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: six
|
||||
)
|
||||
1: Scalar_EncapsedStringPart(
|
||||
value: -
|
||||
)
|
||||
2: Expr_Variable(
|
||||
name: six
|
||||
)
|
||||
3: Scalar_EncapsedStringPart(
|
||||
value: -
|
||||
)
|
||||
4: Expr_Variable(
|
||||
name: six
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
14: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: seven
|
||||
)
|
||||
1: Scalar_EncapsedStringPart(
|
||||
value:
|
||||
-
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
15: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: eight
|
||||
)
|
||||
1: Scalar_EncapsedStringPart(
|
||||
value:
|
||||
-
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
16: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: nine
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
17: Stmt_Expression(
|
||||
expr: Scalar_String(
|
||||
value: -
|
||||
)
|
||||
)
|
||||
18: Stmt_Expression(
|
||||
expr: Scalar_String(
|
||||
value: -
|
||||
)
|
||||
)
|
||||
)
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
Error conditions for flexible doc strings
|
||||
-----
|
||||
<?php
|
||||
|
||||
<<<A
|
||||
@@{ "\t" }@@A;
|
||||
|
||||
<<<A
|
||||
FooBar
|
||||
@@{ "\t" }@@A;
|
||||
|
||||
echo <<<END
|
||||
@@{ "\t" }@@ X
|
||||
@@{ "\t\t" }@@END;
|
||||
|
||||
echo <<<END
|
||||
a
|
||||
b
|
||||
c
|
||||
END;
|
||||
|
||||
<<<END
|
||||
\ta
|
||||
@@{ "\t" }@@END;
|
||||
|
||||
<<<TEST
|
||||
Foo
|
||||
$var
|
||||
TEST;
|
||||
|
||||
<<<TEST
|
||||
$var
|
||||
TEST;
|
||||
|
||||
echo <<<END
|
||||
a
|
||||
$a
|
||||
END;
|
||||
-----
|
||||
Invalid indentation - tabs and spaces cannot be mixed from 4:1 to 4:3
|
||||
Invalid indentation - tabs and spaces cannot be mixed from 8:1 to 8:3
|
||||
Invalid indentation - tabs and spaces cannot be mixed from 10:6 to 12:5
|
||||
Invalid body indentation level (expecting an indentation level of at least 5) from 14:6 to 18:8
|
||||
Invalid body indentation level (expecting an indentation level of at least 1) from 20:1 to 22:4
|
||||
Invalid body indentation level (expecting an indentation level of at least 2) from 25:1 to 26:0
|
||||
Invalid body indentation level (expecting an indentation level of at least 1) from 30:1 to 30:4
|
||||
Invalid body indentation level (expecting an indentation level of at least 1) from 34:1 to 35:0
|
||||
array(
|
||||
0: Stmt_Expression(
|
||||
expr: Scalar_String(
|
||||
value:
|
||||
)
|
||||
)
|
||||
1: Stmt_Expression(
|
||||
expr: Scalar_String(
|
||||
value: FooBar
|
||||
)
|
||||
)
|
||||
2: Stmt_Echo(
|
||||
exprs: array(
|
||||
0: Scalar_String(
|
||||
value: X
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Stmt_Echo(
|
||||
exprs: array(
|
||||
0: Scalar_String(
|
||||
value: a
|
||||
b
|
||||
c
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Stmt_Expression(
|
||||
expr: Scalar_String(
|
||||
value: a
|
||||
)
|
||||
)
|
||||
5: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Scalar_EncapsedStringPart(
|
||||
value: Foo
|
||||
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: var
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
6: Stmt_Expression(
|
||||
expr: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: var
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
7: Stmt_Echo(
|
||||
exprs: array(
|
||||
0: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Scalar_EncapsedStringPart(
|
||||
value: a
|
||||
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user