Update v1.0.6
This commit is contained in:
41
vendor/nikic/php-parser/test/PhpParser/AutoloaderTest.php
vendored
Normal file
41
vendor/nikic/php-parser/test/PhpParser/AutoloaderTest.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar;
|
||||
|
||||
/* The autoloader is already active at this point, so we only check effects here. */
|
||||
|
||||
class AutoloaderTest extends \PHPUnit_Framework_TestCase {
|
||||
public function testLegacyNames() {
|
||||
$lexer = new \PHPParser_Lexer;
|
||||
$parser = new \PHPParser_Parser($lexer);
|
||||
$prettyPrinter = new \PHPParser_PrettyPrinter_Default;
|
||||
|
||||
$this->assertInstanceof('PhpParser\Lexer', $lexer);
|
||||
$this->assertInstanceof('PhpParser\Parser', $parser);
|
||||
$this->assertInstanceof('PhpParser\PrettyPrinter\Standard', $prettyPrinter);
|
||||
}
|
||||
|
||||
public function testPhp7ReservedNames() {
|
||||
if (version_compare(PHP_VERSION, '7.0-dev', '>=')) {
|
||||
$this->markTestSkipped('Cannot create aliases to reserved names on PHP 7');
|
||||
}
|
||||
|
||||
$this->assertTrue(new Expr\Cast\Bool_(new Expr\Variable('foo')) instanceof Expr\Cast\Bool);
|
||||
$this->assertTrue(new Expr\Cast\Int_(new Expr\Variable('foo')) instanceof Expr\Cast\Int);
|
||||
|
||||
$this->assertInstanceof('PhpParser\Node\Expr\Cast\Object_', new Expr\Cast\Object(new Expr\Variable('foo')));
|
||||
$this->assertInstanceof('PhpParser\Node\Expr\Cast\String_', new Expr\Cast\String(new Expr\Variable('foo')));
|
||||
$this->assertInstanceof('PhpParser\Node\Scalar\String_', new Scalar\String('foobar'));
|
||||
}
|
||||
|
||||
public function testClassExists() {
|
||||
$this->assertTrue(class_exists('PhpParser\NodeVisitorAbstract'));
|
||||
$this->assertTrue(class_exists('PHPParser_NodeVisitor_NameResolver'));
|
||||
|
||||
$this->assertFalse(class_exists('PhpParser\FooBar'));
|
||||
$this->assertFalse(class_exists('PHPParser_FooBar'));
|
||||
}
|
||||
}
|
161
vendor/nikic/php-parser/test/PhpParser/Builder/ClassTest.php
vendored
Normal file
161
vendor/nikic/php-parser/test/PhpParser/Builder/ClassTest.php
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class ClassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function createClassBuilder($class) {
|
||||
return new Class_($class);
|
||||
}
|
||||
|
||||
public function testExtendsImplements() {
|
||||
$node = $this->createClassBuilder('SomeLogger')
|
||||
->extend('BaseLogger')
|
||||
->implement('Namespaced\Logger', new Name('SomeInterface'))
|
||||
->implement('\Fully\Qualified', 'namespace\NamespaceRelative')
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Class_('SomeLogger', array(
|
||||
'extends' => new Name('BaseLogger'),
|
||||
'implements' => array(
|
||||
new Name('Namespaced\Logger'),
|
||||
new Name('SomeInterface'),
|
||||
new Name\FullyQualified('Fully\Qualified'),
|
||||
new Name\Relative('NamespaceRelative'),
|
||||
),
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testAbstract() {
|
||||
$node = $this->createClassBuilder('Test')
|
||||
->makeAbstract()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Class_('Test', array(
|
||||
'type' => Stmt\Class_::MODIFIER_ABSTRACT
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testFinal() {
|
||||
$node = $this->createClassBuilder('Test')
|
||||
->makeFinal()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Class_('Test', array(
|
||||
'type' => Stmt\Class_::MODIFIER_FINAL
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testStatementOrder() {
|
||||
$method = new Stmt\ClassMethod('testMethod');
|
||||
$property = new Stmt\Property(
|
||||
Stmt\Class_::MODIFIER_PUBLIC,
|
||||
array(new Stmt\PropertyProperty('testProperty'))
|
||||
);
|
||||
$const = new Stmt\ClassConst(array(
|
||||
new Node\Const_('TEST_CONST', new Node\Scalar\String_('ABC'))
|
||||
));
|
||||
$use = new Stmt\TraitUse(array(new Name('SomeTrait')));
|
||||
|
||||
$node = $this->createClassBuilder('Test')
|
||||
->addStmt($method)
|
||||
->addStmt($property)
|
||||
->addStmts(array($const, $use))
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Class_('Test', array(
|
||||
'stmts' => array($use, $const, $property, $method)
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testDocComment() {
|
||||
$docComment = <<<'DOC'
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
DOC;
|
||||
$class = $this->createClassBuilder('Test')
|
||||
->setDocComment($docComment)
|
||||
->getNode();
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Class_('Test', array(), array(
|
||||
'comments' => array(
|
||||
new Comment\Doc($docComment)
|
||||
)
|
||||
)),
|
||||
$class
|
||||
);
|
||||
|
||||
$class = $this->createClassBuilder('Test')
|
||||
->setDocComment(new Comment\Doc($docComment))
|
||||
->getNode();
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Class_('Test', array(), array(
|
||||
'comments' => array(
|
||||
new Comment\Doc($docComment)
|
||||
)
|
||||
)),
|
||||
$class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Unexpected node of type "Stmt_Echo"
|
||||
*/
|
||||
public function testInvalidStmtError() {
|
||||
$this->createClassBuilder('Test')
|
||||
->addStmt(new Stmt\Echo_(array()))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Doc comment must be a string or an instance of PhpParser\Comment\Doc
|
||||
*/
|
||||
public function testInvalidDocComment() {
|
||||
$this->createClassBuilder('Test')
|
||||
->setDocComment(new Comment('Test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Name cannot be empty
|
||||
*/
|
||||
public function testEmptyName() {
|
||||
$this->createClassBuilder('Test')
|
||||
->extend('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Name must be a string or an instance of PhpParser\Node\Name
|
||||
*/
|
||||
public function testInvalidName() {
|
||||
$this->createClassBuilder('Test')
|
||||
->extend(array('Foo'));
|
||||
}
|
||||
}
|
88
vendor/nikic/php-parser/test/PhpParser/Builder/FunctionTest.php
vendored
Normal file
88
vendor/nikic/php-parser/test/PhpParser/Builder/FunctionTest.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Expr\Print_;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
|
||||
class FunctionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function createFunctionBuilder($name) {
|
||||
return new Function_($name);
|
||||
}
|
||||
|
||||
public function testReturnByRef() {
|
||||
$node = $this->createFunctionBuilder('test')
|
||||
->makeReturnByRef()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Function_('test', array(
|
||||
'byRef' => true
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testParams() {
|
||||
$param1 = new Node\Param('test1');
|
||||
$param2 = new Node\Param('test2');
|
||||
$param3 = new Node\Param('test3');
|
||||
|
||||
$node = $this->createFunctionBuilder('test')
|
||||
->addParam($param1)
|
||||
->addParams(array($param2, $param3))
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Function_('test', array(
|
||||
'params' => array($param1, $param2, $param3)
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testStmts() {
|
||||
$stmt1 = new Print_(new String_('test1'));
|
||||
$stmt2 = new Print_(new String_('test2'));
|
||||
$stmt3 = new Print_(new String_('test3'));
|
||||
|
||||
$node = $this->createFunctionBuilder('test')
|
||||
->addStmt($stmt1)
|
||||
->addStmts(array($stmt2, $stmt3))
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Function_('test', array(
|
||||
'stmts' => array($stmt1, $stmt2, $stmt3)
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testDocComment() {
|
||||
$node = $this->createFunctionBuilder('test')
|
||||
->setDocComment('/** Test */')
|
||||
->getNode();
|
||||
|
||||
$this->assertEquals(new Stmt\Function_('test', array(), array(
|
||||
'comments' => array(new Comment\Doc('/** Test */'))
|
||||
)), $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Expected parameter node, got "Name"
|
||||
*/
|
||||
public function testInvalidParamError() {
|
||||
$this->createFunctionBuilder('test')
|
||||
->addParam(new Node\Name('foo'))
|
||||
;
|
||||
}
|
||||
}
|
105
vendor/nikic/php-parser/test/PhpParser/Builder/InterfaceTest.php
vendored
Normal file
105
vendor/nikic/php-parser/test/PhpParser/Builder/InterfaceTest.php
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Scalar\DNumber;
|
||||
use PhpParser\Comment;
|
||||
|
||||
class InterfaceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @var Interface_ */
|
||||
protected $builder;
|
||||
|
||||
protected function setUp() {
|
||||
$this->builder = new Interface_('Contract');
|
||||
}
|
||||
|
||||
private function dump($node) {
|
||||
$pp = new \PhpParser\PrettyPrinter\Standard;
|
||||
return $pp->prettyPrint(array($node));
|
||||
}
|
||||
|
||||
public function testEmpty() {
|
||||
$contract = $this->builder->getNode();
|
||||
$this->assertInstanceOf('PhpParser\Node\Stmt\Interface_', $contract);
|
||||
$this->assertSame('Contract', $contract->name);
|
||||
}
|
||||
|
||||
public function testExtending() {
|
||||
$contract = $this->builder->extend('Space\Root1', 'Root2')->getNode();
|
||||
$this->assertEquals(
|
||||
new Stmt\Interface_('Contract', array(
|
||||
'extends' => array(
|
||||
new Node\Name('Space\Root1'),
|
||||
new Node\Name('Root2')
|
||||
),
|
||||
)), $contract
|
||||
);
|
||||
}
|
||||
|
||||
public function testAddMethod() {
|
||||
$method = new Stmt\ClassMethod('doSomething');
|
||||
$contract = $this->builder->addStmt($method)->getNode();
|
||||
$this->assertSame(array($method), $contract->stmts);
|
||||
}
|
||||
|
||||
public function testAddConst() {
|
||||
$const = new Stmt\ClassConst(array(
|
||||
new Node\Const_('SPEED_OF_LIGHT', new DNumber(299792458.0))
|
||||
));
|
||||
$contract = $this->builder->addStmt($const)->getNode();
|
||||
$this->assertSame(299792458.0, $contract->stmts[0]->consts[0]->value->value);
|
||||
}
|
||||
|
||||
public function testOrder() {
|
||||
$const = new Stmt\ClassConst(array(
|
||||
new Node\Const_('SPEED_OF_LIGHT', new DNumber(299792458))
|
||||
));
|
||||
$method = new Stmt\ClassMethod('doSomething');
|
||||
$contract = $this->builder
|
||||
->addStmt($method)
|
||||
->addStmt($const)
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertInstanceOf('PhpParser\Node\Stmt\ClassConst', $contract->stmts[0]);
|
||||
$this->assertInstanceOf('PhpParser\Node\Stmt\ClassMethod', $contract->stmts[1]);
|
||||
}
|
||||
|
||||
public function testDocComment() {
|
||||
$node = $this->builder
|
||||
->setDocComment('/** Test */')
|
||||
->getNode();
|
||||
|
||||
$this->assertEquals(new Stmt\Interface_('Contract', array(), array(
|
||||
'comments' => array(new Comment\Doc('/** Test */'))
|
||||
)), $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Unexpected node of type "Stmt_PropertyProperty"
|
||||
*/
|
||||
public function testInvalidStmtError() {
|
||||
$this->builder->addStmt(new Stmt\PropertyProperty('invalid'));
|
||||
}
|
||||
|
||||
public function testFullFunctional() {
|
||||
$const = new Stmt\ClassConst(array(
|
||||
new Node\Const_('SPEED_OF_LIGHT', new DNumber(299792458))
|
||||
));
|
||||
$method = new Stmt\ClassMethod('doSomething');
|
||||
$contract = $this->builder
|
||||
->addStmt($method)
|
||||
->addStmt($const)
|
||||
->getNode()
|
||||
;
|
||||
|
||||
eval($this->dump($contract));
|
||||
|
||||
$this->assertTrue(interface_exists('Contract', false));
|
||||
}
|
||||
}
|
||||
|
154
vendor/nikic/php-parser/test/PhpParser/Builder/MethodTest.php
vendored
Normal file
154
vendor/nikic/php-parser/test/PhpParser/Builder/MethodTest.php
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Print_;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Comment;
|
||||
|
||||
class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function createMethodBuilder($name) {
|
||||
return new Method($name);
|
||||
}
|
||||
|
||||
public function testModifiers() {
|
||||
$node = $this->createMethodBuilder('test')
|
||||
->makePublic()
|
||||
->makeAbstract()
|
||||
->makeStatic()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
'type' => Stmt\Class_::MODIFIER_PUBLIC
|
||||
| Stmt\Class_::MODIFIER_ABSTRACT
|
||||
| Stmt\Class_::MODIFIER_STATIC,
|
||||
'stmts' => null,
|
||||
)),
|
||||
$node
|
||||
);
|
||||
|
||||
$node = $this->createMethodBuilder('test')
|
||||
->makeProtected()
|
||||
->makeFinal()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
'type' => Stmt\Class_::MODIFIER_PROTECTED
|
||||
| Stmt\Class_::MODIFIER_FINAL
|
||||
)),
|
||||
$node
|
||||
);
|
||||
|
||||
$node = $this->createMethodBuilder('test')
|
||||
->makePrivate()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
'type' => Stmt\Class_::MODIFIER_PRIVATE
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testReturnByRef() {
|
||||
$node = $this->createMethodBuilder('test')
|
||||
->makeReturnByRef()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
'byRef' => true
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testParams() {
|
||||
$param1 = new Node\Param('test1');
|
||||
$param2 = new Node\Param('test2');
|
||||
$param3 = new Node\Param('test3');
|
||||
|
||||
$node = $this->createMethodBuilder('test')
|
||||
->addParam($param1)
|
||||
->addParams(array($param2, $param3))
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
'params' => array($param1, $param2, $param3)
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testStmts() {
|
||||
$stmt1 = new Print_(new String_('test1'));
|
||||
$stmt2 = new Print_(new String_('test2'));
|
||||
$stmt3 = new Print_(new String_('test3'));
|
||||
|
||||
$node = $this->createMethodBuilder('test')
|
||||
->addStmt($stmt1)
|
||||
->addStmts(array($stmt2, $stmt3))
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
'stmts' => array($stmt1, $stmt2, $stmt3)
|
||||
)),
|
||||
$node
|
||||
);
|
||||
}
|
||||
public function testDocComment() {
|
||||
$node = $this->createMethodBuilder('test')
|
||||
->setDocComment('/** Test */')
|
||||
->getNode();
|
||||
|
||||
$this->assertEquals(new Stmt\ClassMethod('test', array(), array(
|
||||
'comments' => array(new Comment\Doc('/** Test */'))
|
||||
)), $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot add statements to an abstract method
|
||||
*/
|
||||
public function testAddStmtToAbstractMethodError() {
|
||||
$this->createMethodBuilder('test')
|
||||
->makeAbstract()
|
||||
->addStmt(new Print_(new String_('test')))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot make method with statements abstract
|
||||
*/
|
||||
public function testMakeMethodWithStmtsAbstractError() {
|
||||
$this->createMethodBuilder('test')
|
||||
->addStmt(new Print_(new String_('test')))
|
||||
->makeAbstract()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Expected parameter node, got "Name"
|
||||
*/
|
||||
public function testInvalidParamError() {
|
||||
$this->createMethodBuilder('test')
|
||||
->addParam(new Node\Name('foo'))
|
||||
;
|
||||
}
|
||||
}
|
41
vendor/nikic/php-parser/test/PhpParser/Builder/NamespaceTest.php
vendored
Normal file
41
vendor/nikic/php-parser/test/PhpParser/Builder/NamespaceTest.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class NamespaceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function createNamespaceBuilder($fqn) {
|
||||
return new Namespace_($fqn);
|
||||
}
|
||||
|
||||
public function testCreation() {
|
||||
$stmt1 = new Stmt\Class_('SomeClass');
|
||||
$stmt2 = new Stmt\Interface_('SomeInterface');
|
||||
$stmt3 = new Stmt\Function_('someFunction');
|
||||
$expected = new Stmt\Namespace_(
|
||||
new Node\Name('Name\Space'),
|
||||
array($stmt1, $stmt2, $stmt3)
|
||||
);
|
||||
|
||||
$node = $this->createNamespaceBuilder('Name\Space')
|
||||
->addStmt($stmt1)
|
||||
->addStmts(array($stmt2, $stmt3))
|
||||
->getNode()
|
||||
;
|
||||
$this->assertEquals($expected, $node);
|
||||
|
||||
$node = $this->createNamespaceBuilder(new Node\Name(array('Name', 'Space')))
|
||||
->addStmts(array($stmt1, $stmt2))
|
||||
->addStmt($stmt3)
|
||||
->getNode()
|
||||
;
|
||||
$this->assertEquals($expected, $node);
|
||||
|
||||
$node = $this->createNamespaceBuilder(null)->getNode();
|
||||
$this->assertNull($node->name);
|
||||
$this->assertEmpty($node->stmts);
|
||||
}
|
||||
}
|
124
vendor/nikic/php-parser/test/PhpParser/Builder/ParamTest.php
vendored
Normal file
124
vendor/nikic/php-parser/test/PhpParser/Builder/ParamTest.php
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar;
|
||||
|
||||
class ParamTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function createParamBuilder($name) {
|
||||
return new Param($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestDefaultValues
|
||||
*/
|
||||
public function testDefaultValues($value, $expectedValueNode) {
|
||||
$node = $this->createParamBuilder('test')
|
||||
->setDefault($value)
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals($expectedValueNode, $node->default);
|
||||
}
|
||||
|
||||
public function provideTestDefaultValues() {
|
||||
return array(
|
||||
array(
|
||||
null,
|
||||
new Expr\ConstFetch(new Node\Name('null'))
|
||||
),
|
||||
array(
|
||||
true,
|
||||
new Expr\ConstFetch(new Node\Name('true'))
|
||||
),
|
||||
array(
|
||||
false,
|
||||
new Expr\ConstFetch(new Node\Name('false'))
|
||||
),
|
||||
array(
|
||||
31415,
|
||||
new Scalar\LNumber(31415)
|
||||
),
|
||||
array(
|
||||
3.1415,
|
||||
new Scalar\DNumber(3.1415)
|
||||
),
|
||||
array(
|
||||
'Hallo World',
|
||||
new Scalar\String_('Hallo World')
|
||||
),
|
||||
array(
|
||||
array(1, 2, 3),
|
||||
new Expr\Array_(array(
|
||||
new Expr\ArrayItem(new Scalar\LNumber(1)),
|
||||
new Expr\ArrayItem(new Scalar\LNumber(2)),
|
||||
new Expr\ArrayItem(new Scalar\LNumber(3)),
|
||||
))
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar', 'bar' => 'foo'),
|
||||
new Expr\Array_(array(
|
||||
new Expr\ArrayItem(
|
||||
new Scalar\String_('bar'),
|
||||
new Scalar\String_('foo')
|
||||
),
|
||||
new Expr\ArrayItem(
|
||||
new Scalar\String_('foo'),
|
||||
new Scalar\String_('bar')
|
||||
),
|
||||
))
|
||||
),
|
||||
array(
|
||||
new Scalar\MagicConst\Dir,
|
||||
new Scalar\MagicConst\Dir
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testTypeHints() {
|
||||
$node = $this->createParamBuilder('test')
|
||||
->setTypeHint('array')
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Node\Param('test', null, 'array'),
|
||||
$node
|
||||
);
|
||||
|
||||
$node = $this->createParamBuilder('test')
|
||||
->setTypeHint('callable')
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Node\Param('test', null, 'callable'),
|
||||
$node
|
||||
);
|
||||
|
||||
$node = $this->createParamBuilder('test')
|
||||
->setTypeHint('Some\Class')
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Node\Param('test', null, new Node\Name('Some\Class')),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testByRef() {
|
||||
$node = $this->createParamBuilder('test')
|
||||
->makeByRef()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Node\Param('test', null, null, true),
|
||||
$node
|
||||
);
|
||||
}
|
||||
}
|
147
vendor/nikic/php-parser/test/PhpParser/Builder/PropertyTest.php
vendored
Normal file
147
vendor/nikic/php-parser/test/PhpParser/Builder/PropertyTest.php
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar;
|
||||
use PhpParser\Comment;
|
||||
|
||||
class PropertyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function createPropertyBuilder($name) {
|
||||
return new Property($name);
|
||||
}
|
||||
|
||||
public function testModifiers() {
|
||||
$node = $this->createPropertyBuilder('test')
|
||||
->makePrivate()
|
||||
->makeStatic()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Property(
|
||||
Stmt\Class_::MODIFIER_PRIVATE
|
||||
| Stmt\Class_::MODIFIER_STATIC,
|
||||
array(
|
||||
new Stmt\PropertyProperty('test')
|
||||
)
|
||||
),
|
||||
$node
|
||||
);
|
||||
|
||||
$node = $this->createPropertyBuilder('test')
|
||||
->makeProtected()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Property(
|
||||
Stmt\Class_::MODIFIER_PROTECTED,
|
||||
array(
|
||||
new Stmt\PropertyProperty('test')
|
||||
)
|
||||
),
|
||||
$node
|
||||
);
|
||||
|
||||
$node = $this->createPropertyBuilder('test')
|
||||
->makePublic()
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\Property(
|
||||
Stmt\Class_::MODIFIER_PUBLIC,
|
||||
array(
|
||||
new Stmt\PropertyProperty('test')
|
||||
)
|
||||
),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testDocComment() {
|
||||
$node = $this->createPropertyBuilder('test')
|
||||
->setDocComment('/** Test */')
|
||||
->getNode();
|
||||
|
||||
$this->assertEquals(new Stmt\Property(
|
||||
Stmt\Class_::MODIFIER_PUBLIC,
|
||||
array(
|
||||
new Stmt\PropertyProperty('test')
|
||||
),
|
||||
array(
|
||||
'comments' => array(new Comment\Doc('/** Test */'))
|
||||
)
|
||||
), $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestDefaultValues
|
||||
*/
|
||||
public function testDefaultValues($value, $expectedValueNode) {
|
||||
$node = $this->createPropertyBuilder('test')
|
||||
->setDefault($value)
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals($expectedValueNode, $node->props[0]->default);
|
||||
}
|
||||
|
||||
public function provideTestDefaultValues() {
|
||||
return array(
|
||||
array(
|
||||
null,
|
||||
new Expr\ConstFetch(new Name('null'))
|
||||
),
|
||||
array(
|
||||
true,
|
||||
new Expr\ConstFetch(new Name('true'))
|
||||
),
|
||||
array(
|
||||
false,
|
||||
new Expr\ConstFetch(new Name('false'))
|
||||
),
|
||||
array(
|
||||
31415,
|
||||
new Scalar\LNumber(31415)
|
||||
),
|
||||
array(
|
||||
3.1415,
|
||||
new Scalar\DNumber(3.1415)
|
||||
),
|
||||
array(
|
||||
'Hallo World',
|
||||
new Scalar\String_('Hallo World')
|
||||
),
|
||||
array(
|
||||
array(1, 2, 3),
|
||||
new Expr\Array_(array(
|
||||
new Expr\ArrayItem(new Scalar\LNumber(1)),
|
||||
new Expr\ArrayItem(new Scalar\LNumber(2)),
|
||||
new Expr\ArrayItem(new Scalar\LNumber(3)),
|
||||
))
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar', 'bar' => 'foo'),
|
||||
new Expr\Array_(array(
|
||||
new Expr\ArrayItem(
|
||||
new Scalar\String_('bar'),
|
||||
new Scalar\String_('foo')
|
||||
),
|
||||
new Expr\ArrayItem(
|
||||
new Scalar\String_('foo'),
|
||||
new Scalar\String_('bar')
|
||||
),
|
||||
))
|
||||
),
|
||||
array(
|
||||
new Scalar\MagicConst\Dir,
|
||||
new Scalar\MagicConst\Dir
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
47
vendor/nikic/php-parser/test/PhpParser/Builder/TraitTest.php
vendored
Normal file
47
vendor/nikic/php-parser/test/PhpParser/Builder/TraitTest.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class TraitTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function createTraitBuilder($class) {
|
||||
return new Trait_($class);
|
||||
}
|
||||
|
||||
public function testStmtAddition() {
|
||||
$method1 = new Stmt\ClassMethod('test1');
|
||||
$method2 = new Stmt\ClassMethod('test2');
|
||||
$method3 = new Stmt\ClassMethod('test3');
|
||||
$prop = new Stmt\Property(Stmt\Class_::MODIFIER_PUBLIC, array(
|
||||
new Stmt\PropertyProperty('test')
|
||||
));
|
||||
$trait = $this->createTraitBuilder('TestTrait')
|
||||
->setDocComment('/** Nice trait */')
|
||||
->addStmt($method1)
|
||||
->addStmts(array($method2, $method3))
|
||||
->addStmt($prop)
|
||||
->getNode();
|
||||
$this->assertEquals(new Stmt\Trait_('TestTrait', array(
|
||||
$prop, $method1, $method2, $method3
|
||||
), array(
|
||||
'comments' => array(
|
||||
new Comment\Doc('/** Nice trait */')
|
||||
)
|
||||
)), $trait);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Unexpected node of type "Stmt_Echo"
|
||||
*/
|
||||
public function testInvalidStmtError() {
|
||||
$this->createTraitBuilder('Test')
|
||||
->addStmt(new Stmt\Echo_(array()))
|
||||
;
|
||||
}
|
||||
}
|
35
vendor/nikic/php-parser/test/PhpParser/Builder/UseTest.php
vendored
Normal file
35
vendor/nikic/php-parser/test/PhpParser/Builder/UseTest.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use PhpParser\Builder;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class UseTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function createUseBuilder($name, $type = Stmt\Use_::TYPE_NORMAL) {
|
||||
return new Builder\Use_($name, $type);
|
||||
}
|
||||
|
||||
public function testCreation() {
|
||||
$node = $this->createUseBuilder('Foo\Bar')->getNode();
|
||||
$this->assertEquals(new Stmt\Use_(array(
|
||||
new Stmt\UseUse(new Name('Foo\Bar'), 'Bar')
|
||||
)), $node);
|
||||
|
||||
$node = $this->createUseBuilder(new Name('Foo\Bar'))->as('XYZ')->getNode();
|
||||
$this->assertEquals(new Stmt\Use_(array(
|
||||
new Stmt\UseUse(new Name('Foo\Bar'), 'XYZ')
|
||||
)), $node);
|
||||
|
||||
$node = $this->createUseBuilder('foo\bar', Stmt\Use_::TYPE_FUNCTION)->as('foo')->getNode();
|
||||
$this->assertEquals(new Stmt\Use_(array(
|
||||
new Stmt\UseUse(new Name('foo\bar'), 'foo')
|
||||
), Stmt\Use_::TYPE_FUNCTION), $node);
|
||||
}
|
||||
|
||||
public function testNonExistingMethod() {
|
||||
$this->setExpectedException('LogicException', 'Method "foo" does not exist');
|
||||
$builder = $this->createUseBuilder('Test');
|
||||
$builder->foo();
|
||||
}
|
||||
}
|
108
vendor/nikic/php-parser/test/PhpParser/BuilderFactoryTest.php
vendored
Normal file
108
vendor/nikic/php-parser/test/PhpParser/BuilderFactoryTest.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
class BuilderFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestFactory
|
||||
*/
|
||||
public function testFactory($methodName, $className) {
|
||||
$factory = new BuilderFactory;
|
||||
$this->assertInstanceOf($className, $factory->$methodName('test'));
|
||||
}
|
||||
|
||||
public function provideTestFactory() {
|
||||
return array(
|
||||
array('namespace', 'PhpParser\Builder\Namespace_'),
|
||||
array('class', 'PhpParser\Builder\Class_'),
|
||||
array('interface', 'PhpParser\Builder\Interface_'),
|
||||
array('trait', 'PhpParser\Builder\Trait_'),
|
||||
array('method', 'PhpParser\Builder\Method'),
|
||||
array('function', 'PhpParser\Builder\Function_'),
|
||||
array('property', 'PhpParser\Builder\Property'),
|
||||
array('param', 'PhpParser\Builder\Param'),
|
||||
array('use', 'PhpParser\Builder\Use_'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testNonExistingMethod() {
|
||||
$this->setExpectedException('LogicException', 'Method "foo" does not exist');
|
||||
$factory = new BuilderFactory();
|
||||
$factory->foo();
|
||||
}
|
||||
|
||||
public function testIntegration() {
|
||||
$factory = new BuilderFactory;
|
||||
$node = $factory->namespace('Name\Space')
|
||||
->addStmt($factory->use('Foo\Bar\SomeOtherClass'))
|
||||
->addStmt($factory->use('Foo\Bar')->as('A'))
|
||||
->addStmt($factory
|
||||
->class('SomeClass')
|
||||
->extend('SomeOtherClass')
|
||||
->implement('A\Few', '\Interfaces')
|
||||
->makeAbstract()
|
||||
|
||||
->addStmt($factory->method('firstMethod'))
|
||||
|
||||
->addStmt($factory->method('someMethod')
|
||||
->makePublic()
|
||||
->makeAbstract()
|
||||
->addParam($factory->param('someParam')->setTypeHint('SomeClass'))
|
||||
->setDocComment('/**
|
||||
* This method does something.
|
||||
*
|
||||
* @param SomeClass And takes a parameter
|
||||
*/'))
|
||||
|
||||
->addStmt($factory->method('anotherMethod')
|
||||
->makeProtected()
|
||||
->addParam($factory->param('someParam')->setDefault('test'))
|
||||
->addStmt(new Expr\Print_(new Expr\Variable('someParam'))))
|
||||
|
||||
->addStmt($factory->property('someProperty')->makeProtected())
|
||||
->addStmt($factory->property('anotherProperty')
|
||||
->makePrivate()
|
||||
->setDefault(array(1, 2, 3))))
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$expected = <<<'EOC'
|
||||
<?php
|
||||
|
||||
namespace Name\Space;
|
||||
|
||||
use Foo\Bar\SomeOtherClass;
|
||||
use Foo\Bar as A;
|
||||
abstract class SomeClass extends SomeOtherClass implements A\Few, \Interfaces
|
||||
{
|
||||
protected $someProperty;
|
||||
private $anotherProperty = array(1, 2, 3);
|
||||
function firstMethod()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* This method does something.
|
||||
*
|
||||
* @param SomeClass And takes a parameter
|
||||
*/
|
||||
public abstract function someMethod(SomeClass $someParam);
|
||||
protected function anotherMethod($someParam = 'test')
|
||||
{
|
||||
print $someParam;
|
||||
}
|
||||
}
|
||||
EOC;
|
||||
|
||||
$stmts = array($node);
|
||||
$prettyPrinter = new PrettyPrinter\Standard();
|
||||
$generated = $prettyPrinter->prettyPrintFile($stmts);
|
||||
|
||||
$this->assertEquals(
|
||||
str_replace("\r\n", "\n", $expected),
|
||||
str_replace("\r\n", "\n", $generated)
|
||||
);
|
||||
}
|
||||
}
|
53
vendor/nikic/php-parser/test/PhpParser/CodeTestAbstract.php
vendored
Normal file
53
vendor/nikic/php-parser/test/PhpParser/CodeTestAbstract.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
abstract class CodeTestAbstract extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function getTests($directory, $fileExtension) {
|
||||
$it = new \RecursiveDirectoryIterator($directory);
|
||||
$it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::LEAVES_ONLY);
|
||||
$it = new \RegexIterator($it, '(\.' . preg_quote($fileExtension) . '$)');
|
||||
|
||||
$tests = array();
|
||||
foreach ($it as $file) {
|
||||
$fileName = realpath($file->getPathname());
|
||||
$fileContents = file_get_contents($fileName);
|
||||
|
||||
// evaluate @@{expr}@@ expressions
|
||||
$fileContents = preg_replace_callback(
|
||||
'/@@\{(.*?)\}@@/',
|
||||
array($this, 'evalCallback'),
|
||||
$fileContents
|
||||
);
|
||||
|
||||
// parse sections
|
||||
$parts = array_map('trim', explode('-----', $fileContents));
|
||||
|
||||
// first part is the name
|
||||
$name = array_shift($parts) . ' (' . $fileName . ')';
|
||||
|
||||
// multiple sections possible with always two forming a pair
|
||||
foreach (array_chunk($parts, 2) as $chunk) {
|
||||
$tests[] = array($name, $chunk[0], $chunk[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
protected function evalCallback($matches) {
|
||||
return eval('return ' . $matches[1] . ';');
|
||||
}
|
||||
|
||||
protected function canonicalize($str) {
|
||||
// trim from both sides
|
||||
$str = trim($str);
|
||||
|
||||
// normalize EOL to \n
|
||||
$str = str_replace(array("\r\n", "\r"), "\n", $str);
|
||||
|
||||
// trim right side of all lines
|
||||
return implode("\n", array_map('rtrim', explode("\n", $str)));
|
||||
}
|
||||
}
|
71
vendor/nikic/php-parser/test/PhpParser/CommentTest.php
vendored
Normal file
71
vendor/nikic/php-parser/test/PhpParser/CommentTest.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class CommentTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetSet() {
|
||||
$comment = new Comment('/* Some comment */', 1);
|
||||
|
||||
$this->assertSame('/* Some comment */', $comment->getText());
|
||||
$this->assertSame('/* Some comment */', (string) $comment);
|
||||
$this->assertSame(1, $comment->getLine());
|
||||
|
||||
$comment->setText('/* Some other comment */');
|
||||
$comment->setLine(10);
|
||||
|
||||
$this->assertSame('/* Some other comment */', $comment->getText());
|
||||
$this->assertSame('/* Some other comment */', (string) $comment);
|
||||
$this->assertSame(10, $comment->getLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestReformatting
|
||||
*/
|
||||
public function testReformatting($commentText, $reformattedText) {
|
||||
$comment = new Comment($commentText);
|
||||
$this->assertSame($reformattedText, $comment->getReformattedText());
|
||||
}
|
||||
|
||||
public function provideTestReformatting() {
|
||||
return array(
|
||||
array('// Some text' . "\n", '// Some text'),
|
||||
array('/* Some text */', '/* Some text */'),
|
||||
array(
|
||||
'/**
|
||||
* Some text.
|
||||
* Some more text.
|
||||
*/',
|
||||
'/**
|
||||
* Some text.
|
||||
* Some more text.
|
||||
*/'
|
||||
),
|
||||
array(
|
||||
'/*
|
||||
Some text.
|
||||
Some more text.
|
||||
*/',
|
||||
'/*
|
||||
Some text.
|
||||
Some more text.
|
||||
*/'
|
||||
),
|
||||
array(
|
||||
'/* Some text.
|
||||
More text.
|
||||
Even more text. */',
|
||||
'/* Some text.
|
||||
More text.
|
||||
Even more text. */'
|
||||
),
|
||||
// invalid comment -> no reformatting
|
||||
array(
|
||||
'hallo
|
||||
world',
|
||||
'hallo
|
||||
world',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
112
vendor/nikic/php-parser/test/PhpParser/ErrorTest.php
vendored
Normal file
112
vendor/nikic/php-parser/test/PhpParser/ErrorTest.php
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class ErrorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstruct() {
|
||||
$attributes = array(
|
||||
'startLine' => 10,
|
||||
'endLine' => 11,
|
||||
);
|
||||
$error = new Error('Some error', $attributes);
|
||||
|
||||
$this->assertSame('Some error', $error->getRawMessage());
|
||||
$this->assertSame($attributes, $error->getAttributes());
|
||||
$this->assertSame(10, $error->getStartLine());
|
||||
$this->assertSame(11, $error->getEndLine());
|
||||
$this->assertSame(10, $error->getRawLine());
|
||||
$this->assertSame('Some error on line 10', $error->getMessage());
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
*/
|
||||
public function testSetMessageAndLine(Error $error) {
|
||||
$error->setRawMessage('Some other error');
|
||||
$this->assertSame('Some other error', $error->getRawMessage());
|
||||
|
||||
$error->setStartLine(15);
|
||||
$this->assertSame(15, $error->getStartLine());
|
||||
$this->assertSame('Some other error on line 15', $error->getMessage());
|
||||
|
||||
$error->setRawLine(17);
|
||||
$this->assertSame(17, $error->getRawLine());
|
||||
$this->assertSame('Some other error on line 17', $error->getMessage());
|
||||
}
|
||||
|
||||
public function testUnknownLine() {
|
||||
$error = new Error('Some error');
|
||||
|
||||
$this->assertSame(-1, $error->getStartLine());
|
||||
$this->assertSame(-1, $error->getEndLine());
|
||||
$this->assertSame(-1, $error->getRawLine());
|
||||
$this->assertSame('Some error on unknown line', $error->getMessage());
|
||||
}
|
||||
|
||||
/** @dataProvider provideTestColumnInfo */
|
||||
public function testColumnInfo($code, $startPos, $endPos, $startColumn, $endColumn) {
|
||||
$error = new Error('Some error', array(
|
||||
'startFilePos' => $startPos,
|
||||
'endFilePos' => $endPos,
|
||||
));
|
||||
|
||||
$this->assertSame(true, $error->hasColumnInfo());
|
||||
$this->assertSame($startColumn, $error->getStartColumn($code));
|
||||
$this->assertSame($endColumn, $error->getEndColumn($code));
|
||||
|
||||
}
|
||||
|
||||
public function provideTestColumnInfo() {
|
||||
return array(
|
||||
// Error at "bar"
|
||||
array("<?php foo bar baz", 10, 12, 11, 13),
|
||||
array("<?php\nfoo bar baz", 10, 12, 5, 7),
|
||||
array("<?php foo\nbar baz", 10, 12, 1, 3),
|
||||
array("<?php foo bar\nbaz", 10, 12, 11, 13),
|
||||
array("<?php\r\nfoo bar baz", 11, 13, 5, 7),
|
||||
// Error at "baz"
|
||||
array("<?php foo bar baz", 14, 16, 15, 17),
|
||||
array("<?php foo bar\nbaz", 14, 16, 1, 3),
|
||||
// Error at string literal
|
||||
array("<?php foo 'bar\nbaz' xyz", 10, 18, 11, 4),
|
||||
array("<?php\nfoo 'bar\nbaz' xyz", 10, 18, 5, 4),
|
||||
array("<?php foo\n'\nbarbaz\n'\nxyz", 10, 19, 1, 1),
|
||||
// Error over full string
|
||||
array("<?php", 0, 4, 1, 5),
|
||||
array("<?\nphp", 0, 5, 1, 3),
|
||||
);
|
||||
}
|
||||
|
||||
public function testNoColumnInfo() {
|
||||
$error = new Error('Some error', 3);
|
||||
|
||||
$this->assertSame(false, $error->hasColumnInfo());
|
||||
try {
|
||||
$error->getStartColumn('');
|
||||
$this->fail('Expected RuntimeException');
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->assertSame('Error does not have column information', $e->getMessage());
|
||||
}
|
||||
try {
|
||||
$error->getEndColumn('');
|
||||
$this->fail('Expected RuntimeException');
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->assertSame('Error does not have column information', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage Invalid position information
|
||||
*/
|
||||
public function testInvalidPosInfo() {
|
||||
$error = new Error('Some error', array(
|
||||
'startFilePos' => 10,
|
||||
'endFilePos' => 11,
|
||||
));
|
||||
$error->getStartColumn('code');
|
||||
}
|
||||
}
|
133
vendor/nikic/php-parser/test/PhpParser/Lexer/EmulativeTest.php
vendored
Normal file
133
vendor/nikic/php-parser/test/PhpParser/Lexer/EmulativeTest.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Lexer;
|
||||
|
||||
use PhpParser\LexerTest;
|
||||
use PhpParser\Parser;
|
||||
|
||||
require_once __DIR__ . '/../LexerTest.php';
|
||||
|
||||
class EmulativeTest extends LexerTest
|
||||
{
|
||||
protected function getLexer(array $options = array()) {
|
||||
return new Emulative($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestReplaceKeywords
|
||||
*/
|
||||
public function testReplaceKeywords($keyword, $expectedToken) {
|
||||
$lexer = $this->getLexer();
|
||||
$lexer->startLexing('<?php ' . $keyword);
|
||||
|
||||
$this->assertSame($expectedToken, $lexer->getNextToken());
|
||||
$this->assertSame(0, $lexer->getNextToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestReplaceKeywords
|
||||
*/
|
||||
public function testNoReplaceKeywordsAfterObjectOperator($keyword) {
|
||||
$lexer = $this->getLexer();
|
||||
$lexer->startLexing('<?php ->' . $keyword);
|
||||
|
||||
$this->assertSame(Parser::T_OBJECT_OPERATOR, $lexer->getNextToken());
|
||||
$this->assertSame(Parser::T_STRING, $lexer->getNextToken());
|
||||
$this->assertSame(0, $lexer->getNextToken());
|
||||
}
|
||||
|
||||
public function provideTestReplaceKeywords() {
|
||||
return array(
|
||||
// PHP 5.5
|
||||
array('finally', Parser::T_FINALLY),
|
||||
array('yield', Parser::T_YIELD),
|
||||
|
||||
// PHP 5.4
|
||||
array('callable', Parser::T_CALLABLE),
|
||||
array('insteadof', Parser::T_INSTEADOF),
|
||||
array('trait', Parser::T_TRAIT),
|
||||
array('__TRAIT__', Parser::T_TRAIT_C),
|
||||
|
||||
// PHP 5.3
|
||||
array('__DIR__', Parser::T_DIR),
|
||||
array('goto', Parser::T_GOTO),
|
||||
array('namespace', Parser::T_NAMESPACE),
|
||||
array('__NAMESPACE__', Parser::T_NS_C),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestLexNewFeatures
|
||||
*/
|
||||
public function testLexNewFeatures($code, array $expectedTokens) {
|
||||
$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);
|
||||
}
|
||||
$this->assertSame(0, $lexer->getNextToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestLexNewFeatures
|
||||
*/
|
||||
public function testLeaveStuffAloneInStrings($code) {
|
||||
$stringifiedToken = '"' . addcslashes($code, '"\\') . '"';
|
||||
|
||||
$lexer = $this->getLexer();
|
||||
$lexer->startLexing('<?php ' . $stringifiedToken);
|
||||
|
||||
$this->assertSame(Parser::T_CONSTANT_ENCAPSED_STRING, $lexer->getNextToken($text));
|
||||
$this->assertSame($stringifiedToken, $text);
|
||||
$this->assertSame(0, $lexer->getNextToken());
|
||||
}
|
||||
|
||||
public function provideTestLexNewFeatures() {
|
||||
return array(
|
||||
array('yield from', array(
|
||||
array(Parser::T_YIELD_FROM, 'yield from'),
|
||||
)),
|
||||
array("yield\r\nfrom", array(
|
||||
array(Parser::T_YIELD_FROM, "yield\r\nfrom"),
|
||||
)),
|
||||
array('...', array(
|
||||
array(Parser::T_ELLIPSIS, '...'),
|
||||
)),
|
||||
array('**', array(
|
||||
array(Parser::T_POW, '**'),
|
||||
)),
|
||||
array('**=', array(
|
||||
array(Parser::T_POW_EQUAL, '**='),
|
||||
)),
|
||||
array('??', array(
|
||||
array(Parser::T_COALESCE, '??'),
|
||||
)),
|
||||
array('<=>', array(
|
||||
array(Parser::T_SPACESHIP, '<=>'),
|
||||
)),
|
||||
array('0b1010110', array(
|
||||
array(Parser::T_LNUMBER, '0b1010110'),
|
||||
)),
|
||||
array('0b1011010101001010110101010010101011010101010101101011001110111100', array(
|
||||
array(Parser::T_DNUMBER, '0b1011010101001010110101010010101011010101010101101011001110111100'),
|
||||
)),
|
||||
array('\\', array(
|
||||
array(Parser::T_NS_SEPARATOR, '\\'),
|
||||
)),
|
||||
array("<<<'NOWDOC'\nNOWDOC;\n", array(
|
||||
array(Parser::T_START_HEREDOC, "<<<'NOWDOC'\n"),
|
||||
array(Parser::T_END_HEREDOC, 'NOWDOC'),
|
||||
array(ord(';'), ';'),
|
||||
)),
|
||||
array("<<<'NOWDOC'\nFoobar\nNOWDOC;\n", array(
|
||||
array(Parser::T_START_HEREDOC, "<<<'NOWDOC'\n"),
|
||||
array(Parser::T_ENCAPSED_AND_WHITESPACE, "Foobar\n"),
|
||||
array(Parser::T_END_HEREDOC, 'NOWDOC'),
|
||||
array(ord(';'), ';'),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
246
vendor/nikic/php-parser/test/PhpParser/LexerTest.php
vendored
Normal file
246
vendor/nikic/php-parser/test/PhpParser/LexerTest.php
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class LexerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/* To allow overwriting in parent class */
|
||||
protected function getLexer(array $options = array()) {
|
||||
return new Lexer($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestError
|
||||
*/
|
||||
public function testError($code, $message) {
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('HHVM does not throw warnings from token_get_all()');
|
||||
}
|
||||
|
||||
$lexer = $this->getLexer();
|
||||
try {
|
||||
$lexer->startLexing($code);
|
||||
} catch (Error $e) {
|
||||
$this->assertSame($message, $e->getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail('Expected PhpParser\Error');
|
||||
}
|
||||
|
||||
public function provideTestError() {
|
||||
return array(
|
||||
array('<?php /*', 'Unterminated comment on line 1'),
|
||||
array('<?php ' . "\1", 'Unexpected character "' . "\1" . '" (ASCII 1) on unknown line'),
|
||||
array('<?php ' . "\0", 'Unexpected null byte on unknown line'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestLex
|
||||
*/
|
||||
public function testLex($code, $options, $tokens) {
|
||||
$lexer = $this->getLexer($options);
|
||||
$lexer->startLexing($code);
|
||||
while ($id = $lexer->getNextToken($value, $startAttributes, $endAttributes)) {
|
||||
$token = array_shift($tokens);
|
||||
|
||||
$this->assertSame($token[0], $id);
|
||||
$this->assertSame($token[1], $value);
|
||||
$this->assertEquals($token[2], $startAttributes);
|
||||
$this->assertEquals($token[3], $endAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
public function provideTestLex() {
|
||||
return array(
|
||||
// tests conversion of closing PHP tag and drop of whitespace and opening tags
|
||||
array(
|
||||
'<?php tokens ?>plaintext',
|
||||
array(),
|
||||
array(
|
||||
array(
|
||||
Parser::T_STRING, 'tokens',
|
||||
array('startLine' => 1), array('endLine' => 1)
|
||||
),
|
||||
array(
|
||||
ord(';'), '?>',
|
||||
array('startLine' => 1), array('endLine' => 1)
|
||||
),
|
||||
array(
|
||||
Parser::T_INLINE_HTML, 'plaintext',
|
||||
array('startLine' => 1), array('endLine' => 1)
|
||||
),
|
||||
)
|
||||
),
|
||||
// tests line numbers
|
||||
array(
|
||||
'<?php' . "\n" . '$ token /** doc' . "\n" . 'comment */ $',
|
||||
array(),
|
||||
array(
|
||||
array(
|
||||
ord('$'), '$',
|
||||
array('startLine' => 2), array('endLine' => 2)
|
||||
),
|
||||
array(
|
||||
Parser::T_STRING, 'token',
|
||||
array('startLine' => 2), array('endLine' => 2)
|
||||
),
|
||||
array(
|
||||
ord('$'), '$',
|
||||
array(
|
||||
'startLine' => 3,
|
||||
'comments' => array(new Comment\Doc('/** doc' . "\n" . 'comment */', 2))
|
||||
),
|
||||
array('endLine' => 3)
|
||||
),
|
||||
)
|
||||
),
|
||||
// tests comment extraction
|
||||
array(
|
||||
'<?php /* comment */ // comment' . "\n" . '/** docComment 1 *//** docComment 2 */ token',
|
||||
array(),
|
||||
array(
|
||||
array(
|
||||
Parser::T_STRING, 'token',
|
||||
array(
|
||||
'startLine' => 2,
|
||||
'comments' => array(
|
||||
new Comment('/* comment */', 1),
|
||||
new Comment('// comment' . "\n", 1),
|
||||
new Comment\Doc('/** docComment 1 */', 2),
|
||||
new Comment\Doc('/** docComment 2 */', 2),
|
||||
),
|
||||
),
|
||||
array('endLine' => 2)
|
||||
),
|
||||
)
|
||||
),
|
||||
// tests differing start and end line
|
||||
array(
|
||||
'<?php "foo' . "\n" . 'bar"',
|
||||
array(),
|
||||
array(
|
||||
array(
|
||||
Parser::T_CONSTANT_ENCAPSED_STRING, '"foo' . "\n" . 'bar"',
|
||||
array('startLine' => 1), array('endLine' => 2)
|
||||
),
|
||||
)
|
||||
),
|
||||
// tests exact file offsets
|
||||
array(
|
||||
'<?php "a";' . "\n" . '// foo' . "\n" . '"b";',
|
||||
array('usedAttributes' => array('startFilePos', 'endFilePos')),
|
||||
array(
|
||||
array(
|
||||
Parser::T_CONSTANT_ENCAPSED_STRING, '"a"',
|
||||
array('startFilePos' => 6), array('endFilePos' => 8)
|
||||
),
|
||||
array(
|
||||
ord(';'), ';',
|
||||
array('startFilePos' => 9), array('endFilePos' => 9)
|
||||
),
|
||||
array(
|
||||
Parser::T_CONSTANT_ENCAPSED_STRING, '"b"',
|
||||
array('startFilePos' => 18), array('endFilePos' => 20)
|
||||
),
|
||||
array(
|
||||
ord(';'), ';',
|
||||
array('startFilePos' => 21), array('endFilePos' => 21)
|
||||
),
|
||||
)
|
||||
),
|
||||
// tests token offsets
|
||||
array(
|
||||
'<?php "a";' . "\n" . '// foo' . "\n" . '"b";',
|
||||
array('usedAttributes' => array('startTokenPos', 'endTokenPos')),
|
||||
array(
|
||||
array(
|
||||
Parser::T_CONSTANT_ENCAPSED_STRING, '"a"',
|
||||
array('startTokenPos' => 1), array('endTokenPos' => 1)
|
||||
),
|
||||
array(
|
||||
ord(';'), ';',
|
||||
array('startTokenPos' => 2), array('endTokenPos' => 2)
|
||||
),
|
||||
array(
|
||||
Parser::T_CONSTANT_ENCAPSED_STRING, '"b"',
|
||||
array('startTokenPos' => 5), array('endTokenPos' => 5)
|
||||
),
|
||||
array(
|
||||
ord(';'), ';',
|
||||
array('startTokenPos' => 6), array('endTokenPos' => 6)
|
||||
),
|
||||
)
|
||||
),
|
||||
// tests all attributes being disabled
|
||||
array(
|
||||
'<?php /* foo */ $bar;',
|
||||
array('usedAttributes' => array()),
|
||||
array(
|
||||
array(
|
||||
Parser::T_VARIABLE, '$bar',
|
||||
array(), array()
|
||||
),
|
||||
array(
|
||||
ord(';'), ';',
|
||||
array(), array()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestHaltCompiler
|
||||
*/
|
||||
public function testHandleHaltCompiler($code, $remaining) {
|
||||
$lexer = $this->getLexer();
|
||||
$lexer->startLexing($code);
|
||||
|
||||
while (Parser::T_HALT_COMPILER !== $lexer->getNextToken());
|
||||
|
||||
$this->assertSame($remaining, $lexer->handleHaltCompiler());
|
||||
$this->assertSame(0, $lexer->getNextToken());
|
||||
}
|
||||
|
||||
public function provideTestHaltCompiler() {
|
||||
return array(
|
||||
array('<?php ... __halt_compiler();Remaining Text', 'Remaining Text'),
|
||||
array('<?php ... __halt_compiler ( ) ;Remaining Text', 'Remaining Text'),
|
||||
array('<?php ... __halt_compiler() ?>Remaining Text', 'Remaining Text'),
|
||||
//array('<?php ... __halt_compiler();' . "\0", "\0"),
|
||||
//array('<?php ... __halt_compiler /* */ ( ) ;Remaining Text', 'Remaining Text'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \PhpParser\Error
|
||||
* @expectedExceptionMessage __HALT_COMPILER must be followed by "();"
|
||||
*/
|
||||
public function testHandleHaltCompilerError() {
|
||||
$lexer = $this->getLexer();
|
||||
$lexer->startLexing('<?php ... __halt_compiler invalid ();');
|
||||
|
||||
while (Parser::T_HALT_COMPILER !== $lexer->getNextToken());
|
||||
$lexer->handleHaltCompiler();
|
||||
}
|
||||
|
||||
public function testGetTokens() {
|
||||
$code = '<?php "a";' . "\n" . '// foo' . "\n" . '"b";';
|
||||
$expectedTokens = array(
|
||||
array(T_OPEN_TAG, '<?php ', 1),
|
||||
array(T_CONSTANT_ENCAPSED_STRING, '"a"', 1),
|
||||
';',
|
||||
array(T_WHITESPACE, "\n", 1),
|
||||
array(T_COMMENT, '// foo' . "\n", 2),
|
||||
array(T_CONSTANT_ENCAPSED_STRING, '"b"', 3),
|
||||
';',
|
||||
);
|
||||
|
||||
$lexer = $this->getLexer();
|
||||
$lexer->startLexing($code);
|
||||
$this->assertSame($expectedTokens, $lexer->getTokens());
|
||||
}
|
||||
}
|
132
vendor/nikic/php-parser/test/PhpParser/Node/NameTest.php
vendored
Normal file
132
vendor/nikic/php-parser/test/PhpParser/Node/NameTest.php
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Node;
|
||||
|
||||
class NameTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstruct() {
|
||||
$name = new Name(array('foo', 'bar'));
|
||||
$this->assertSame(array('foo', 'bar'), $name->parts);
|
||||
|
||||
$name = new Name('foo\bar');
|
||||
$this->assertSame(array('foo', 'bar'), $name->parts);
|
||||
}
|
||||
|
||||
public function testGet() {
|
||||
$name = new Name('foo');
|
||||
$this->assertSame('foo', $name->getFirst());
|
||||
$this->assertSame('foo', $name->getLast());
|
||||
|
||||
$name = new Name('foo\bar');
|
||||
$this->assertSame('foo', $name->getFirst());
|
||||
$this->assertSame('bar', $name->getLast());
|
||||
}
|
||||
|
||||
public function testToString() {
|
||||
$name = new Name('foo\bar');
|
||||
|
||||
$this->assertSame('foo\bar', (string) $name);
|
||||
$this->assertSame('foo\bar', $name->toString());
|
||||
$this->assertSame('foo_bar', $name->toString('_'));
|
||||
}
|
||||
|
||||
public function testSet() {
|
||||
$name = new Name('foo');
|
||||
|
||||
$name->set('foo\bar');
|
||||
$this->assertSame('foo\bar', $name->toString());
|
||||
|
||||
$name->set(array('foo', 'bar'));
|
||||
$this->assertSame('foo\bar', $name->toString());
|
||||
|
||||
$name->set(new Name('foo\bar'));
|
||||
$this->assertSame('foo\bar', $name->toString());
|
||||
}
|
||||
|
||||
public function testSetFirst() {
|
||||
$name = new Name('foo');
|
||||
|
||||
$name->setFirst('bar');
|
||||
$this->assertSame('bar', $name->toString());
|
||||
|
||||
$name->setFirst('A\B');
|
||||
$this->assertSame('A\B', $name->toString());
|
||||
|
||||
$name->setFirst('C');
|
||||
$this->assertSame('C\B', $name->toString());
|
||||
|
||||
$name->setFirst('D\E');
|
||||
$this->assertSame('D\E\B', $name->toString());
|
||||
}
|
||||
|
||||
public function testSetLast() {
|
||||
$name = new Name('foo');
|
||||
|
||||
$name->setLast('bar');
|
||||
$this->assertSame('bar', $name->toString());
|
||||
|
||||
$name->setLast('A\B');
|
||||
$this->assertSame('A\B', $name->toString());
|
||||
|
||||
$name->setLast('C');
|
||||
$this->assertSame('A\C', $name->toString());
|
||||
|
||||
$name->setLast('D\E');
|
||||
$this->assertSame('A\D\E', $name->toString());
|
||||
}
|
||||
|
||||
public function testAppend() {
|
||||
$name = new Name('foo');
|
||||
|
||||
$name->append('bar');
|
||||
$this->assertSame('foo\bar', $name->toString());
|
||||
|
||||
$name->append('bar\foo');
|
||||
$this->assertSame('foo\bar\bar\foo', $name->toString());
|
||||
}
|
||||
|
||||
public function testPrepend() {
|
||||
$name = new Name('foo');
|
||||
|
||||
$name->prepend('bar');
|
||||
$this->assertSame('bar\foo', $name->toString());
|
||||
|
||||
$name->prepend('foo\bar');
|
||||
$this->assertSame('foo\bar\bar\foo', $name->toString());
|
||||
}
|
||||
|
||||
public function testIs() {
|
||||
$name = new Name('foo');
|
||||
$this->assertTrue ($name->isUnqualified());
|
||||
$this->assertFalse($name->isQualified());
|
||||
$this->assertFalse($name->isFullyQualified());
|
||||
$this->assertFalse($name->isRelative());
|
||||
|
||||
$name = new Name('foo\bar');
|
||||
$this->assertFalse($name->isUnqualified());
|
||||
$this->assertTrue ($name->isQualified());
|
||||
$this->assertFalse($name->isFullyQualified());
|
||||
$this->assertFalse($name->isRelative());
|
||||
|
||||
$name = new Name\FullyQualified('foo');
|
||||
$this->assertFalse($name->isUnqualified());
|
||||
$this->assertFalse($name->isQualified());
|
||||
$this->assertTrue ($name->isFullyQualified());
|
||||
$this->assertFalse($name->isRelative());
|
||||
|
||||
$name = new Name\Relative('foo');
|
||||
$this->assertFalse($name->isUnqualified());
|
||||
$this->assertFalse($name->isQualified());
|
||||
$this->assertFalse($name->isFullyQualified());
|
||||
$this->assertTrue ($name->isRelative());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage When changing a name you need to pass either a string, an array or a Name node
|
||||
*/
|
||||
public function testInvalidArg() {
|
||||
$name = new Name('foo');
|
||||
$name->set(new \stdClass);
|
||||
}
|
||||
}
|
25
vendor/nikic/php-parser/test/PhpParser/Node/Scalar/MagicConstTest.php
vendored
Normal file
25
vendor/nikic/php-parser/test/PhpParser/Node/Scalar/MagicConstTest.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Node\Scalar;
|
||||
|
||||
class MagicConstTest extends \PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* @dataProvider provideTestGetName
|
||||
*/
|
||||
public function testGetName(MagicConst $magicConst, $name) {
|
||||
$this->assertSame($name, $magicConst->getName());
|
||||
}
|
||||
|
||||
public function provideTestGetName() {
|
||||
return array(
|
||||
array(new MagicConst\Class_, '__CLASS__'),
|
||||
array(new MagicConst\Dir, '__DIR__'),
|
||||
array(new MagicConst\File, '__FILE__'),
|
||||
array(new MagicConst\Function_, '__FUNCTION__'),
|
||||
array(new MagicConst\Line, '__LINE__'),
|
||||
array(new MagicConst\Method, '__METHOD__'),
|
||||
array(new MagicConst\Namespace_, '__NAMESPACE__'),
|
||||
array(new MagicConst\Trait_, '__TRAIT__'),
|
||||
);
|
||||
}
|
||||
}
|
61
vendor/nikic/php-parser/test/PhpParser/Node/Scalar/StringTest.php
vendored
Normal file
61
vendor/nikic/php-parser/test/PhpParser/Node/Scalar/StringTest.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Node\Scalar;
|
||||
|
||||
class StringTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestParseEscapeSequences
|
||||
*/
|
||||
public function testParseEscapeSequences($expected, $string, $quote) {
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
String_::parseEscapeSequences($string, $quote)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestParse
|
||||
*/
|
||||
public function testCreate($expected, $string) {
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
String_::parse($string)
|
||||
);
|
||||
}
|
||||
|
||||
public function provideTestParseEscapeSequences() {
|
||||
return array(
|
||||
array('"', '\\"', '"'),
|
||||
array('\\"', '\\"', '`'),
|
||||
array('\\"\\`', '\\"\\`', null),
|
||||
array("\\\$\n\r\t\f\v", '\\\\\$\n\r\t\f\v', null),
|
||||
array("\x1B", '\e', null),
|
||||
array(chr(255), '\xFF', null),
|
||||
array(chr(255), '\377', null),
|
||||
array(chr(0), '\400', null),
|
||||
array("\0", '\0', null),
|
||||
array('\xFF', '\\\\xFF', null),
|
||||
);
|
||||
}
|
||||
|
||||
public function provideTestParse() {
|
||||
$tests = array(
|
||||
array('A', '\'A\''),
|
||||
array('A', 'b\'A\''),
|
||||
array('A', '"A"'),
|
||||
array('A', 'b"A"'),
|
||||
array('\\', '\'\\\\\''),
|
||||
array('\'', '\'\\\'\''),
|
||||
);
|
||||
|
||||
foreach ($this->provideTestParseEscapeSequences() as $i => $test) {
|
||||
// skip second and third tests, they aren't for double quotes
|
||||
if ($i != 1 && $i != 2) {
|
||||
$tests[] = array($test[0], '"' . $test[1] . '"');
|
||||
}
|
||||
}
|
||||
|
||||
return $tests;
|
||||
}
|
||||
}
|
63
vendor/nikic/php-parser/test/PhpParser/Node/Stmt/ClassMethodTest.php
vendored
Normal file
63
vendor/nikic/php-parser/test/PhpParser/Node/Stmt/ClassMethodTest.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
class ClassMethodTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideModifiers
|
||||
*/
|
||||
public function testModifiers($modifier) {
|
||||
$node = new ClassMethod('foo', array(
|
||||
'type' => constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier))
|
||||
));
|
||||
|
||||
$this->assertTrue($node->{'is' . $modifier}());
|
||||
}
|
||||
|
||||
public function testNoModifiers() {
|
||||
$node = new ClassMethod('foo', array('type' => 0));
|
||||
|
||||
$this->assertTrue($node->isPublic());
|
||||
$this->assertFalse($node->isProtected());
|
||||
$this->assertFalse($node->isPrivate());
|
||||
$this->assertFalse($node->isAbstract());
|
||||
$this->assertFalse($node->isFinal());
|
||||
$this->assertFalse($node->isStatic());
|
||||
}
|
||||
|
||||
public function provideModifiers() {
|
||||
return array(
|
||||
array('public'),
|
||||
array('protected'),
|
||||
array('private'),
|
||||
array('abstract'),
|
||||
array('final'),
|
||||
array('static'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that implicit public modifier detection for method is working
|
||||
*
|
||||
* @dataProvider implicitPublicModifiers
|
||||
*
|
||||
* @param integer $modifier Node type modifier
|
||||
*/
|
||||
public function testImplicitPublic($modifier)
|
||||
{
|
||||
$node = new ClassMethod('foo', array(
|
||||
'type' => constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier))
|
||||
));
|
||||
|
||||
$this->assertTrue($node->isPublic(), 'Node should be implicitly public');
|
||||
}
|
||||
|
||||
public function implicitPublicModifiers() {
|
||||
return array(
|
||||
array('abstract'),
|
||||
array('final'),
|
||||
array('static'),
|
||||
);
|
||||
}
|
||||
}
|
59
vendor/nikic/php-parser/test/PhpParser/Node/Stmt/ClassTest.php
vendored
Normal file
59
vendor/nikic/php-parser/test/PhpParser/Node/Stmt/ClassTest.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
class ClassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIsAbstract() {
|
||||
$class = new Class_('Foo', array('type' => Class_::MODIFIER_ABSTRACT));
|
||||
$this->assertTrue($class->isAbstract());
|
||||
|
||||
$class = new Class_('Foo');
|
||||
$this->assertFalse($class->isAbstract());
|
||||
}
|
||||
|
||||
public function testIsFinal() {
|
||||
$class = new Class_('Foo', array('type' => Class_::MODIFIER_FINAL));
|
||||
$this->assertTrue($class->isFinal());
|
||||
|
||||
$class = new Class_('Foo');
|
||||
$this->assertFalse($class->isFinal());
|
||||
}
|
||||
|
||||
public function testGetMethods() {
|
||||
$methods = array(
|
||||
new ClassMethod('foo'),
|
||||
new ClassMethod('bar'),
|
||||
new ClassMethod('fooBar'),
|
||||
);
|
||||
$class = new Class_('Foo', array(
|
||||
'stmts' => array(
|
||||
new TraitUse(array()),
|
||||
$methods[0],
|
||||
new ClassConst(array()),
|
||||
$methods[1],
|
||||
new Property(0, array()),
|
||||
$methods[2],
|
||||
)
|
||||
));
|
||||
|
||||
$this->assertSame($methods, $class->getMethods());
|
||||
}
|
||||
|
||||
public function testGetMethod() {
|
||||
$methodConstruct = new ClassMethod('__CONSTRUCT');
|
||||
$methodTest = new ClassMethod('test');
|
||||
$class = new Class_('Foo', array(
|
||||
'stmts' => array(
|
||||
new ClassConst(array()),
|
||||
$methodConstruct,
|
||||
new Property(0, array()),
|
||||
$methodTest,
|
||||
)
|
||||
));
|
||||
|
||||
$this->assertSame($methodConstruct, $class->getMethod('__construct'));
|
||||
$this->assertSame($methodTest, $class->getMethod('test'));
|
||||
$this->assertNull($class->getMethod('nonExisting'));
|
||||
}
|
||||
}
|
26
vendor/nikic/php-parser/test/PhpParser/Node/Stmt/InterfaceTest.php
vendored
Normal file
26
vendor/nikic/php-parser/test/PhpParser/Node/Stmt/InterfaceTest.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
class InterfaceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetMethods() {
|
||||
$methods = array(
|
||||
new ClassMethod('foo'),
|
||||
new ClassMethod('bar'),
|
||||
);
|
||||
$interface = new Class_('Foo', array(
|
||||
'stmts' => array(
|
||||
new Node\Stmt\ClassConst(array(new Node\Const_('C1', new Node\Scalar\String_('C1')))),
|
||||
$methods[0],
|
||||
new Node\Stmt\ClassConst(array(new Node\Const_('C2', new Node\Scalar\String_('C2')))),
|
||||
$methods[1],
|
||||
new Node\Stmt\ClassConst(array(new Node\Const_('C3', new Node\Scalar\String_('C3')))),
|
||||
)
|
||||
));
|
||||
|
||||
$this->assertSame($methods, $interface->getMethods());
|
||||
}
|
||||
}
|
44
vendor/nikic/php-parser/test/PhpParser/Node/Stmt/PropertyTest.php
vendored
Normal file
44
vendor/nikic/php-parser/test/PhpParser/Node/Stmt/PropertyTest.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
class PropertyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideModifiers
|
||||
*/
|
||||
public function testModifiers($modifier) {
|
||||
$node = new Property(
|
||||
constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier)),
|
||||
array() // invalid
|
||||
);
|
||||
|
||||
$this->assertTrue($node->{'is' . $modifier}());
|
||||
}
|
||||
|
||||
public function testNoModifiers() {
|
||||
$node = new Property(0, array());
|
||||
|
||||
$this->assertTrue($node->isPublic());
|
||||
$this->assertFalse($node->isProtected());
|
||||
$this->assertFalse($node->isPrivate());
|
||||
$this->assertFalse($node->isStatic());
|
||||
}
|
||||
|
||||
public function testStaticImplicitlyPublic() {
|
||||
$node = new Property(Class_::MODIFIER_STATIC, array());
|
||||
$this->assertTrue($node->isPublic());
|
||||
$this->assertFalse($node->isProtected());
|
||||
$this->assertFalse($node->isPrivate());
|
||||
$this->assertTrue($node->isStatic());
|
||||
}
|
||||
|
||||
public function provideModifiers() {
|
||||
return array(
|
||||
array('public'),
|
||||
array('protected'),
|
||||
array('private'),
|
||||
array('static'),
|
||||
);
|
||||
}
|
||||
}
|
161
vendor/nikic/php-parser/test/PhpParser/NodeAbstractTest.php
vendored
Normal file
161
vendor/nikic/php-parser/test/PhpParser/NodeAbstractTest.php
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class DummyNode extends NodeAbstract {
|
||||
public $subNode1;
|
||||
public $subNode2;
|
||||
|
||||
public function __construct($subNode1, $subNode2, $attributes) {
|
||||
parent::__construct(null, $attributes);
|
||||
$this->subNode1 = $subNode1;
|
||||
$this->subNode2 = $subNode2;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('subNode1', 'subNode2');
|
||||
}
|
||||
|
||||
// This method is only overwritten because the node is located in an unusual namespace
|
||||
public function getType() {
|
||||
return 'Dummy';
|
||||
}
|
||||
}
|
||||
|
||||
class NodeAbstractTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function provideNodes() {
|
||||
$attributes = array(
|
||||
'startLine' => 10,
|
||||
'comments' => array(
|
||||
new Comment('// Comment' . "\n"),
|
||||
new Comment\Doc('/** doc comment */'),
|
||||
),
|
||||
);
|
||||
|
||||
$node1 = $this->getMockForAbstractClass(
|
||||
'PhpParser\NodeAbstract',
|
||||
array(
|
||||
array(
|
||||
'subNode1' => 'value1',
|
||||
'subNode2' => 'value2',
|
||||
),
|
||||
$attributes
|
||||
),
|
||||
'PhpParser_Node_Dummy'
|
||||
);
|
||||
$node1->notSubNode = 'value3';
|
||||
|
||||
$node2 = new DummyNode('value1', 'value2', $attributes);
|
||||
$node2->notSubNode = 'value3';
|
||||
|
||||
return array(
|
||||
array($attributes, $node1),
|
||||
array($attributes, $node2),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideNodes
|
||||
*/
|
||||
public function testConstruct(array $attributes, Node $node) {
|
||||
$this->assertSame('Dummy', $node->getType());
|
||||
$this->assertSame(array('subNode1', 'subNode2'), $node->getSubNodeNames());
|
||||
$this->assertSame(10, $node->getLine());
|
||||
$this->assertSame('/** doc comment */', $node->getDocComment()->getText());
|
||||
$this->assertSame('value1', $node->subNode1);
|
||||
$this->assertSame('value2', $node->subNode2);
|
||||
$this->assertTrue(isset($node->subNode1));
|
||||
$this->assertTrue(isset($node->subNode2));
|
||||
$this->assertFalse(isset($node->subNode3));
|
||||
$this->assertSame($attributes, $node->getAttributes());
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideNodes
|
||||
*/
|
||||
public function testGetDocComment(array $attributes, Node $node) {
|
||||
$this->assertSame('/** doc comment */', $node->getDocComment()->getText());
|
||||
array_pop($node->getAttribute('comments')); // remove doc comment
|
||||
$this->assertNull($node->getDocComment());
|
||||
array_pop($node->getAttribute('comments')); // remove comment
|
||||
$this->assertNull($node->getDocComment());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideNodes
|
||||
*/
|
||||
public function testChange(array $attributes, Node $node) {
|
||||
// change of line
|
||||
$node->setLine(15);
|
||||
$this->assertSame(15, $node->getLine());
|
||||
|
||||
// direct modification
|
||||
$node->subNode = 'newValue';
|
||||
$this->assertSame('newValue', $node->subNode);
|
||||
|
||||
// indirect modification
|
||||
$subNode =& $node->subNode;
|
||||
$subNode = 'newNewValue';
|
||||
$this->assertSame('newNewValue', $node->subNode);
|
||||
|
||||
// removal
|
||||
unset($node->subNode);
|
||||
$this->assertFalse(isset($node->subNode));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideNodes
|
||||
*/
|
||||
public function testIteration(array $attributes, Node $node) {
|
||||
// Iteration is simple object iteration over properties,
|
||||
// not over subnodes
|
||||
$i = 0;
|
||||
foreach ($node as $key => $value) {
|
||||
if ($i === 0) {
|
||||
$this->assertSame('subNode1', $key);
|
||||
$this->assertSame('value1', $value);
|
||||
} else if ($i === 1) {
|
||||
$this->assertSame('subNode2', $key);
|
||||
$this->assertSame('value2', $value);
|
||||
} else if ($i === 2) {
|
||||
$this->assertSame('notSubNode', $key);
|
||||
$this->assertSame('value3', $value);
|
||||
} else {
|
||||
throw new \Exception;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$this->assertSame(3, $i);
|
||||
}
|
||||
|
||||
public function testAttributes() {
|
||||
/** @var $node Node */
|
||||
$node = $this->getMockForAbstractClass('PhpParser\NodeAbstract');
|
||||
|
||||
$this->assertEmpty($node->getAttributes());
|
||||
|
||||
$node->setAttribute('key', 'value');
|
||||
$this->assertTrue($node->hasAttribute('key'));
|
||||
$this->assertSame('value', $node->getAttribute('key'));
|
||||
|
||||
$this->assertFalse($node->hasAttribute('doesNotExist'));
|
||||
$this->assertNull($node->getAttribute('doesNotExist'));
|
||||
$this->assertSame('default', $node->getAttribute('doesNotExist', 'default'));
|
||||
|
||||
$node->setAttribute('null', null);
|
||||
$this->assertTrue($node->hasAttribute('null'));
|
||||
$this->assertNull($node->getAttribute('null'));
|
||||
$this->assertNull($node->getAttribute('null', 'default'));
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'key' => 'value',
|
||||
'null' => null,
|
||||
),
|
||||
$node->getAttributes()
|
||||
);
|
||||
}
|
||||
}
|
72
vendor/nikic/php-parser/test/PhpParser/NodeDumperTest.php
vendored
Normal file
72
vendor/nikic/php-parser/test/PhpParser/NodeDumperTest.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class NodeDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private function canonicalize($string) {
|
||||
return str_replace("\r\n", "\n", $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestDump
|
||||
* @covers PhpParser\NodeDumper::dump
|
||||
*/
|
||||
public function testDump($node, $dump) {
|
||||
$dumper = new NodeDumper;
|
||||
|
||||
$this->assertSame($this->canonicalize($dump), $this->canonicalize($dumper->dump($node)));
|
||||
}
|
||||
|
||||
public function provideTestDump() {
|
||||
return array(
|
||||
array(
|
||||
array(),
|
||||
'array(
|
||||
)'
|
||||
),
|
||||
array(
|
||||
array('Foo', 'Bar', 'Key' => 'FooBar'),
|
||||
'array(
|
||||
0: Foo
|
||||
1: Bar
|
||||
Key: FooBar
|
||||
)'
|
||||
),
|
||||
array(
|
||||
new Node\Name(array('Hallo', 'World')),
|
||||
'Name(
|
||||
parts: array(
|
||||
0: Hallo
|
||||
1: World
|
||||
)
|
||||
)'
|
||||
),
|
||||
array(
|
||||
new Node\Expr\Array_(array(
|
||||
new Node\Expr\ArrayItem(new Node\Scalar\String_('Foo'))
|
||||
)),
|
||||
'Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: Foo
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Can only dump nodes and arrays.
|
||||
*/
|
||||
public function testError() {
|
||||
$dumper = new NodeDumper;
|
||||
$dumper->dump(new \stdClass);
|
||||
}
|
||||
}
|
203
vendor/nikic/php-parser/test/PhpParser/NodeTraverserTest.php
vendored
Normal file
203
vendor/nikic/php-parser/test/PhpParser/NodeTraverserTest.php
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
class NodeTraverserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testNonModifying() {
|
||||
$str1Node = new String_('Foo');
|
||||
$str2Node = new String_('Bar');
|
||||
$echoNode = new Node\Stmt\Echo_(array($str1Node, $str2Node));
|
||||
$stmts = array($echoNode);
|
||||
|
||||
$visitor = $this->getMock('PhpParser\NodeVisitor');
|
||||
|
||||
$visitor->expects($this->at(0))->method('beforeTraverse')->with($stmts);
|
||||
$visitor->expects($this->at(1))->method('enterNode')->with($echoNode);
|
||||
$visitor->expects($this->at(2))->method('enterNode')->with($str1Node);
|
||||
$visitor->expects($this->at(3))->method('leaveNode')->with($str1Node);
|
||||
$visitor->expects($this->at(4))->method('enterNode')->with($str2Node);
|
||||
$visitor->expects($this->at(5))->method('leaveNode')->with($str2Node);
|
||||
$visitor->expects($this->at(6))->method('leaveNode')->with($echoNode);
|
||||
$visitor->expects($this->at(7))->method('afterTraverse')->with($stmts);
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
|
||||
$this->assertEquals($stmts, $traverser->traverse($stmts));
|
||||
}
|
||||
|
||||
public function testModifying() {
|
||||
$str1Node = new String_('Foo');
|
||||
$str2Node = new String_('Bar');
|
||||
$printNode = new Expr\Print_($str1Node);
|
||||
|
||||
// first visitor changes the node, second verifies the change
|
||||
$visitor1 = $this->getMock('PhpParser\NodeVisitor');
|
||||
$visitor2 = $this->getMock('PhpParser\NodeVisitor');
|
||||
|
||||
// replace empty statements with string1 node
|
||||
$visitor1->expects($this->at(0))->method('beforeTraverse')->with(array())
|
||||
->will($this->returnValue(array($str1Node)));
|
||||
$visitor2->expects($this->at(0))->method('beforeTraverse')->with(array($str1Node));
|
||||
|
||||
// replace string1 node with print node
|
||||
$visitor1->expects($this->at(1))->method('enterNode')->with($str1Node)
|
||||
->will($this->returnValue($printNode));
|
||||
$visitor2->expects($this->at(1))->method('enterNode')->with($printNode);
|
||||
|
||||
// replace string1 node with string2 node
|
||||
$visitor1->expects($this->at(2))->method('enterNode')->with($str1Node)
|
||||
->will($this->returnValue($str2Node));
|
||||
$visitor2->expects($this->at(2))->method('enterNode')->with($str2Node);
|
||||
|
||||
// replace string2 node with string1 node again
|
||||
$visitor1->expects($this->at(3))->method('leaveNode')->with($str2Node)
|
||||
->will($this->returnValue($str1Node));
|
||||
$visitor2->expects($this->at(3))->method('leaveNode')->with($str1Node);
|
||||
|
||||
// replace print node with string1 node again
|
||||
$visitor1->expects($this->at(4))->method('leaveNode')->with($printNode)
|
||||
->will($this->returnValue($str1Node));
|
||||
$visitor2->expects($this->at(4))->method('leaveNode')->with($str1Node);
|
||||
|
||||
// replace string1 node with empty statements again
|
||||
$visitor1->expects($this->at(5))->method('afterTraverse')->with(array($str1Node))
|
||||
->will($this->returnValue(array()));
|
||||
$visitor2->expects($this->at(5))->method('afterTraverse')->with(array());
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor1);
|
||||
$traverser->addVisitor($visitor2);
|
||||
|
||||
// as all operations are reversed we end where we start
|
||||
$this->assertEquals(array(), $traverser->traverse(array()));
|
||||
}
|
||||
|
||||
public function testRemove() {
|
||||
$str1Node = new String_('Foo');
|
||||
$str2Node = new String_('Bar');
|
||||
|
||||
$visitor = $this->getMock('PhpParser\NodeVisitor');
|
||||
|
||||
// remove the string1 node, leave the string2 node
|
||||
$visitor->expects($this->at(2))->method('leaveNode')->with($str1Node)
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
|
||||
$this->assertEquals(array($str2Node), $traverser->traverse(array($str1Node, $str2Node)));
|
||||
}
|
||||
|
||||
public function testMerge() {
|
||||
$strStart = new String_('Start');
|
||||
$strMiddle = new String_('End');
|
||||
$strEnd = new String_('Middle');
|
||||
$strR1 = new String_('Replacement 1');
|
||||
$strR2 = new String_('Replacement 2');
|
||||
|
||||
$visitor = $this->getMock('PhpParser\NodeVisitor');
|
||||
|
||||
// replace strMiddle with strR1 and strR2 by merge
|
||||
$visitor->expects($this->at(4))->method('leaveNode')->with($strMiddle)
|
||||
->will($this->returnValue(array($strR1, $strR2)));
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
|
||||
$this->assertEquals(
|
||||
array($strStart, $strR1, $strR2, $strEnd),
|
||||
$traverser->traverse(array($strStart, $strMiddle, $strEnd))
|
||||
);
|
||||
}
|
||||
|
||||
public function testDeepArray() {
|
||||
$strNode = new String_('Foo');
|
||||
$stmts = array(array(array($strNode)));
|
||||
|
||||
$visitor = $this->getMock('PhpParser\NodeVisitor');
|
||||
$visitor->expects($this->at(1))->method('enterNode')->with($strNode);
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
|
||||
$this->assertEquals($stmts, $traverser->traverse($stmts));
|
||||
}
|
||||
|
||||
public function testDontTraverseChildren() {
|
||||
$strNode = new String_('str');
|
||||
$printNode = new Expr\Print_($strNode);
|
||||
$varNode = new Expr\Variable('foo');
|
||||
$mulNode = new Expr\BinaryOp\Mul($varNode, $varNode);
|
||||
$negNode = new Expr\UnaryMinus($mulNode);
|
||||
$stmts = array($printNode, $negNode);
|
||||
|
||||
$visitor1 = $this->getMock('PhpParser\NodeVisitor');
|
||||
$visitor2 = $this->getMock('PhpParser\NodeVisitor');
|
||||
|
||||
$visitor1->expects($this->at(1))->method('enterNode')->with($printNode)
|
||||
->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CHILDREN));
|
||||
$visitor2->expects($this->at(1))->method('enterNode')->with($printNode);
|
||||
|
||||
$visitor1->expects($this->at(2))->method('leaveNode')->with($printNode);
|
||||
$visitor2->expects($this->at(2))->method('leaveNode')->with($printNode);
|
||||
|
||||
$visitor1->expects($this->at(3))->method('enterNode')->with($negNode);
|
||||
$visitor2->expects($this->at(3))->method('enterNode')->with($negNode);
|
||||
|
||||
$visitor1->expects($this->at(4))->method('enterNode')->with($mulNode);
|
||||
$visitor2->expects($this->at(4))->method('enterNode')->with($mulNode)
|
||||
->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CHILDREN));
|
||||
|
||||
$visitor1->expects($this->at(5))->method('leaveNode')->with($mulNode);
|
||||
$visitor2->expects($this->at(5))->method('leaveNode')->with($mulNode);
|
||||
|
||||
$visitor1->expects($this->at(6))->method('leaveNode')->with($negNode);
|
||||
$visitor2->expects($this->at(6))->method('leaveNode')->with($negNode);
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor1);
|
||||
$traverser->addVisitor($visitor2);
|
||||
|
||||
$this->assertEquals($stmts, $traverser->traverse($stmts));
|
||||
}
|
||||
|
||||
public function testRemovingVisitor() {
|
||||
$visitor1 = $this->getMock('PhpParser\NodeVisitor');
|
||||
$visitor2 = $this->getMock('PhpParser\NodeVisitor');
|
||||
$visitor3 = $this->getMock('PhpParser\NodeVisitor');
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor1);
|
||||
$traverser->addVisitor($visitor2);
|
||||
$traverser->addVisitor($visitor3);
|
||||
|
||||
$preExpected = array($visitor1, $visitor2, $visitor3);
|
||||
$this->assertAttributeSame($preExpected, 'visitors', $traverser, 'The appropriate visitors have not been added');
|
||||
|
||||
$traverser->removeVisitor($visitor2);
|
||||
|
||||
$postExpected = array(0 => $visitor1, 2 => $visitor3);
|
||||
$this->assertAttributeSame($postExpected, 'visitors', $traverser, 'The appropriate visitors are not present after removal');
|
||||
}
|
||||
|
||||
public function testCloneNodesByDefault() {
|
||||
$stmts = array(new Node\Stmt\Echo_(array(new String_('Foo'), new String_('Bar'))));
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
|
||||
$this->assertNotSame($stmts, $traverser->traverse($stmts));
|
||||
}
|
||||
|
||||
public function testCloneNodesDisabled() {
|
||||
$stmts = array(new Node\Stmt\Echo_(array(new String_('Foo'), new String_('Bar'))));
|
||||
|
||||
$traverser = new NodeTraverser(false);
|
||||
|
||||
$this->assertSame($stmts, $traverser->traverse($stmts));
|
||||
}
|
||||
}
|
398
vendor/nikic/php-parser/test/PhpParser/NodeVisitor/NameResolverTest.php
vendored
Normal file
398
vendor/nikic/php-parser/test/PhpParser/NodeVisitor/NameResolverTest.php
vendored
Normal file
@@ -0,0 +1,398 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\NodeVisitor;
|
||||
|
||||
use PhpParser;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
class NameResolverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private function canonicalize($string) {
|
||||
return str_replace("\r\n", "\n", $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PhpParser\NodeVisitor\NameResolver
|
||||
*/
|
||||
public function testResolveNames() {
|
||||
$code = <<<'EOC'
|
||||
<?php
|
||||
|
||||
namespace Foo {
|
||||
use Hallo as Hi;
|
||||
|
||||
new Bar();
|
||||
new Hi();
|
||||
new Hi\Bar();
|
||||
new \Bar();
|
||||
new namespace\Bar();
|
||||
|
||||
bar();
|
||||
hi();
|
||||
Hi\bar();
|
||||
foo\bar();
|
||||
\bar();
|
||||
namespace\bar();
|
||||
}
|
||||
namespace {
|
||||
use Hallo as Hi;
|
||||
|
||||
new Bar();
|
||||
new Hi();
|
||||
new Hi\Bar();
|
||||
new \Bar();
|
||||
new namespace\Bar();
|
||||
|
||||
bar();
|
||||
hi();
|
||||
Hi\bar();
|
||||
foo\bar();
|
||||
\bar();
|
||||
namespace\bar();
|
||||
}
|
||||
namespace Bar {
|
||||
use function foo\bar as baz;
|
||||
use const foo\BAR as BAZ;
|
||||
use foo as bar;
|
||||
|
||||
bar();
|
||||
baz();
|
||||
bar\foo();
|
||||
baz\foo();
|
||||
BAR();
|
||||
BAZ();
|
||||
BAR\FOO();
|
||||
BAZ\FOO();
|
||||
|
||||
bar;
|
||||
baz;
|
||||
bar\foo;
|
||||
baz\foo;
|
||||
BAR;
|
||||
BAZ;
|
||||
BAR\FOO;
|
||||
BAZ\FOO;
|
||||
}
|
||||
EOC;
|
||||
$expectedCode = <<<'EOC'
|
||||
namespace Foo {
|
||||
use Hallo as Hi;
|
||||
new \Foo\Bar();
|
||||
new \Hallo();
|
||||
new \Hallo\Bar();
|
||||
new \Bar();
|
||||
new \Foo\Bar();
|
||||
bar();
|
||||
hi();
|
||||
\Hallo\bar();
|
||||
\Foo\foo\bar();
|
||||
\bar();
|
||||
\Foo\bar();
|
||||
}
|
||||
namespace {
|
||||
use Hallo as Hi;
|
||||
new \Bar();
|
||||
new \Hallo();
|
||||
new \Hallo\Bar();
|
||||
new \Bar();
|
||||
new \Bar();
|
||||
bar();
|
||||
hi();
|
||||
\Hallo\bar();
|
||||
\foo\bar();
|
||||
\bar();
|
||||
\bar();
|
||||
}
|
||||
namespace Bar {
|
||||
use function foo\bar as baz;
|
||||
use const foo\BAR as BAZ;
|
||||
use foo as bar;
|
||||
bar();
|
||||
\foo\bar();
|
||||
\foo\foo();
|
||||
\Bar\baz\foo();
|
||||
BAR();
|
||||
\foo\bar();
|
||||
\foo\FOO();
|
||||
\Bar\BAZ\FOO();
|
||||
bar;
|
||||
baz;
|
||||
\foo\foo;
|
||||
\Bar\baz\foo;
|
||||
BAR;
|
||||
\foo\BAR;
|
||||
\foo\FOO;
|
||||
\Bar\BAZ\FOO;
|
||||
}
|
||||
EOC;
|
||||
|
||||
$parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative);
|
||||
$prettyPrinter = new PhpParser\PrettyPrinter\Standard;
|
||||
$traverser = new PhpParser\NodeTraverser;
|
||||
$traverser->addVisitor(new NameResolver);
|
||||
|
||||
$stmts = $parser->parse($code);
|
||||
$stmts = $traverser->traverse($stmts);
|
||||
|
||||
$this->assertSame(
|
||||
$this->canonicalize($expectedCode),
|
||||
$prettyPrinter->prettyPrint($stmts)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PhpParser\NodeVisitor\NameResolver
|
||||
*/
|
||||
public function testResolveLocations() {
|
||||
$code = <<<'EOC'
|
||||
<?php
|
||||
namespace NS;
|
||||
|
||||
class A extends B implements C, D {
|
||||
use E, F, G {
|
||||
f as private g;
|
||||
E::h as i;
|
||||
E::j insteadof F, G;
|
||||
}
|
||||
}
|
||||
|
||||
interface A extends C, D {
|
||||
public function a(A $a) : A;
|
||||
}
|
||||
|
||||
function fn() : A {}
|
||||
function fn2() : array {}
|
||||
function() : A {};
|
||||
|
||||
A::b();
|
||||
A::$b;
|
||||
A::B;
|
||||
new A;
|
||||
$a instanceof A;
|
||||
|
||||
namespace\a();
|
||||
namespace\A;
|
||||
|
||||
try {
|
||||
$someThing;
|
||||
} catch (A $a) {
|
||||
$someThingElse;
|
||||
}
|
||||
EOC;
|
||||
$expectedCode = <<<'EOC'
|
||||
namespace NS;
|
||||
|
||||
class A extends \NS\B implements \NS\C, \NS\D
|
||||
{
|
||||
use \NS\E, \NS\F, \NS\G {
|
||||
f as private g;
|
||||
\NS\E::h as i;
|
||||
\NS\E::j insteadof \NS\F, \NS\G;
|
||||
}
|
||||
}
|
||||
interface A extends \NS\C, \NS\D
|
||||
{
|
||||
public function a(\NS\A $a) : \NS\A;
|
||||
}
|
||||
function fn() : \NS\A
|
||||
{
|
||||
}
|
||||
function fn2() : array
|
||||
{
|
||||
}
|
||||
function () : \NS\A {
|
||||
};
|
||||
\NS\A::b();
|
||||
\NS\A::$b;
|
||||
\NS\A::B;
|
||||
new \NS\A();
|
||||
$a instanceof \NS\A;
|
||||
\NS\a();
|
||||
\NS\A;
|
||||
try {
|
||||
$someThing;
|
||||
} catch (\NS\A $a) {
|
||||
$someThingElse;
|
||||
}
|
||||
EOC;
|
||||
|
||||
$parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative);
|
||||
$prettyPrinter = new PhpParser\PrettyPrinter\Standard;
|
||||
$traverser = new PhpParser\NodeTraverser;
|
||||
$traverser->addVisitor(new NameResolver);
|
||||
|
||||
$stmts = $parser->parse($code);
|
||||
$stmts = $traverser->traverse($stmts);
|
||||
|
||||
$this->assertSame(
|
||||
$this->canonicalize($expectedCode),
|
||||
$prettyPrinter->prettyPrint($stmts)
|
||||
);
|
||||
}
|
||||
|
||||
public function testNoResolveSpecialName() {
|
||||
$stmts = array(new Node\Expr\New_(new Name('self')));
|
||||
|
||||
$traverser = new PhpParser\NodeTraverser;
|
||||
$traverser->addVisitor(new NameResolver);
|
||||
|
||||
$this->assertEquals($stmts, $traverser->traverse($stmts));
|
||||
}
|
||||
|
||||
protected function createNamespacedAndNonNamespaced(array $stmts) {
|
||||
return array(
|
||||
new Stmt\Namespace_(new Name('NS'), $stmts),
|
||||
new Stmt\Namespace_(null, $stmts),
|
||||
);
|
||||
}
|
||||
|
||||
public function testAddNamespacedName() {
|
||||
$stmts = $this->createNamespacedAndNonNamespaced(array(
|
||||
new Stmt\Class_('A'),
|
||||
new Stmt\Interface_('B'),
|
||||
new Stmt\Function_('C'),
|
||||
new Stmt\Const_(array(
|
||||
new Node\Const_('D', new Node\Scalar\String_('E'))
|
||||
)),
|
||||
new Expr\New_(new Stmt\Class_(null)),
|
||||
));
|
||||
|
||||
$traverser = new PhpParser\NodeTraverser;
|
||||
$traverser->addVisitor(new NameResolver);
|
||||
|
||||
$stmts = $traverser->traverse($stmts);
|
||||
|
||||
$this->assertSame('NS\\A', (string) $stmts[0]->stmts[0]->namespacedName);
|
||||
$this->assertSame('NS\\B', (string) $stmts[0]->stmts[1]->namespacedName);
|
||||
$this->assertSame('NS\\C', (string) $stmts[0]->stmts[2]->namespacedName);
|
||||
$this->assertSame('NS\\D', (string) $stmts[0]->stmts[3]->consts[0]->namespacedName);
|
||||
$this->assertObjectNotHasAttribute('namespacedName', $stmts[0]->stmts[4]->class);
|
||||
$this->assertSame('A', (string) $stmts[1]->stmts[0]->namespacedName);
|
||||
$this->assertSame('B', (string) $stmts[1]->stmts[1]->namespacedName);
|
||||
$this->assertSame('C', (string) $stmts[1]->stmts[2]->namespacedName);
|
||||
$this->assertSame('D', (string) $stmts[1]->stmts[3]->consts[0]->namespacedName);
|
||||
$this->assertObjectNotHasAttribute('namespacedName', $stmts[1]->stmts[4]->class);
|
||||
}
|
||||
|
||||
public function testAddTraitNamespacedName() {
|
||||
$stmts = $this->createNamespacedAndNonNamespaced(array(
|
||||
new Stmt\Trait_('A')
|
||||
));
|
||||
|
||||
$traverser = new PhpParser\NodeTraverser;
|
||||
$traverser->addVisitor(new NameResolver);
|
||||
|
||||
$stmts = $traverser->traverse($stmts);
|
||||
|
||||
$this->assertSame('NS\\A', (string) $stmts[0]->stmts[0]->namespacedName);
|
||||
$this->assertSame('A', (string) $stmts[1]->stmts[0]->namespacedName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestError
|
||||
*/
|
||||
public function testError(Node $stmt, $errorMsg) {
|
||||
$this->setExpectedException('PhpParser\Error', $errorMsg);
|
||||
|
||||
$traverser = new PhpParser\NodeTraverser;
|
||||
$traverser->addVisitor(new NameResolver);
|
||||
$traverser->traverse(array($stmt));
|
||||
}
|
||||
|
||||
public function provideTestError() {
|
||||
return array(
|
||||
array(
|
||||
new Stmt\Use_(array(
|
||||
new Stmt\UseUse(new Name('A\B'), 'B', array('startLine' => 1)),
|
||||
new Stmt\UseUse(new Name('C\D'), 'B', array('startLine' => 2)),
|
||||
), Stmt\Use_::TYPE_NORMAL),
|
||||
'Cannot use C\D as B because the name is already in use on line 2'
|
||||
),
|
||||
array(
|
||||
new Stmt\Use_(array(
|
||||
new Stmt\UseUse(new Name('a\b'), 'b', array('startLine' => 1)),
|
||||
new Stmt\UseUse(new Name('c\d'), 'B', array('startLine' => 2)),
|
||||
), Stmt\Use_::TYPE_FUNCTION),
|
||||
'Cannot use function c\d as B because the name is already in use on line 2'
|
||||
),
|
||||
array(
|
||||
new Stmt\Use_(array(
|
||||
new Stmt\UseUse(new Name('A\B'), 'B', array('startLine' => 1)),
|
||||
new Stmt\UseUse(new Name('C\D'), 'B', array('startLine' => 2)),
|
||||
), Stmt\Use_::TYPE_CONSTANT),
|
||||
'Cannot use const C\D as B because the name is already in use on line 2'
|
||||
),
|
||||
array(
|
||||
new Expr\New_(new Name\FullyQualified('self', array('startLine' => 3))),
|
||||
"'\\self' is an invalid class name on line 3"
|
||||
),
|
||||
array(
|
||||
new Expr\New_(new Name\Relative('self', array('startLine' => 3))),
|
||||
"'\\self' is an invalid class name on line 3"
|
||||
),
|
||||
array(
|
||||
new Expr\New_(new Name\FullyQualified('PARENT', array('startLine' => 3))),
|
||||
"'\\PARENT' is an invalid class name on line 3"
|
||||
),
|
||||
array(
|
||||
new Expr\New_(new Name\Relative('STATIC', array('startLine' => 3))),
|
||||
"'\\STATIC' is an invalid class name on line 3"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function testClassNameIsCaseInsensitive()
|
||||
{
|
||||
$source = <<<'EOC'
|
||||
<?php
|
||||
namespace Foo;
|
||||
use Bar\Baz;
|
||||
$test = new baz();
|
||||
EOC;
|
||||
|
||||
$parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative);
|
||||
$stmts = $parser->parse($source);
|
||||
|
||||
$traverser = new PhpParser\NodeTraverser;
|
||||
$traverser->addVisitor(new NameResolver);
|
||||
|
||||
$stmts = $traverser->traverse($stmts);
|
||||
$stmt = $stmts[0];
|
||||
|
||||
$this->assertSame(array('Bar', 'Baz'), $stmt->stmts[1]->expr->class->parts);
|
||||
}
|
||||
|
||||
public function testSpecialClassNamesAreCaseInsensitive() {
|
||||
$source = <<<'EOC'
|
||||
<?php
|
||||
namespace Foo;
|
||||
|
||||
class Bar
|
||||
{
|
||||
public static function method()
|
||||
{
|
||||
SELF::method();
|
||||
PARENT::method();
|
||||
STATIC::method();
|
||||
}
|
||||
}
|
||||
EOC;
|
||||
|
||||
$parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative);
|
||||
$stmts = $parser->parse($source);
|
||||
|
||||
$traverser = new PhpParser\NodeTraverser;
|
||||
$traverser->addVisitor(new NameResolver);
|
||||
|
||||
$stmts = $traverser->traverse($stmts);
|
||||
$classStmt = $stmts[0];
|
||||
$methodStmt = $classStmt->stmts[0]->stmts[0];
|
||||
|
||||
$this->assertSame('SELF', (string)$methodStmt->stmts[0]->class);
|
||||
$this->assertSame('PARENT', (string)$methodStmt->stmts[1]->class);
|
||||
$this->assertSame('STATIC', (string)$methodStmt->stmts[2]->class);
|
||||
}
|
||||
}
|
154
vendor/nikic/php-parser/test/PhpParser/ParserTest.php
vendored
Normal file
154
vendor/nikic/php-parser/test/PhpParser/ParserTest.php
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PhpParser\Comment;
|
||||
|
||||
require_once __DIR__ . '/CodeTestAbstract.php';
|
||||
|
||||
class ParserTest extends CodeTestAbstract
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestParse
|
||||
*/
|
||||
public function testParse($name, $code, $expected) {
|
||||
$lexer = new Lexer\Emulative(array('usedAttributes' => array(
|
||||
'startLine', 'endLine', 'startFilePos', 'endFilePos'
|
||||
)));
|
||||
$parser = new Parser($lexer, array(
|
||||
'throwOnError' => false,
|
||||
));
|
||||
|
||||
$stmts = $parser->parse($code);
|
||||
$errors = $parser->getErrors();
|
||||
|
||||
$output = '';
|
||||
foreach ($errors as $error) {
|
||||
$output .= $this->formatErrorMessage($error, $code) . "\n";
|
||||
}
|
||||
|
||||
if (null !== $stmts) {
|
||||
$dumper = new NodeDumper;
|
||||
$output .= $dumper->dump($stmts);
|
||||
}
|
||||
|
||||
$this->assertSame($this->canonicalize($expected), $this->canonicalize($output), $name);
|
||||
}
|
||||
|
||||
public function provideTestParse() {
|
||||
return $this->getTests(__DIR__ . '/../code/parser', 'test');
|
||||
}
|
||||
|
||||
private function formatErrorMessage(Error $e, $code) {
|
||||
if ($e->hasColumnInfo()) {
|
||||
return $e->getRawMessage() . ' from ' . $e->getStartLine() . ':' . $e->getStartColumn($code)
|
||||
. ' to ' . $e->getEndLine() . ':' . $e->getEndColumn($code);
|
||||
} else {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \PhpParser\Error
|
||||
* @expectedExceptionMessage Syntax error, unexpected EOF on line 1
|
||||
*/
|
||||
public function testParserThrowsSyntaxError() {
|
||||
$parser = new Parser(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() {
|
||||
$parser = new Parser(new Lexer());
|
||||
$parser->parse('<?php use foo as self;');
|
||||
}
|
||||
|
||||
public function testAttributeAssignment() {
|
||||
$lexer = new Lexer(array(
|
||||
'usedAttributes' => array(
|
||||
'comments', 'startLine', 'endLine',
|
||||
'startTokenPos', 'endTokenPos',
|
||||
)
|
||||
));
|
||||
|
||||
$code = <<<'EOC'
|
||||
<?php
|
||||
/** Doc comment */
|
||||
function test($a) {
|
||||
// Line
|
||||
// Comments
|
||||
echo $a;
|
||||
}
|
||||
EOC;
|
||||
$code = $this->canonicalize($code);
|
||||
|
||||
$parser = new Parser($lexer);
|
||||
$stmts = $parser->parse($code);
|
||||
|
||||
/** @var \PhpParser\Node\Stmt\Function_ $fn */
|
||||
$fn = $stmts[0];
|
||||
$this->assertInstanceOf('PhpParser\Node\Stmt\Function_', $fn);
|
||||
$this->assertEquals(array(
|
||||
'comments' => array(
|
||||
new Comment\Doc('/** Doc comment */', 2),
|
||||
),
|
||||
'startLine' => 3,
|
||||
'endLine' => 7,
|
||||
'startTokenPos' => 3,
|
||||
'endTokenPos' => 21,
|
||||
), $fn->getAttributes());
|
||||
|
||||
$param = $fn->params[0];
|
||||
$this->assertInstanceOf('PhpParser\Node\Param', $param);
|
||||
$this->assertEquals(array(
|
||||
'startLine' => 3,
|
||||
'endLine' => 3,
|
||||
'startTokenPos' => 7,
|
||||
'endTokenPos' => 7,
|
||||
), $param->getAttributes());
|
||||
|
||||
/** @var \PhpParser\Node\Stmt\Echo_ $echo */
|
||||
$echo = $fn->stmts[0];
|
||||
$this->assertInstanceOf('PhpParser\Node\Stmt\Echo_', $echo);
|
||||
$this->assertEquals(array(
|
||||
'comments' => array(
|
||||
new Comment("// Line\n", 4),
|
||||
new Comment("// Comments\n", 5),
|
||||
),
|
||||
'startLine' => 6,
|
||||
'endLine' => 6,
|
||||
'startTokenPos' => 16,
|
||||
'endTokenPos' => 19,
|
||||
), $echo->getAttributes());
|
||||
|
||||
/** @var \PhpParser\Node\Expr\Variable $var */
|
||||
$var = $echo->exprs[0];
|
||||
$this->assertInstanceOf('PhpParser\Node\Expr\Variable', $var);
|
||||
$this->assertEquals(array(
|
||||
'startLine' => 6,
|
||||
'endLine' => 6,
|
||||
'startTokenPos' => 18,
|
||||
'endTokenPos' => 18,
|
||||
), $var->getAttributes());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RangeException
|
||||
* @expectedExceptionMessage The lexer returned an invalid token (id=999, value=foobar)
|
||||
*/
|
||||
public function testInvalidToken() {
|
||||
$lexer = new InvalidTokenLexer;
|
||||
$parser = new Parser($lexer);
|
||||
$parser->parse('dummy');
|
||||
}
|
||||
}
|
||||
|
||||
class InvalidTokenLexer extends Lexer {
|
||||
public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) {
|
||||
$value = 'foobar';
|
||||
return 999;
|
||||
}
|
||||
}
|
63
vendor/nikic/php-parser/test/PhpParser/PrettyPrinterTest.php
vendored
Normal file
63
vendor/nikic/php-parser/test/PhpParser/PrettyPrinterTest.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\PrettyPrinter\Standard;
|
||||
|
||||
require_once __DIR__ . '/CodeTestAbstract.php';
|
||||
|
||||
class PrettyPrinterTest extends CodeTestAbstract
|
||||
{
|
||||
protected function doTestPrettyPrintMethod($method, $name, $code, $dump) {
|
||||
$parser = new Parser(new Lexer\Emulative);
|
||||
$prettyPrinter = new Standard;
|
||||
|
||||
$stmts = $parser->parse($code);
|
||||
$this->assertSame(
|
||||
$this->canonicalize($dump),
|
||||
$this->canonicalize($prettyPrinter->$method($stmts)),
|
||||
$name
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestPrettyPrint
|
||||
* @covers PhpParser\PrettyPrinter\Standard<extended>
|
||||
*/
|
||||
public function testPrettyPrint($name, $code, $dump) {
|
||||
$this->doTestPrettyPrintMethod('prettyPrint', $name, $code, $dump);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestPrettyPrintFile
|
||||
* @covers PhpParser\PrettyPrinter\Standard<extended>
|
||||
*/
|
||||
public function testPrettyPrintFile($name, $code, $dump) {
|
||||
$this->doTestPrettyPrintMethod('prettyPrintFile', $name, $code, $dump);
|
||||
}
|
||||
|
||||
public function provideTestPrettyPrint() {
|
||||
return $this->getTests(__DIR__ . '/../code/prettyPrinter', 'test');
|
||||
}
|
||||
|
||||
public function provideTestPrettyPrintFile() {
|
||||
return $this->getTests(__DIR__ . '/../code/prettyPrinter', 'file-test');
|
||||
}
|
||||
|
||||
public function testPrettyPrintExpr() {
|
||||
$prettyPrinter = new Standard;
|
||||
$expr = new Expr\BinaryOp\Mul(
|
||||
new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b')),
|
||||
new Expr\Variable('c')
|
||||
);
|
||||
$this->assertEquals('($a + $b) * $c', $prettyPrinter->prettyPrintExpr($expr));
|
||||
|
||||
$expr = new Expr\Closure(array(
|
||||
'stmts' => array(new Stmt\Return_(new String_("a\nb")))
|
||||
));
|
||||
$this->assertEquals("function () {\n return 'a\nb';\n}", $prettyPrinter->prettyPrintExpr($expr));
|
||||
}
|
||||
}
|
165
vendor/nikic/php-parser/test/PhpParser/Serializer/XMLTest.php
vendored
Normal file
165
vendor/nikic/php-parser/test/PhpParser/Serializer/XMLTest.php
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Serializer;
|
||||
|
||||
use PhpParser;
|
||||
|
||||
class XMLTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PhpParser\Serializer\XML<extended>
|
||||
*/
|
||||
public function testSerialize() {
|
||||
$code = <<<CODE
|
||||
<?php
|
||||
// comment
|
||||
/** doc comment */
|
||||
function functionName(&\$a = 0, \$b = 1.0) {
|
||||
echo 'Foo';
|
||||
}
|
||||
CODE;
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AST xmlns:node="http://nikic.github.com/PHPParser/XML/node" xmlns:subNode="http://nikic.github.com/PHPParser/XML/subNode" xmlns:attribute="http://nikic.github.com/PHPParser/XML/attribute" xmlns:scalar="http://nikic.github.com/PHPParser/XML/scalar">
|
||||
<scalar:array>
|
||||
<node:Stmt_Function>
|
||||
<attribute:comments>
|
||||
<scalar:array>
|
||||
<comment isDocComment="false" line="2">// comment
|
||||
</comment>
|
||||
<comment isDocComment="true" line="3">/** doc comment */</comment>
|
||||
</scalar:array>
|
||||
</attribute:comments>
|
||||
<attribute:startLine>
|
||||
<scalar:int>4</scalar:int>
|
||||
</attribute:startLine>
|
||||
<attribute:endLine>
|
||||
<scalar:int>6</scalar:int>
|
||||
</attribute:endLine>
|
||||
<subNode:byRef>
|
||||
<scalar:false/>
|
||||
</subNode:byRef>
|
||||
<subNode:name>
|
||||
<scalar:string>functionName</scalar:string>
|
||||
</subNode:name>
|
||||
<subNode:params>
|
||||
<scalar:array>
|
||||
<node:Param>
|
||||
<attribute:startLine>
|
||||
<scalar:int>4</scalar:int>
|
||||
</attribute:startLine>
|
||||
<attribute:endLine>
|
||||
<scalar:int>4</scalar:int>
|
||||
</attribute:endLine>
|
||||
<subNode:type>
|
||||
<scalar:null/>
|
||||
</subNode:type>
|
||||
<subNode:byRef>
|
||||
<scalar:true/>
|
||||
</subNode:byRef>
|
||||
<subNode:variadic>
|
||||
<scalar:false/>
|
||||
</subNode:variadic>
|
||||
<subNode:name>
|
||||
<scalar:string>a</scalar:string>
|
||||
</subNode:name>
|
||||
<subNode:default>
|
||||
<node:Scalar_LNumber>
|
||||
<attribute:startLine>
|
||||
<scalar:int>4</scalar:int>
|
||||
</attribute:startLine>
|
||||
<attribute:endLine>
|
||||
<scalar:int>4</scalar:int>
|
||||
</attribute:endLine>
|
||||
<subNode:value>
|
||||
<scalar:int>0</scalar:int>
|
||||
</subNode:value>
|
||||
</node:Scalar_LNumber>
|
||||
</subNode:default>
|
||||
</node:Param>
|
||||
<node:Param>
|
||||
<attribute:startLine>
|
||||
<scalar:int>4</scalar:int>
|
||||
</attribute:startLine>
|
||||
<attribute:endLine>
|
||||
<scalar:int>4</scalar:int>
|
||||
</attribute:endLine>
|
||||
<subNode:type>
|
||||
<scalar:null/>
|
||||
</subNode:type>
|
||||
<subNode:byRef>
|
||||
<scalar:false/>
|
||||
</subNode:byRef>
|
||||
<subNode:variadic>
|
||||
<scalar:false/>
|
||||
</subNode:variadic>
|
||||
<subNode:name>
|
||||
<scalar:string>b</scalar:string>
|
||||
</subNode:name>
|
||||
<subNode:default>
|
||||
<node:Scalar_DNumber>
|
||||
<attribute:startLine>
|
||||
<scalar:int>4</scalar:int>
|
||||
</attribute:startLine>
|
||||
<attribute:endLine>
|
||||
<scalar:int>4</scalar:int>
|
||||
</attribute:endLine>
|
||||
<subNode:value>
|
||||
<scalar:float>1</scalar:float>
|
||||
</subNode:value>
|
||||
</node:Scalar_DNumber>
|
||||
</subNode:default>
|
||||
</node:Param>
|
||||
</scalar:array>
|
||||
</subNode:params>
|
||||
<subNode:returnType>
|
||||
<scalar:null/>
|
||||
</subNode:returnType>
|
||||
<subNode:stmts>
|
||||
<scalar:array>
|
||||
<node:Stmt_Echo>
|
||||
<attribute:startLine>
|
||||
<scalar:int>5</scalar:int>
|
||||
</attribute:startLine>
|
||||
<attribute:endLine>
|
||||
<scalar:int>5</scalar:int>
|
||||
</attribute:endLine>
|
||||
<subNode:exprs>
|
||||
<scalar:array>
|
||||
<node:Scalar_String>
|
||||
<attribute:startLine>
|
||||
<scalar:int>5</scalar:int>
|
||||
</attribute:startLine>
|
||||
<attribute:endLine>
|
||||
<scalar:int>5</scalar:int>
|
||||
</attribute:endLine>
|
||||
<subNode:value>
|
||||
<scalar:string>Foo</scalar:string>
|
||||
</subNode:value>
|
||||
</node:Scalar_String>
|
||||
</scalar:array>
|
||||
</subNode:exprs>
|
||||
</node:Stmt_Echo>
|
||||
</scalar:array>
|
||||
</subNode:stmts>
|
||||
</node:Stmt_Function>
|
||||
</scalar:array>
|
||||
</AST>
|
||||
XML;
|
||||
|
||||
$parser = new PhpParser\Parser(new PhpParser\Lexer);
|
||||
$serializer = new XML;
|
||||
|
||||
$stmts = $parser->parse($code);
|
||||
$this->assertXmlStringEqualsXmlString($xml, $serializer->serialize($stmts));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Unexpected node type
|
||||
*/
|
||||
public function testError() {
|
||||
$serializer = new XML;
|
||||
$serializer->serialize(array(new \stdClass));
|
||||
}
|
||||
}
|
150
vendor/nikic/php-parser/test/PhpParser/Unserializer/XMLTest.php
vendored
Normal file
150
vendor/nikic/php-parser/test/PhpParser/Unserializer/XMLTest.php
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace PhpParser\Unserializer;
|
||||
|
||||
use PhpParser\Node\Scalar;
|
||||
use PhpParser\Comment;
|
||||
|
||||
class XMLTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testNode() {
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AST xmlns:node="http://nikic.github.com/PHPParser/XML/node" xmlns:subNode="http://nikic.github.com/PHPParser/XML/subNode" xmlns:attribute="http://nikic.github.com/PHPParser/XML/attribute" xmlns:scalar="http://nikic.github.com/PHPParser/XML/scalar">
|
||||
<node:Scalar_String line="1" docComment="/** doc comment */">
|
||||
<attribute:startLine>
|
||||
<scalar:int>1</scalar:int>
|
||||
</attribute:startLine>
|
||||
<attribute:comments>
|
||||
<scalar:array>
|
||||
<comment isDocComment="false" line="2">// comment
|
||||
</comment>
|
||||
<comment isDocComment="true" line="3">/** doc comment */</comment>
|
||||
</scalar:array>
|
||||
</attribute:comments>
|
||||
<subNode:value>
|
||||
<scalar:string>Test</scalar:string>
|
||||
</subNode:value>
|
||||
</node:Scalar_String>
|
||||
</AST>
|
||||
XML;
|
||||
|
||||
$unserializer = new XML;
|
||||
$this->assertEquals(
|
||||
new Scalar\String_('Test', array(
|
||||
'startLine' => 1,
|
||||
'comments' => array(
|
||||
new Comment('// comment' . "\n", 2),
|
||||
new Comment\Doc('/** doc comment */', 3),
|
||||
),
|
||||
)),
|
||||
$unserializer->unserialize($xml)
|
||||
);
|
||||
}
|
||||
|
||||
public function testEmptyNode() {
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AST xmlns:node="http://nikic.github.com/PHPParser/XML/node">
|
||||
<node:Scalar_MagicConst_Class />
|
||||
</AST>
|
||||
XML;
|
||||
|
||||
$unserializer = new XML;
|
||||
|
||||
$this->assertEquals(
|
||||
new Scalar\MagicConst\Class_,
|
||||
$unserializer->unserialize($xml)
|
||||
);
|
||||
}
|
||||
|
||||
public function testScalars() {
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AST xmlns:scalar="http://nikic.github.com/PHPParser/XML/scalar">
|
||||
<scalar:array>
|
||||
<scalar:array></scalar:array>
|
||||
<scalar:array/>
|
||||
<scalar:string>test</scalar:string>
|
||||
<scalar:string></scalar:string>
|
||||
<scalar:string/>
|
||||
<scalar:int>1</scalar:int>
|
||||
<scalar:float>1</scalar:float>
|
||||
<scalar:float>1.5</scalar:float>
|
||||
<scalar:true/>
|
||||
<scalar:false/>
|
||||
<scalar:null/>
|
||||
</scalar:array>
|
||||
</AST>
|
||||
XML;
|
||||
$result = array(
|
||||
array(), array(),
|
||||
'test', '', '',
|
||||
1,
|
||||
1, 1.5,
|
||||
true, false, null
|
||||
);
|
||||
|
||||
$unserializer = new XML;
|
||||
$this->assertEquals($result, $unserializer->unserialize($xml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \DomainException
|
||||
* @expectedExceptionMessage AST root element not found
|
||||
*/
|
||||
public function testWrongRootElementError() {
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<notAST/>
|
||||
XML;
|
||||
|
||||
$unserializer = new XML;
|
||||
$unserializer->unserialize($xml);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestErrors
|
||||
*/
|
||||
public function testErrors($xml, $errorMsg) {
|
||||
$this->setExpectedException('DomainException', $errorMsg);
|
||||
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AST xmlns:scalar="http://nikic.github.com/PHPParser/XML/scalar"
|
||||
xmlns:node="http://nikic.github.com/PHPParser/XML/node"
|
||||
xmlns:subNode="http://nikic.github.com/PHPParser/XML/subNode"
|
||||
xmlns:foo="http://nikic.github.com/PHPParser/XML/foo">
|
||||
$xml
|
||||
</AST>
|
||||
XML;
|
||||
|
||||
$unserializer = new XML;
|
||||
$unserializer->unserialize($xml);
|
||||
}
|
||||
|
||||
public function provideTestErrors() {
|
||||
return array(
|
||||
array('<scalar:true>test</scalar:true>', '"true" scalar must be empty'),
|
||||
array('<scalar:false>test</scalar:false>', '"false" scalar must be empty'),
|
||||
array('<scalar:null>test</scalar:null>', '"null" scalar must be empty'),
|
||||
array('<scalar:foo>bar</scalar:foo>', 'Unknown scalar type "foo"'),
|
||||
array('<scalar:int>x</scalar:int>', '"x" is not a valid int'),
|
||||
array('<scalar:float>x</scalar:float>', '"x" is not a valid float'),
|
||||
array('', 'Expected node or scalar'),
|
||||
array('<foo:bar>test</foo:bar>', 'Unexpected node of type "foo:bar"'),
|
||||
array(
|
||||
'<node:Scalar_String><foo:bar>test</foo:bar></node:Scalar_String>',
|
||||
'Expected sub node or attribute, got node of type "foo:bar"'
|
||||
),
|
||||
array(
|
||||
'<node:Scalar_String><subNode:value/></node:Scalar_String>',
|
||||
'Expected node or scalar'
|
||||
),
|
||||
array(
|
||||
'<node:Foo><subNode:value/></node:Foo>',
|
||||
'Unknown node type "Foo"'
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
13
vendor/nikic/php-parser/test/code/parser/errorHandling/eofError.test
vendored
Normal file
13
vendor/nikic/php-parser/test/code/parser/errorHandling/eofError.test
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Error positions
|
||||
-----
|
||||
<?php foo
|
||||
-----
|
||||
Syntax error, unexpected EOF from 1:10 to 1:10
|
||||
array(
|
||||
)
|
||||
-----
|
||||
<?php foo /* bar */
|
||||
-----
|
||||
Syntax error, unexpected EOF from 1:20 to 1:20
|
||||
array(
|
||||
)
|
186
vendor/nikic/php-parser/test/code/parser/errorHandling/recovery.test
vendored
Normal file
186
vendor/nikic/php-parser/test/code/parser/errorHandling/recovery.test
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
Error recovery
|
||||
-----
|
||||
<?php
|
||||
|
||||
foo()
|
||||
bar()
|
||||
baz()
|
||||
-----
|
||||
Syntax error, unexpected T_STRING from 4:1 to 4:3
|
||||
Syntax error, unexpected T_STRING from 5:1 to 5:3
|
||||
Syntax error, unexpected EOF from 5:6 to 5:6
|
||||
array(
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
|
||||
foo()
|
||||
bar();
|
||||
baz();
|
||||
-----
|
||||
Syntax error, unexpected T_STRING from 4:1 to 4:3
|
||||
array(
|
||||
0: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: bar
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
1: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: baz
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
|
||||
foo();
|
||||
bar()
|
||||
baz();
|
||||
-----
|
||||
Syntax error, unexpected T_STRING from 5:1 to 5:3
|
||||
array(
|
||||
0: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: foo
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
1: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: baz
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
abc;
|
||||
1 + ;
|
||||
-----
|
||||
Syntax error, unexpected ';' from 3:5 to 3:5
|
||||
array(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: abc
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
1 +
|
||||
}
|
||||
-----
|
||||
Syntax error, unexpected '}' from 4:1 to 4:1
|
||||
array(
|
||||
0: Stmt_Function(
|
||||
byRef: false
|
||||
name: test
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
|
||||
$i = 0;
|
||||
while
|
||||
|
||||
$j = 1;
|
||||
$k = 2;
|
||||
-----
|
||||
Syntax error, unexpected T_VARIABLE, expecting '(' from 6:1 to 6:2
|
||||
array(
|
||||
0: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: i
|
||||
)
|
||||
expr: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
1: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: j
|
||||
)
|
||||
expr: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
2: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: k
|
||||
)
|
||||
expr: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
|
||||
$i = 0;
|
||||
while () {
|
||||
$j = 1;
|
||||
}
|
||||
$k = 2;
|
||||
// The output here drops the loop - would require Error node to handle this
|
||||
-----
|
||||
Syntax error, unexpected ')' from 4:8 to 4:8
|
||||
array(
|
||||
0: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: i
|
||||
)
|
||||
expr: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
1: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: j
|
||||
)
|
||||
expr: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
2: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: k
|
||||
)
|
||||
expr: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
// Can't recover this yet, as the '}' for the inner_statement_list
|
||||
// is always required.
|
||||
|
||||
$i = 0;
|
||||
while (true) {
|
||||
$i = 1;
|
||||
$i = 2;
|
||||
-----
|
||||
Syntax error, unexpected EOF from 8:12 to 8:12
|
139
vendor/nikic/php-parser/test/code/parser/expr/arrayDef.test
vendored
Normal file
139
vendor/nikic/php-parser/test/code/parser/expr/arrayDef.test
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
Array definitions
|
||||
-----
|
||||
<?php
|
||||
|
||||
array();
|
||||
array('a');
|
||||
array('a', );
|
||||
array('a', 'b');
|
||||
array('a', &$b, 'c' => 'd', 'e' => &$f);
|
||||
|
||||
// short array syntax
|
||||
[];
|
||||
[1, 2, 3];
|
||||
['a' => 'b'];
|
||||
-----
|
||||
array(
|
||||
0: Expr_Array(
|
||||
items: array(
|
||||
)
|
||||
)
|
||||
1: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: a
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: a
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: a
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: a
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
byRef: true
|
||||
)
|
||||
2: Expr_ArrayItem(
|
||||
key: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
value: Scalar_String(
|
||||
value: d
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
3: Expr_ArrayItem(
|
||||
key: Scalar_String(
|
||||
value: e
|
||||
)
|
||||
value: Expr_Variable(
|
||||
name: f
|
||||
)
|
||||
byRef: true
|
||||
)
|
||||
)
|
||||
)
|
||||
5: Expr_Array(
|
||||
items: array(
|
||||
)
|
||||
)
|
||||
6: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
2: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
7: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: Scalar_String(
|
||||
value: a
|
||||
)
|
||||
value: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
255
vendor/nikic/php-parser/test/code/parser/expr/assign.test
vendored
Normal file
255
vendor/nikic/php-parser/test/code/parser/expr/assign.test
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
Assignments
|
||||
-----
|
||||
<?php
|
||||
// simple assign
|
||||
$a = $b;
|
||||
|
||||
// combined assign
|
||||
$a &= $b;
|
||||
$a |= $b;
|
||||
$a ^= $b;
|
||||
$a .= $b;
|
||||
$a /= $b;
|
||||
$a -= $b;
|
||||
$a %= $b;
|
||||
$a *= $b;
|
||||
$a += $b;
|
||||
$a <<= $b;
|
||||
$a >>= $b;
|
||||
$a **= $b;
|
||||
|
||||
// chained assign
|
||||
$a = $b *= $c **= $d;
|
||||
|
||||
// by ref assign
|
||||
$a =& $b;
|
||||
$a =& new B;
|
||||
|
||||
// list() assign
|
||||
list($a) = $b;
|
||||
list($a, , $b) = $c;
|
||||
list($a, list(, $c), $d) = $e;
|
||||
|
||||
// inc/dec
|
||||
++$a;
|
||||
$a++;
|
||||
--$a;
|
||||
$a--;
|
||||
-----
|
||||
array(
|
||||
0: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
1: Expr_AssignOp_BitwiseAnd(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
2: Expr_AssignOp_BitwiseOr(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
3: Expr_AssignOp_BitwiseXor(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
4: Expr_AssignOp_Concat(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
5: Expr_AssignOp_Div(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
6: Expr_AssignOp_Minus(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
7: Expr_AssignOp_Mod(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
8: Expr_AssignOp_Mul(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
9: Expr_AssignOp_Plus(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
10: Expr_AssignOp_ShiftLeft(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
11: Expr_AssignOp_ShiftRight(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
12: Expr_AssignOp_Pow(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
13: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_AssignOp_Mul(
|
||||
var: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
expr: Expr_AssignOp_Pow(
|
||||
var: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: d
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
14: Expr_AssignRef(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
15: Expr_AssignRef(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: B
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
16: Expr_Assign(
|
||||
var: Expr_List(
|
||||
vars: array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
17: Expr_Assign(
|
||||
var: Expr_List(
|
||||
vars: array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
1: null
|
||||
2: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
18: Expr_Assign(
|
||||
var: Expr_List(
|
||||
vars: array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
1: Expr_List(
|
||||
vars: array(
|
||||
0: null
|
||||
1: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Expr_Variable(
|
||||
name: d
|
||||
)
|
||||
)
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: e
|
||||
)
|
||||
)
|
||||
19: Expr_PreInc(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
20: Expr_PostInc(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
21: Expr_PreDec(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
22: Expr_PostDec(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
72
vendor/nikic/php-parser/test/code/parser/expr/cast.test
vendored
Normal file
72
vendor/nikic/php-parser/test/code/parser/expr/cast.test
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
Casts
|
||||
-----
|
||||
<?php
|
||||
(array) $a;
|
||||
(bool) $a;
|
||||
(boolean) $a;
|
||||
(real) $a;
|
||||
(double) $a;
|
||||
(float) $a;
|
||||
(int) $a;
|
||||
(integer) $a;
|
||||
(object) $a;
|
||||
(string) $a;
|
||||
(unset) $a;
|
||||
-----
|
||||
array(
|
||||
0: Expr_Cast_Array(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
1: Expr_Cast_Bool(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
2: Expr_Cast_Bool(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
3: Expr_Cast_Double(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
4: Expr_Cast_Double(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
5: Expr_Cast_Double(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
6: Expr_Cast_Int(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
7: Expr_Cast_Int(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
8: Expr_Cast_Object(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
9: Expr_Cast_String(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
10: Expr_Cast_Unset(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
13
vendor/nikic/php-parser/test/code/parser/expr/clone.test
vendored
Normal file
13
vendor/nikic/php-parser/test/code/parser/expr/clone.test
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Clone
|
||||
-----
|
||||
<?php
|
||||
|
||||
clone $a;
|
||||
-----
|
||||
array(
|
||||
0: Expr_Clone(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
142
vendor/nikic/php-parser/test/code/parser/expr/closure.test
vendored
Normal file
142
vendor/nikic/php-parser/test/code/parser/expr/closure.test
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
Closures
|
||||
-----
|
||||
<?php
|
||||
function($a) { $a; };
|
||||
function($a) use($b) {};
|
||||
function() use($a, &$b) {};
|
||||
function &($a) {};
|
||||
static function() {};
|
||||
function($a) : array {};
|
||||
function() use($a) : \Foo\Bar {};
|
||||
-----
|
||||
array(
|
||||
0: Expr_Closure(
|
||||
static: false
|
||||
byRef: false
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: a
|
||||
default: null
|
||||
)
|
||||
)
|
||||
uses: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Expr_Closure(
|
||||
static: false
|
||||
byRef: false
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: a
|
||||
default: null
|
||||
)
|
||||
)
|
||||
uses: array(
|
||||
0: Expr_ClosureUse(
|
||||
var: b
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
2: Expr_Closure(
|
||||
static: false
|
||||
byRef: false
|
||||
params: array(
|
||||
)
|
||||
uses: array(
|
||||
0: Expr_ClosureUse(
|
||||
var: a
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ClosureUse(
|
||||
var: b
|
||||
byRef: true
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
3: Expr_Closure(
|
||||
static: false
|
||||
byRef: true
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: a
|
||||
default: null
|
||||
)
|
||||
)
|
||||
uses: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
4: Expr_Closure(
|
||||
static: true
|
||||
byRef: false
|
||||
params: array(
|
||||
)
|
||||
uses: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
5: Expr_Closure(
|
||||
static: false
|
||||
byRef: false
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: a
|
||||
default: null
|
||||
)
|
||||
)
|
||||
uses: array(
|
||||
)
|
||||
returnType: array
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
6: Expr_Closure(
|
||||
static: false
|
||||
byRef: false
|
||||
params: array(
|
||||
)
|
||||
uses: array(
|
||||
0: Expr_ClosureUse(
|
||||
var: a
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
returnType: Name_FullyQualified(
|
||||
parts: array(
|
||||
0: Foo
|
||||
1: Bar
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
107
vendor/nikic/php-parser/test/code/parser/expr/comparison.test
vendored
Normal file
107
vendor/nikic/php-parser/test/code/parser/expr/comparison.test
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
Comparison operators
|
||||
-----
|
||||
<?php
|
||||
$a < $b;
|
||||
$a <= $b;
|
||||
$a > $b;
|
||||
$a >= $b;
|
||||
$a == $b;
|
||||
$a === $b;
|
||||
$a != $b;
|
||||
$a !== $b;
|
||||
$a <=> $b;
|
||||
$a instanceof B;
|
||||
$a instanceof $b;
|
||||
-----
|
||||
array(
|
||||
0: Expr_BinaryOp_Smaller(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
1: Expr_BinaryOp_SmallerOrEqual(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
2: Expr_BinaryOp_Greater(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
3: Expr_BinaryOp_GreaterOrEqual(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
4: Expr_BinaryOp_Equal(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
5: Expr_BinaryOp_Identical(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
6: Expr_BinaryOp_NotEqual(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
7: Expr_BinaryOp_NotIdentical(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
8: Expr_BinaryOp_Spaceship(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
9: Expr_Instanceof(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: B
|
||||
)
|
||||
)
|
||||
)
|
||||
10: Expr_Instanceof(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
class: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
)
|
621
vendor/nikic/php-parser/test/code/parser/expr/constant_expr.test
vendored
Normal file
621
vendor/nikic/php-parser/test/code/parser/expr/constant_expr.test
vendored
Normal file
@@ -0,0 +1,621 @@
|
||||
Expressions in static scalar context
|
||||
-----
|
||||
<?php
|
||||
|
||||
const T_1 = 1 << 1;
|
||||
const T_2 = 1 / 2;
|
||||
const T_3 = 1.5 + 1.5;
|
||||
const T_4 = "foo" . "bar";
|
||||
const T_5 = (1.5 + 1.5) * 2;
|
||||
const T_6 = "foo" . 2 . 3 . 4.0;
|
||||
const T_7 = __LINE__;
|
||||
const T_8 = <<<ENDOFSTRING
|
||||
This is a test string
|
||||
ENDOFSTRING;
|
||||
const T_9 = ~-1;
|
||||
const T_10 = (-1?:1) + (0?2:3);
|
||||
const T_11 = 1 && 0;
|
||||
const T_12 = 1 and 1;
|
||||
const T_13 = 0 || 0;
|
||||
const T_14 = 1 or 0;
|
||||
const T_15 = 1 xor 1;
|
||||
const T_16 = 1 xor 0;
|
||||
const T_17 = 1 < 0;
|
||||
const T_18 = 0 <= 0;
|
||||
const T_19 = 1 > 0;
|
||||
const T_20 = 1 >= 0;
|
||||
const T_21 = 1 === 1;
|
||||
const T_22 = 1 !== 1;
|
||||
const T_23 = 0 != "0";
|
||||
const T_24 = 1 == "1";
|
||||
const T_25 = 1 + 2 * 3;
|
||||
const T_26 = "1" + 2 + "3";
|
||||
const T_27 = 2 ** 3;
|
||||
const T_28 = [1, 2, 3][1];
|
||||
const T_29 = 12 - 13;
|
||||
const T_30 = 12 ^ 13;
|
||||
const T_31 = 12 & 13;
|
||||
const T_32 = 12 | 13;
|
||||
const T_33 = 12 % 3;
|
||||
const T_34 = 100 >> 4;
|
||||
const T_35 = !false;
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_1
|
||||
value: Expr_BinaryOp_ShiftLeft(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_2
|
||||
value: Expr_BinaryOp_Div(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_3
|
||||
value: Expr_BinaryOp_Plus(
|
||||
left: Scalar_DNumber(
|
||||
value: 1.5
|
||||
)
|
||||
right: Scalar_DNumber(
|
||||
value: 1.5
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_4
|
||||
value: Expr_BinaryOp_Concat(
|
||||
left: Scalar_String(
|
||||
value: foo
|
||||
)
|
||||
right: Scalar_String(
|
||||
value: bar
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_5
|
||||
value: Expr_BinaryOp_Mul(
|
||||
left: Expr_BinaryOp_Plus(
|
||||
left: Scalar_DNumber(
|
||||
value: 1.5
|
||||
)
|
||||
right: Scalar_DNumber(
|
||||
value: 1.5
|
||||
)
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
5: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_6
|
||||
value: Expr_BinaryOp_Concat(
|
||||
left: Expr_BinaryOp_Concat(
|
||||
left: Expr_BinaryOp_Concat(
|
||||
left: Scalar_String(
|
||||
value: foo
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
)
|
||||
right: Scalar_DNumber(
|
||||
value: 4
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
6: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_7
|
||||
value: Scalar_MagicConst_Line(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
7: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_8
|
||||
value: Scalar_String(
|
||||
value: This is a test string
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
8: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_9
|
||||
value: Expr_BitwiseNot(
|
||||
expr: Expr_UnaryMinus(
|
||||
expr: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
9: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_10
|
||||
value: Expr_BinaryOp_Plus(
|
||||
left: Expr_Ternary(
|
||||
cond: Expr_UnaryMinus(
|
||||
expr: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
if: null
|
||||
else: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
right: Expr_Ternary(
|
||||
cond: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
if: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
else: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
10: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_11
|
||||
value: Expr_BinaryOp_BooleanAnd(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
11: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_12
|
||||
value: Expr_BinaryOp_LogicalAnd(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
12: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_13
|
||||
value: Expr_BinaryOp_BooleanOr(
|
||||
left: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
13: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_14
|
||||
value: Expr_BinaryOp_LogicalOr(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
14: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_15
|
||||
value: Expr_BinaryOp_LogicalXor(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
15: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_16
|
||||
value: Expr_BinaryOp_LogicalXor(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
16: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_17
|
||||
value: Expr_BinaryOp_Smaller(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
17: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_18
|
||||
value: Expr_BinaryOp_SmallerOrEqual(
|
||||
left: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
18: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_19
|
||||
value: Expr_BinaryOp_Greater(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
19: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_20
|
||||
value: Expr_BinaryOp_GreaterOrEqual(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
20: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_21
|
||||
value: Expr_BinaryOp_Identical(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
21: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_22
|
||||
value: Expr_BinaryOp_NotIdentical(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
22: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_23
|
||||
value: Expr_BinaryOp_NotEqual(
|
||||
left: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
right: Scalar_String(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
23: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_24
|
||||
value: Expr_BinaryOp_Equal(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_String(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
24: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_25
|
||||
value: Expr_BinaryOp_Plus(
|
||||
left: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
right: Expr_BinaryOp_Mul(
|
||||
left: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
25: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_26
|
||||
value: Expr_BinaryOp_Plus(
|
||||
left: Expr_BinaryOp_Plus(
|
||||
left: Scalar_String(
|
||||
value: 1
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
right: Scalar_String(
|
||||
value: 3
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
26: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_27
|
||||
value: Expr_BinaryOp_Pow(
|
||||
left: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
27: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_28
|
||||
value: Expr_ArrayDimFetch(
|
||||
var: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
2: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
28: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_29
|
||||
value: Expr_BinaryOp_Minus(
|
||||
left: Scalar_LNumber(
|
||||
value: 12
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 13
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
29: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_30
|
||||
value: Expr_BinaryOp_BitwiseXor(
|
||||
left: Scalar_LNumber(
|
||||
value: 12
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 13
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
30: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_31
|
||||
value: Expr_BinaryOp_BitwiseAnd(
|
||||
left: Scalar_LNumber(
|
||||
value: 12
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 13
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
31: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_32
|
||||
value: Expr_BinaryOp_BitwiseOr(
|
||||
left: Scalar_LNumber(
|
||||
value: 12
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 13
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
32: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_33
|
||||
value: Expr_BinaryOp_Mod(
|
||||
left: Scalar_LNumber(
|
||||
value: 12
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
33: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_34
|
||||
value: Expr_BinaryOp_ShiftRight(
|
||||
left: Scalar_LNumber(
|
||||
value: 100
|
||||
)
|
||||
right: Scalar_LNumber(
|
||||
value: 4
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
34: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: T_35
|
||||
value: Expr_BooleanNot(
|
||||
expr: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: false
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
12
vendor/nikic/php-parser/test/code/parser/expr/errorSuppress.test
vendored
Normal file
12
vendor/nikic/php-parser/test/code/parser/expr/errorSuppress.test
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
Error suppression
|
||||
-----
|
||||
<?php
|
||||
@$a;
|
||||
-----
|
||||
array(
|
||||
0: Expr_ErrorSuppress(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
34
vendor/nikic/php-parser/test/code/parser/expr/exit.test
vendored
Normal file
34
vendor/nikic/php-parser/test/code/parser/expr/exit.test
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
Exit
|
||||
-----
|
||||
<?php
|
||||
exit;
|
||||
exit();
|
||||
exit('Die!');
|
||||
die;
|
||||
die();
|
||||
die('Exit!');
|
||||
-----
|
||||
array(
|
||||
0: Expr_Exit(
|
||||
expr: null
|
||||
)
|
||||
1: Expr_Exit(
|
||||
expr: null
|
||||
)
|
||||
2: Expr_Exit(
|
||||
expr: Scalar_String(
|
||||
value: Die!
|
||||
)
|
||||
)
|
||||
3: Expr_Exit(
|
||||
expr: null
|
||||
)
|
||||
4: Expr_Exit(
|
||||
expr: null
|
||||
)
|
||||
5: Expr_Exit(
|
||||
expr: Scalar_String(
|
||||
value: Exit!
|
||||
)
|
||||
)
|
||||
)
|
99
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/args.test
vendored
Normal file
99
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/args.test
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
Arguments
|
||||
-----
|
||||
<?php
|
||||
|
||||
f();
|
||||
f($a);
|
||||
f($a, $b);
|
||||
f(&$a);
|
||||
f($a, ...$b);
|
||||
-----
|
||||
array(
|
||||
0: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: f
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
1: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: f
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: f
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
1: Arg(
|
||||
value: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: f
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
byRef: true
|
||||
unpack: false
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: f
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
1: Arg(
|
||||
value: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
byRef: false
|
||||
unpack: true
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
33
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/constFetch.test
vendored
Normal file
33
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/constFetch.test
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
Constant fetches
|
||||
-----
|
||||
<?php
|
||||
|
||||
A;
|
||||
A::B;
|
||||
A::class;
|
||||
-----
|
||||
array(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Expr_ClassConstFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: B
|
||||
)
|
||||
2: Expr_ClassConstFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: class
|
||||
)
|
||||
)
|
231
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/constantDeref.test
vendored
Normal file
231
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/constantDeref.test
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
Array/string dereferencing
|
||||
-----
|
||||
<?php
|
||||
|
||||
"abc"[2];
|
||||
"abc"[2][0][0];
|
||||
|
||||
[1, 2, 3][2];
|
||||
[1, 2, 3][2][0][0];
|
||||
|
||||
array(1, 2, 3)[2];
|
||||
array(1, 2, 3)[2][0][0];
|
||||
|
||||
FOO[0];
|
||||
Foo::BAR[1];
|
||||
$foo::BAR[2][1][0];
|
||||
-----
|
||||
array(
|
||||
0: Expr_ArrayDimFetch(
|
||||
var: Scalar_String(
|
||||
value: abc
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
1: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Scalar_String(
|
||||
value: abc
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
2: Expr_ArrayDimFetch(
|
||||
var: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
2: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
3: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
2: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
4: Expr_ArrayDimFetch(
|
||||
var: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
2: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
5: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
2: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
6: Expr_ArrayDimFetch(
|
||||
var: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: FOO
|
||||
)
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
7: Expr_ArrayDimFetch(
|
||||
var: Expr_ClassConstFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: Foo
|
||||
)
|
||||
)
|
||||
name: BAR
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
8: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_ClassConstFetch(
|
||||
class: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
name: BAR
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
117
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/funcCall.test
vendored
Normal file
117
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/funcCall.test
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
Function calls
|
||||
-----
|
||||
<?php
|
||||
|
||||
// function name variations
|
||||
a();
|
||||
$a();
|
||||
${'a'}();
|
||||
$$a();
|
||||
$$$a();
|
||||
$a['b']();
|
||||
$a{'b'}();
|
||||
$a->b['c']();
|
||||
|
||||
// array dereferencing
|
||||
a()['b'];
|
||||
-----
|
||||
array(
|
||||
0: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: a
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
1: Expr_FuncCall(
|
||||
name: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
2: Expr_FuncCall(
|
||||
name: Expr_Variable(
|
||||
name: Scalar_String(
|
||||
value: a
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
3: Expr_FuncCall(
|
||||
name: Expr_Variable(
|
||||
name: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
4: Expr_FuncCall(
|
||||
name: Expr_Variable(
|
||||
name: Expr_Variable(
|
||||
name: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
5: Expr_FuncCall(
|
||||
name: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
6: Expr_FuncCall(
|
||||
name: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
7: Expr_FuncCall(
|
||||
name: Expr_ArrayDimFetch(
|
||||
var: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
8: Expr_ArrayDimFetch(
|
||||
var: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: a
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
)
|
70
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/newDeref.test
vendored
Normal file
70
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/newDeref.test
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
New expression dereferencing
|
||||
-----
|
||||
<?php
|
||||
|
||||
(new A)->b;
|
||||
(new A)->b();
|
||||
(new A)['b'];
|
||||
(new A)['b']['c'];
|
||||
-----
|
||||
array(
|
||||
0: Expr_PropertyFetch(
|
||||
var: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
name: b
|
||||
)
|
||||
1: Expr_MethodCall(
|
||||
var: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
name: b
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
2: Expr_ArrayDimFetch(
|
||||
var: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
3: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
)
|
118
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/objectAccess.test
vendored
Normal file
118
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/objectAccess.test
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
Object access
|
||||
-----
|
||||
<?php
|
||||
|
||||
// property fetch variations
|
||||
$a->b;
|
||||
$a->b['c'];
|
||||
$a->b{'c'};
|
||||
|
||||
// method call variations
|
||||
$a->b();
|
||||
$a->{'b'}();
|
||||
$a->$b();
|
||||
$a->$b['c']();
|
||||
|
||||
// array dereferencing
|
||||
$a->b()['c'];
|
||||
$a->b(){'c'}; // invalid PHP: drop Support?
|
||||
-----
|
||||
array(
|
||||
0: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
)
|
||||
1: Expr_ArrayDimFetch(
|
||||
var: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
2: Expr_ArrayDimFetch(
|
||||
var: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
3: Expr_MethodCall(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
4: Expr_MethodCall(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
5: Expr_MethodCall(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
6: Expr_MethodCall(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
7: Expr_ArrayDimFetch(
|
||||
var: Expr_MethodCall(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
8: Expr_ArrayDimFetch(
|
||||
var: Expr_MethodCall(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
)
|
62
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/simpleArrayAccess.test
vendored
Normal file
62
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/simpleArrayAccess.test
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
Simple array access
|
||||
-----
|
||||
<?php
|
||||
|
||||
$a['b'];
|
||||
$a['b']['c'];
|
||||
$a[] = $b;
|
||||
$a{'b'};
|
||||
${$a}['b'];
|
||||
-----
|
||||
array(
|
||||
0: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
1: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
2: Expr_Assign(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
dim: null
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
3: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
4: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
)
|
151
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/staticCall.test
vendored
Normal file
151
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/staticCall.test
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
Static calls
|
||||
-----
|
||||
<?php
|
||||
|
||||
// method name variations
|
||||
A::b();
|
||||
A::{'b'}();
|
||||
A::$b();
|
||||
A::$b['c']();
|
||||
A::$b['c']['d']();
|
||||
|
||||
// array dereferencing
|
||||
A::b()['c'];
|
||||
|
||||
// class name variations
|
||||
static::b();
|
||||
$a::b();
|
||||
${'a'}::b();
|
||||
$a['b']::c();
|
||||
-----
|
||||
array(
|
||||
0: Expr_StaticCall(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: b
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
1: Expr_StaticCall(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
2: Expr_StaticCall(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
3: Expr_StaticCall(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
4: Expr_StaticCall(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: d
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
5: Expr_ArrayDimFetch(
|
||||
var: Expr_StaticCall(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: b
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
6: Expr_StaticCall(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: static
|
||||
)
|
||||
)
|
||||
name: b
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
7: Expr_StaticCall(
|
||||
class: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
8: Expr_StaticCall(
|
||||
class: Expr_Variable(
|
||||
name: Scalar_String(
|
||||
value: a
|
||||
)
|
||||
)
|
||||
name: b
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
9: Expr_StaticCall(
|
||||
class: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
name: c
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
71
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/staticPropertyFetch.test
vendored
Normal file
71
vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/staticPropertyFetch.test
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
Static property fetches
|
||||
-----
|
||||
<?php
|
||||
|
||||
// property name variations
|
||||
A::$b;
|
||||
A::$$b;
|
||||
A::${'b'};
|
||||
|
||||
// array access
|
||||
A::$b['c'];
|
||||
A::$b{'c'};
|
||||
|
||||
// class name variations can be found in staticCall.test
|
||||
-----
|
||||
array(
|
||||
0: Expr_StaticPropertyFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: b
|
||||
)
|
||||
1: Expr_StaticPropertyFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
2: Expr_StaticPropertyFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
3: Expr_ArrayDimFetch(
|
||||
var: Expr_StaticPropertyFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: b
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
4: Expr_ArrayDimFetch(
|
||||
var: Expr_StaticPropertyFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: b
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
)
|
40
vendor/nikic/php-parser/test/code/parser/expr/includeAndEval.test
vendored
Normal file
40
vendor/nikic/php-parser/test/code/parser/expr/includeAndEval.test
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
Include and eval
|
||||
-----
|
||||
<?php
|
||||
include 'A.php';
|
||||
include_once 'A.php';
|
||||
require 'A.php';
|
||||
require_once 'A.php';
|
||||
eval('A');
|
||||
-----
|
||||
array(
|
||||
0: Expr_Include(
|
||||
expr: Scalar_String(
|
||||
value: A.php
|
||||
)
|
||||
type: 1
|
||||
)
|
||||
1: Expr_Include(
|
||||
expr: Scalar_String(
|
||||
value: A.php
|
||||
)
|
||||
type: 2
|
||||
)
|
||||
2: Expr_Include(
|
||||
expr: Scalar_String(
|
||||
value: A.php
|
||||
)
|
||||
type: 3
|
||||
)
|
||||
3: Expr_Include(
|
||||
expr: Scalar_String(
|
||||
value: A.php
|
||||
)
|
||||
type: 4
|
||||
)
|
||||
4: Expr_Eval(
|
||||
expr: Scalar_String(
|
||||
value: A
|
||||
)
|
||||
)
|
||||
)
|
75
vendor/nikic/php-parser/test/code/parser/expr/issetAndEmpty.test
vendored
Normal file
75
vendor/nikic/php-parser/test/code/parser/expr/issetAndEmpty.test
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
isset() and empty()
|
||||
-----
|
||||
<?php
|
||||
isset($a);
|
||||
isset($a, $b, $c);
|
||||
|
||||
empty($a);
|
||||
empty(foo());
|
||||
empty(array(1, 2, 3));
|
||||
-----
|
||||
array(
|
||||
0: Expr_Isset(
|
||||
vars: array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Expr_Isset(
|
||||
vars: array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
2: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Expr_Empty(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
3: Expr_Empty(
|
||||
expr: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: foo
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Expr_Empty(
|
||||
expr: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
2: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_LNumber(
|
||||
value: 3
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
138
vendor/nikic/php-parser/test/code/parser/expr/logic.test
vendored
Normal file
138
vendor/nikic/php-parser/test/code/parser/expr/logic.test
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
Logical operators
|
||||
-----
|
||||
<?php
|
||||
|
||||
// boolean ops
|
||||
$a && $b;
|
||||
$a || $b;
|
||||
!$a;
|
||||
!!$a;
|
||||
|
||||
// logical ops
|
||||
$a and $b;
|
||||
$a or $b;
|
||||
$a xor $b;
|
||||
|
||||
// precedence
|
||||
$a && $b || $c && $d;
|
||||
$a && ($b || $c) && $d;
|
||||
|
||||
$a = $b || $c;
|
||||
$a = $b or $c;
|
||||
-----
|
||||
array(
|
||||
0: Expr_BinaryOp_BooleanAnd(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
1: Expr_BinaryOp_BooleanOr(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
2: Expr_BooleanNot(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
3: Expr_BooleanNot(
|
||||
expr: Expr_BooleanNot(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Expr_BinaryOp_LogicalAnd(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
5: Expr_BinaryOp_LogicalOr(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
6: Expr_BinaryOp_LogicalXor(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
7: Expr_BinaryOp_BooleanOr(
|
||||
left: Expr_BinaryOp_BooleanAnd(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
right: Expr_BinaryOp_BooleanAnd(
|
||||
left: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: d
|
||||
)
|
||||
)
|
||||
)
|
||||
8: Expr_BinaryOp_BooleanAnd(
|
||||
left: Expr_BinaryOp_BooleanAnd(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_BinaryOp_BooleanOr(
|
||||
left: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: d
|
||||
)
|
||||
)
|
||||
9: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_BinaryOp_BooleanOr(
|
||||
left: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
||||
10: Expr_BinaryOp_LogicalOr(
|
||||
left: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
226
vendor/nikic/php-parser/test/code/parser/expr/math.test
vendored
Normal file
226
vendor/nikic/php-parser/test/code/parser/expr/math.test
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
Mathematical operators
|
||||
-----
|
||||
<?php
|
||||
|
||||
// unary ops
|
||||
~$a;
|
||||
+$a;
|
||||
-$a;
|
||||
|
||||
// binary ops
|
||||
$a & $b;
|
||||
$a | $b;
|
||||
$a ^ $b;
|
||||
$a . $b;
|
||||
$a / $b;
|
||||
$a - $b;
|
||||
$a % $b;
|
||||
$a * $b;
|
||||
$a + $b;
|
||||
$a << $b;
|
||||
$a >> $b;
|
||||
$a ** $b;
|
||||
|
||||
// associativity
|
||||
$a * $b * $c;
|
||||
$a * ($b * $c);
|
||||
|
||||
// precedence
|
||||
$a + $b * $c;
|
||||
($a + $b) * $c;
|
||||
|
||||
// pow is special
|
||||
$a ** $b ** $c;
|
||||
($a ** $b) ** $c;
|
||||
-----
|
||||
array(
|
||||
0: Expr_BitwiseNot(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
1: Expr_UnaryPlus(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
2: Expr_UnaryMinus(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
3: Expr_BinaryOp_BitwiseAnd(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
4: Expr_BinaryOp_BitwiseOr(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
5: Expr_BinaryOp_BitwiseXor(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
6: Expr_BinaryOp_Concat(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
7: Expr_BinaryOp_Div(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
8: Expr_BinaryOp_Minus(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
9: Expr_BinaryOp_Mod(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
10: Expr_BinaryOp_Mul(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
11: Expr_BinaryOp_Plus(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
12: Expr_BinaryOp_ShiftLeft(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
13: Expr_BinaryOp_ShiftRight(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
14: Expr_BinaryOp_Pow(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
15: Expr_BinaryOp_Mul(
|
||||
left: Expr_BinaryOp_Mul(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
16: Expr_BinaryOp_Mul(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_BinaryOp_Mul(
|
||||
left: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
||||
17: Expr_BinaryOp_Plus(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_BinaryOp_Mul(
|
||||
left: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
||||
18: Expr_BinaryOp_Mul(
|
||||
left: Expr_BinaryOp_Plus(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
19: Expr_BinaryOp_Pow(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_BinaryOp_Pow(
|
||||
left: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
||||
20: Expr_BinaryOp_Pow(
|
||||
left: Expr_BinaryOp_Pow(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
140
vendor/nikic/php-parser/test/code/parser/expr/new.test
vendored
Normal file
140
vendor/nikic/php-parser/test/code/parser/expr/new.test
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
New
|
||||
-----
|
||||
<?php
|
||||
|
||||
new A;
|
||||
new A($b);
|
||||
|
||||
// class name variations
|
||||
new $a();
|
||||
new $a['b']();
|
||||
new A::$b();
|
||||
// DNCR object access
|
||||
new $a->b();
|
||||
new $a->b->c();
|
||||
new $a->b['c']();
|
||||
new $a->b{'c'}();
|
||||
|
||||
// test regression introduces by new dereferencing syntax
|
||||
(new A);
|
||||
-----
|
||||
array(
|
||||
0: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
1: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Expr_New(
|
||||
class: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
3: Expr_New(
|
||||
class: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
4: Expr_New(
|
||||
class: Expr_StaticPropertyFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: b
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
5: Expr_New(
|
||||
class: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
6: Expr_New(
|
||||
class: Expr_PropertyFetch(
|
||||
var: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
)
|
||||
name: c
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
7: Expr_New(
|
||||
class: Expr_ArrayDimFetch(
|
||||
var: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
8: Expr_New(
|
||||
class: Expr_ArrayDimFetch(
|
||||
var: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
name: b
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
9: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
8
vendor/nikic/php-parser/test/code/parser/expr/newWithoutClass.test
vendored
Normal file
8
vendor/nikic/php-parser/test/code/parser/expr/newWithoutClass.test
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
New without a class
|
||||
-----
|
||||
<?php
|
||||
new;
|
||||
-----
|
||||
Syntax error, unexpected ';' from 2:4 to 2:4
|
||||
array(
|
||||
)
|
12
vendor/nikic/php-parser/test/code/parser/expr/print.test
vendored
Normal file
12
vendor/nikic/php-parser/test/code/parser/expr/print.test
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
Print
|
||||
-----
|
||||
<?php
|
||||
print $a;
|
||||
-----
|
||||
array(
|
||||
0: Expr_Print(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
38
vendor/nikic/php-parser/test/code/parser/expr/shellExec.test
vendored
Normal file
38
vendor/nikic/php-parser/test/code/parser/expr/shellExec.test
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
Shell execution
|
||||
-----
|
||||
<?php
|
||||
``;
|
||||
`test`;
|
||||
`test $A`;
|
||||
`test \``;
|
||||
`test \"`;
|
||||
-----
|
||||
array(
|
||||
0: Expr_ShellExec(
|
||||
parts: array(
|
||||
)
|
||||
)
|
||||
1: Expr_ShellExec(
|
||||
parts: array(
|
||||
0: test
|
||||
)
|
||||
)
|
||||
2: Expr_ShellExec(
|
||||
parts: array(
|
||||
0: test
|
||||
1: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Expr_ShellExec(
|
||||
parts: array(
|
||||
0: test `
|
||||
)
|
||||
)
|
||||
4: Expr_ShellExec(
|
||||
parts: array(
|
||||
0: test \"
|
||||
)
|
||||
)
|
||||
)
|
128
vendor/nikic/php-parser/test/code/parser/expr/ternaryAndCoalesce.test
vendored
Normal file
128
vendor/nikic/php-parser/test/code/parser/expr/ternaryAndCoalesce.test
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
Ternary operator
|
||||
-----
|
||||
<?php
|
||||
|
||||
// ternary
|
||||
$a ? $b : $c;
|
||||
$a ?: $c;
|
||||
|
||||
// precedence
|
||||
$a ? $b : $c ? $d : $e;
|
||||
$a ? $b : ($c ? $d : $e);
|
||||
|
||||
// null coalesce
|
||||
$a ?? $b;
|
||||
$a ?? $b ?? $c;
|
||||
$a ?? $b ? $c : $d;
|
||||
$a && $b ?? $c;
|
||||
-----
|
||||
array(
|
||||
0: Expr_Ternary(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
if: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
else: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
1: Expr_Ternary(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
if: null
|
||||
else: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
2: Expr_Ternary(
|
||||
cond: Expr_Ternary(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
if: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
else: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
if: Expr_Variable(
|
||||
name: d
|
||||
)
|
||||
else: Expr_Variable(
|
||||
name: e
|
||||
)
|
||||
)
|
||||
3: Expr_Ternary(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
if: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
else: Expr_Ternary(
|
||||
cond: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
if: Expr_Variable(
|
||||
name: d
|
||||
)
|
||||
else: Expr_Variable(
|
||||
name: e
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Expr_BinaryOp_Coalesce(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
5: Expr_BinaryOp_Coalesce(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_BinaryOp_Coalesce(
|
||||
left: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
||||
6: Expr_Ternary(
|
||||
cond: Expr_BinaryOp_Coalesce(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
if: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
else: Expr_Variable(
|
||||
name: d
|
||||
)
|
||||
)
|
||||
7: Expr_BinaryOp_Coalesce(
|
||||
left: Expr_BinaryOp_BooleanAnd(
|
||||
left: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
54
vendor/nikic/php-parser/test/code/parser/expr/variable.test
vendored
Normal file
54
vendor/nikic/php-parser/test/code/parser/expr/variable.test
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
Variable syntaxes
|
||||
-----
|
||||
<?php
|
||||
|
||||
$a;
|
||||
${'a'};
|
||||
${foo()};
|
||||
$$a;
|
||||
$$$a;
|
||||
$$a['b'];
|
||||
-----
|
||||
array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: Scalar_String(
|
||||
value: a
|
||||
)
|
||||
)
|
||||
2: Expr_Variable(
|
||||
name: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: foo
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Expr_Variable(
|
||||
name: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
4: Expr_Variable(
|
||||
name: Expr_Variable(
|
||||
name: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
5: Expr_Variable(
|
||||
name: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
53
vendor/nikic/php-parser/test/code/parser/scalar/constantString.test
vendored
Normal file
53
vendor/nikic/php-parser/test/code/parser/scalar/constantString.test
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
Constant string syntaxes
|
||||
-----
|
||||
<?php
|
||||
|
||||
'';
|
||||
"";
|
||||
b'';
|
||||
b"";
|
||||
'Hi';
|
||||
b'Hi';
|
||||
"Hi";
|
||||
b"Hi";
|
||||
'!\'!\\!\a!';
|
||||
"!\"!\\!\$!\n!\r!\t!\f!\v!\e!\a";
|
||||
"!\xFF!\377!\400!\0!";
|
||||
-----
|
||||
array(
|
||||
0: Scalar_String(
|
||||
value:
|
||||
)
|
||||
1: Scalar_String(
|
||||
value:
|
||||
)
|
||||
2: Scalar_String(
|
||||
value:
|
||||
)
|
||||
3: Scalar_String(
|
||||
value:
|
||||
)
|
||||
4: Scalar_String(
|
||||
value: Hi
|
||||
)
|
||||
5: Scalar_String(
|
||||
value: Hi
|
||||
)
|
||||
6: Scalar_String(
|
||||
value: Hi
|
||||
)
|
||||
7: Scalar_String(
|
||||
value: Hi
|
||||
)
|
||||
8: Scalar_String(
|
||||
value: !'!\!\a!
|
||||
)
|
||||
9: Scalar_String(
|
||||
value: !"!\!$!
|
||||
!
|
||||
!@@{ "\t" }@@!@@{ "\f" }@@!@@{ "\v" }@@!@@{ chr(27) /* "\e" */ }@@!\a
|
||||
)
|
||||
10: Scalar_String(
|
||||
value: !@@{ chr(255) }@@!@@{ chr(255) }@@!@@{ chr(0) }@@!@@{ chr(0) }@@!
|
||||
)
|
||||
)
|
67
vendor/nikic/php-parser/test/code/parser/scalar/docString.test
vendored
Normal file
67
vendor/nikic/php-parser/test/code/parser/scalar/docString.test
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
Nowdoc and heredoc strings
|
||||
-----
|
||||
<?php
|
||||
|
||||
// empty strings
|
||||
<<<'EOS'
|
||||
EOS;
|
||||
<<<EOS
|
||||
EOS;
|
||||
|
||||
// constant encapsed strings
|
||||
<<<'EOS'
|
||||
Test '" $a \n
|
||||
EOS;
|
||||
<<<EOS
|
||||
Test '" \$a \n
|
||||
EOS;
|
||||
|
||||
// encapsed strings
|
||||
<<<EOS
|
||||
Test $a
|
||||
EOS;
|
||||
<<<EOS
|
||||
Test $a and $b->c test
|
||||
EOS;
|
||||
|
||||
// comment to force line break before EOF
|
||||
-----
|
||||
array(
|
||||
0: Scalar_String(
|
||||
value:
|
||||
)
|
||||
1: Scalar_String(
|
||||
value:
|
||||
)
|
||||
2: Scalar_String(
|
||||
value: Test '" $a \n
|
||||
)
|
||||
3: Scalar_String(
|
||||
value: Test '" $a
|
||||
|
||||
)
|
||||
4: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Test
|
||||
1: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
5: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Test
|
||||
1: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
2: and
|
||||
3: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
name: c
|
||||
)
|
||||
4: test
|
||||
)
|
||||
)
|
||||
)
|
58
vendor/nikic/php-parser/test/code/parser/scalar/docStringNewlines.test
vendored
Normal file
58
vendor/nikic/php-parser/test/code/parser/scalar/docStringNewlines.test
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
Trailing newlines in doc strings
|
||||
-----
|
||||
<?php
|
||||
|
||||
<<<'EOF'@@{ "\n\n" }@@EOF;
|
||||
<<<'EOF'@@{ "\n\n\n" }@@EOF;
|
||||
<<<'EOF'@@{ "\nFoo\n\n" }@@EOF;
|
||||
<<<EOF@@{ "\n\$var\n\n" }@@EOF;
|
||||
|
||||
<<<'EOF'@@{ "\r\n\r\n" }@@EOF;
|
||||
<<<'EOF'@@{ "\r\n\r\n\r\n" }@@EOF;
|
||||
<<<'EOF'@@{ "\r\nFoo\r\n\r\n" }@@EOF;
|
||||
<<<EOF@@{ "\r\n\$var\r\n\r\n" }@@EOF;
|
||||
|
||||
// comment to force line break before EOF
|
||||
-----
|
||||
array(
|
||||
0: Scalar_String(
|
||||
value:
|
||||
)
|
||||
1: Scalar_String(
|
||||
value:
|
||||
|
||||
)
|
||||
2: Scalar_String(
|
||||
value: Foo
|
||||
|
||||
)
|
||||
3: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: var
|
||||
)
|
||||
1:
|
||||
|
||||
)
|
||||
)
|
||||
4: Scalar_String(
|
||||
value:
|
||||
)
|
||||
5: Scalar_String(
|
||||
value:
|
||||
|
||||
)
|
||||
6: Scalar_String(
|
||||
value: Foo
|
||||
|
||||
)
|
||||
7: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: var
|
||||
)
|
||||
1:
|
||||
|
||||
)
|
||||
)
|
||||
)
|
212
vendor/nikic/php-parser/test/code/parser/scalar/encapsedString.test
vendored
Normal file
212
vendor/nikic/php-parser/test/code/parser/scalar/encapsedString.test
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
Encapsed strings
|
||||
-----
|
||||
<?php
|
||||
|
||||
"$A";
|
||||
"$A->B";
|
||||
"$A[B]";
|
||||
"$A[0]";
|
||||
"$A[0x0]";
|
||||
"$A[$B]";
|
||||
"{$A}";
|
||||
"{$A['B']}";
|
||||
"${A}";
|
||||
"${A['B']}";
|
||||
"${$A}";
|
||||
"\{$A}";
|
||||
"\{ $A }";
|
||||
"\\{$A}";
|
||||
"\\{ $A }";
|
||||
"{$$A}[B]";
|
||||
"$$A[B]";
|
||||
"A $B C";
|
||||
b"$A";
|
||||
-----
|
||||
array(
|
||||
0: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
name: B
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: B
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: 0x0
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
5: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
dim: Expr_Variable(
|
||||
name: B
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
6: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
)
|
||||
7: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: B
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
8: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
)
|
||||
9: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: B
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
10: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
11: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: \{
|
||||
1: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
2: }
|
||||
)
|
||||
)
|
||||
12: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: \{
|
||||
1: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
2: }
|
||||
)
|
||||
)
|
||||
13: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: \
|
||||
1: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
)
|
||||
14: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: \{
|
||||
1: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
2: }
|
||||
)
|
||||
)
|
||||
15: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
1: [B]
|
||||
)
|
||||
)
|
||||
16: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: $
|
||||
1: Expr_ArrayDimFetch(
|
||||
var: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
dim: Scalar_String(
|
||||
value: B
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
17: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: A
|
||||
1: Expr_Variable(
|
||||
name: B
|
||||
)
|
||||
2: C
|
||||
)
|
||||
)
|
||||
18: Scalar_Encapsed(
|
||||
parts: array(
|
||||
0: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
70
vendor/nikic/php-parser/test/code/parser/scalar/float.test
vendored
Normal file
70
vendor/nikic/php-parser/test/code/parser/scalar/float.test
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
Different float syntaxes
|
||||
-----
|
||||
<?php
|
||||
|
||||
0.0;
|
||||
0.;
|
||||
.0;
|
||||
0e0;
|
||||
0E0;
|
||||
0e+0;
|
||||
0e-0;
|
||||
30.20e10;
|
||||
300.200e100;
|
||||
1e10000;
|
||||
|
||||
// various integer -> float overflows
|
||||
// (all are actually the same number, just in different representations)
|
||||
18446744073709551615;
|
||||
0xFFFFFFFFFFFFFFFF;
|
||||
01777777777777777777777;
|
||||
0177777777777777777777787;
|
||||
0b1111111111111111111111111111111111111111111111111111111111111111;
|
||||
-----
|
||||
array(
|
||||
0: Scalar_DNumber(
|
||||
value: 0
|
||||
)
|
||||
1: Scalar_DNumber(
|
||||
value: 0
|
||||
)
|
||||
2: Scalar_DNumber(
|
||||
value: 0
|
||||
)
|
||||
3: Scalar_DNumber(
|
||||
value: 0
|
||||
)
|
||||
4: Scalar_DNumber(
|
||||
value: 0
|
||||
)
|
||||
5: Scalar_DNumber(
|
||||
value: 0
|
||||
)
|
||||
6: Scalar_DNumber(
|
||||
value: 0
|
||||
)
|
||||
7: Scalar_DNumber(
|
||||
value: 302000000000
|
||||
)
|
||||
8: Scalar_DNumber(
|
||||
value: 3.002E+102
|
||||
)
|
||||
9: Scalar_DNumber(
|
||||
value: INF
|
||||
)
|
||||
10: Scalar_DNumber(
|
||||
value: @@{ 0xFFFFFFFFFFFFFFFF }@@
|
||||
)
|
||||
11: Scalar_DNumber(
|
||||
value: @@{ 0xFFFFFFFFFFFFFFFF }@@
|
||||
)
|
||||
12: Scalar_DNumber(
|
||||
value: @@{ 0xFFFFFFFFFFFFFFFF }@@
|
||||
)
|
||||
13: Scalar_DNumber(
|
||||
value: @@{ 0xFFFFFFFFFFFFFFFF }@@
|
||||
)
|
||||
14: Scalar_DNumber(
|
||||
value: @@{ 0xFFFFFFFFFFFFFFFF }@@
|
||||
)
|
||||
)
|
47
vendor/nikic/php-parser/test/code/parser/scalar/int.test
vendored
Normal file
47
vendor/nikic/php-parser/test/code/parser/scalar/int.test
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
Different integer syntaxes
|
||||
-----
|
||||
<?php
|
||||
|
||||
0;
|
||||
1;
|
||||
@@{ PHP_INT_MAX }@@;
|
||||
@@{ PHP_INT_MAX + 1 }@@;
|
||||
0xFFF;
|
||||
0xfff;
|
||||
0XfFf;
|
||||
0777;
|
||||
0787;
|
||||
0b111000111000;
|
||||
-----
|
||||
array(
|
||||
0: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
1: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
2: Scalar_LNumber(
|
||||
value: @@{ PHP_INT_MAX }@@
|
||||
)
|
||||
3: Scalar_DNumber(
|
||||
value: @@{ PHP_INT_MAX + 1 }@@
|
||||
)
|
||||
4: Scalar_LNumber(
|
||||
value: 4095
|
||||
)
|
||||
5: Scalar_LNumber(
|
||||
value: 4095
|
||||
)
|
||||
6: Scalar_LNumber(
|
||||
value: 4095
|
||||
)
|
||||
7: Scalar_LNumber(
|
||||
value: 511
|
||||
)
|
||||
8: Scalar_LNumber(
|
||||
value: 7
|
||||
)
|
||||
9: Scalar_LNumber(
|
||||
value: 3640
|
||||
)
|
||||
)
|
31
vendor/nikic/php-parser/test/code/parser/scalar/magicConst.test
vendored
Normal file
31
vendor/nikic/php-parser/test/code/parser/scalar/magicConst.test
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
Magic constants
|
||||
-----
|
||||
<?php
|
||||
|
||||
__CLASS__;
|
||||
__DIR__;
|
||||
__FILE__;
|
||||
__FUNCTION__;
|
||||
__LINE__;
|
||||
__METHOD__;
|
||||
__NAMESPACE__;
|
||||
__TRAIT__;
|
||||
-----
|
||||
array(
|
||||
0: Scalar_MagicConst_Class(
|
||||
)
|
||||
1: Scalar_MagicConst_Dir(
|
||||
)
|
||||
2: Scalar_MagicConst_File(
|
||||
)
|
||||
3: Scalar_MagicConst_Function(
|
||||
)
|
||||
4: Scalar_MagicConst_Line(
|
||||
)
|
||||
5: Scalar_MagicConst_Method(
|
||||
)
|
||||
6: Scalar_MagicConst_Namespace(
|
||||
)
|
||||
7: Scalar_MagicConst_Trait(
|
||||
)
|
||||
)
|
112
vendor/nikic/php-parser/test/code/parser/stmt/blocklessStatement.test
vendored
Normal file
112
vendor/nikic/php-parser/test/code/parser/stmt/blocklessStatement.test
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
Blockless statements for if/for/etc
|
||||
-----
|
||||
<?php
|
||||
|
||||
if ($a) $A;
|
||||
elseif ($b) $B;
|
||||
else $C;
|
||||
|
||||
for (;;) $foo;
|
||||
|
||||
foreach ($a as $b) $AB;
|
||||
|
||||
while ($a) $A;
|
||||
|
||||
do $A; while ($a);
|
||||
|
||||
declare (a='b') $C;
|
||||
-----
|
||||
array(
|
||||
0: Stmt_If(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
elseifs: array(
|
||||
0: Stmt_ElseIf(
|
||||
cond: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_Variable(
|
||||
name: B
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
else: Stmt_Else(
|
||||
stmts: array(
|
||||
0: Expr_Variable(
|
||||
name: C
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_For(
|
||||
init: array(
|
||||
)
|
||||
cond: array(
|
||||
)
|
||||
loop: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Stmt_Foreach(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
keyVar: null
|
||||
byRef: false
|
||||
valueVar: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_Variable(
|
||||
name: AB
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Stmt_While(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Stmt_Do(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_Variable(
|
||||
name: A
|
||||
)
|
||||
)
|
||||
)
|
||||
5: Stmt_Declare(
|
||||
declares: array(
|
||||
0: Stmt_DeclareDeclare(
|
||||
key: a
|
||||
value: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_Variable(
|
||||
name: C
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
39
vendor/nikic/php-parser/test/code/parser/stmt/class/abstract.test
vendored
Normal file
39
vendor/nikic/php-parser/test/code/parser/stmt/class/abstract.test
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
Abstract class
|
||||
-----
|
||||
<?php
|
||||
|
||||
abstract class A {
|
||||
public function a() {}
|
||||
abstract public function b();
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Class(
|
||||
type: 16
|
||||
name: A
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_ClassMethod(
|
||||
type: 1
|
||||
byRef: false
|
||||
name: a
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
1: Stmt_ClassMethod(
|
||||
type: 17
|
||||
byRef: false
|
||||
name: b
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
194
vendor/nikic/php-parser/test/code/parser/stmt/class/anonymous.test
vendored
Normal file
194
vendor/nikic/php-parser/test/code/parser/stmt/class/anonymous.test
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
Anonymous classes
|
||||
-----
|
||||
<?php
|
||||
|
||||
new class {
|
||||
public function test() {}
|
||||
};
|
||||
new class extends A implements B, C {};
|
||||
new class() {
|
||||
public $foo;
|
||||
};
|
||||
new class($a, $b) extends A {
|
||||
use T;
|
||||
};
|
||||
|
||||
class A {
|
||||
public function test() {
|
||||
return new class($this) extends A {
|
||||
const A = 'B';
|
||||
};
|
||||
}
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Expr_New(
|
||||
class: Stmt_Class(
|
||||
type: 0
|
||||
name: null
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_ClassMethod(
|
||||
type: 1
|
||||
byRef: false
|
||||
name: test
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
1: Expr_New(
|
||||
class: Stmt_Class(
|
||||
type: 0
|
||||
name: null
|
||||
extends: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
implements: array(
|
||||
0: Name(
|
||||
parts: array(
|
||||
0: B
|
||||
)
|
||||
)
|
||||
1: Name(
|
||||
parts: array(
|
||||
0: C
|
||||
)
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
2: Expr_New(
|
||||
class: Stmt_Class(
|
||||
type: 0
|
||||
name: null
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
type: 1
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: foo
|
||||
default: null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
3: Expr_New(
|
||||
class: Stmt_Class(
|
||||
type: 0
|
||||
name: null
|
||||
extends: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_TraitUse(
|
||||
traits: array(
|
||||
0: Name(
|
||||
parts: array(
|
||||
0: T
|
||||
)
|
||||
)
|
||||
)
|
||||
adaptations: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
1: Arg(
|
||||
value: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Stmt_Class(
|
||||
type: 0
|
||||
name: A
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_ClassMethod(
|
||||
type: 1
|
||||
byRef: false
|
||||
name: test
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
0: Stmt_Return(
|
||||
expr: Expr_New(
|
||||
class: Stmt_Class(
|
||||
type: 0
|
||||
name: null
|
||||
extends: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_ClassConst(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: A
|
||||
value: Scalar_String(
|
||||
value: B
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_Variable(
|
||||
name: this
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
33
vendor/nikic/php-parser/test/code/parser/stmt/class/conditional.test
vendored
Normal file
33
vendor/nikic/php-parser/test/code/parser/stmt/class/conditional.test
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
Conditional class definition
|
||||
-----
|
||||
<?php
|
||||
|
||||
if (true) {
|
||||
class A {}
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_If(
|
||||
cond: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: true
|
||||
)
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Class(
|
||||
type: 0
|
||||
name: A
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
elseifs: array(
|
||||
)
|
||||
else: null
|
||||
)
|
||||
)
|
17
vendor/nikic/php-parser/test/code/parser/stmt/class/final.test
vendored
Normal file
17
vendor/nikic/php-parser/test/code/parser/stmt/class/final.test
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
Final class
|
||||
-----
|
||||
<?php
|
||||
|
||||
final class A {}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Class(
|
||||
type: 32
|
||||
name: A
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
92
vendor/nikic/php-parser/test/code/parser/stmt/class/implicitPublic.test
vendored
Normal file
92
vendor/nikic/php-parser/test/code/parser/stmt/class/implicitPublic.test
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
Implicitly public properties and methods
|
||||
-----
|
||||
<?php
|
||||
|
||||
abstract class A {
|
||||
var $a;
|
||||
static $b;
|
||||
abstract function c();
|
||||
final function d() {}
|
||||
static function e() {}
|
||||
final static function f() {}
|
||||
function g() {}
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Class(
|
||||
type: 16
|
||||
name: A
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
type: 0
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: a
|
||||
default: null
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Property(
|
||||
type: 8
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: b
|
||||
default: null
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Stmt_ClassMethod(
|
||||
type: 16
|
||||
byRef: false
|
||||
name: c
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: null
|
||||
)
|
||||
3: Stmt_ClassMethod(
|
||||
type: 32
|
||||
byRef: false
|
||||
name: d
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
4: Stmt_ClassMethod(
|
||||
type: 8
|
||||
byRef: false
|
||||
name: e
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
5: Stmt_ClassMethod(
|
||||
type: 40
|
||||
byRef: false
|
||||
name: f
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
6: Stmt_ClassMethod(
|
||||
type: 0
|
||||
byRef: false
|
||||
name: g
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
36
vendor/nikic/php-parser/test/code/parser/stmt/class/interface.test
vendored
Normal file
36
vendor/nikic/php-parser/test/code/parser/stmt/class/interface.test
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
Interface
|
||||
-----
|
||||
<?php
|
||||
|
||||
interface A extends C, D {
|
||||
public function a();
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Interface(
|
||||
name: A
|
||||
extends: array(
|
||||
0: Name(
|
||||
parts: array(
|
||||
0: C
|
||||
)
|
||||
)
|
||||
1: Name(
|
||||
parts: array(
|
||||
0: D
|
||||
)
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_ClassMethod(
|
||||
type: 1
|
||||
byRef: false
|
||||
name: a
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
49
vendor/nikic/php-parser/test/code/parser/stmt/class/modifier.test
vendored
Normal file
49
vendor/nikic/php-parser/test/code/parser/stmt/class/modifier.test
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
Invalid modifier combination
|
||||
-----
|
||||
<?php class A { public public $a; }
|
||||
-----
|
||||
Multiple access type modifiers are not allowed on line 1
|
||||
-----
|
||||
<?php class A { public protected $a; }
|
||||
-----
|
||||
Multiple access type modifiers are not allowed on line 1
|
||||
-----
|
||||
<?php class A { abstract abstract a(); }
|
||||
-----
|
||||
Multiple abstract modifiers are not allowed on line 1
|
||||
-----
|
||||
<?php class A { static static $a; }
|
||||
-----
|
||||
Multiple static modifiers are not allowed on line 1
|
||||
-----
|
||||
<?php class A { final final a() {} }
|
||||
-----
|
||||
Multiple final modifiers are not allowed on line 1
|
||||
-----
|
||||
<?php class A { abstract final a(); }
|
||||
-----
|
||||
Cannot use the final modifier on an abstract class member on line 1
|
||||
-----
|
||||
<?php abstract final class A { }
|
||||
// Type in the partial parse could conceivably be any of 0, 16 or 32
|
||||
-----
|
||||
Syntax error, unexpected T_FINAL, expecting T_CLASS from 1:16 to 1:20
|
||||
array(
|
||||
0: Stmt_Class(
|
||||
type: 32
|
||||
name: A
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php class A { abstract $a; }
|
||||
-----
|
||||
Properties cannot be declared abstract on line 1
|
||||
-----
|
||||
<?php class A { final $a; }
|
||||
-----
|
||||
Properties cannot be declared final on line 1
|
71
vendor/nikic/php-parser/test/code/parser/stmt/class/name.test
vendored
Normal file
71
vendor/nikic/php-parser/test/code/parser/stmt/class/name.test
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
Invalid class name
|
||||
-----
|
||||
<?php class self {}
|
||||
-----
|
||||
Cannot use 'self' as class name as it is reserved on line 1
|
||||
-----
|
||||
<?php class PARENT {}
|
||||
-----
|
||||
Cannot use 'PARENT' as class name as it is reserved on line 1
|
||||
-----
|
||||
<?php class static {}
|
||||
-----
|
||||
Syntax error, unexpected T_STATIC, expecting T_STRING from 1:13 to 1:18
|
||||
array(
|
||||
)
|
||||
-----
|
||||
<?php class A extends self {}
|
||||
-----
|
||||
Cannot use 'self' as class name as it is reserved from 1:23 to 1:26
|
||||
-----
|
||||
<?php class A extends PARENT {}
|
||||
-----
|
||||
Cannot use 'PARENT' as class name as it is reserved from 1:23 to 1:28
|
||||
-----
|
||||
<?php class A extends static {}
|
||||
-----
|
||||
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NAMESPACE or T_NS_SEPARATOR from 1:23 to 1:28
|
||||
array(
|
||||
)
|
||||
-----
|
||||
<?php class A implements self {}
|
||||
-----
|
||||
Cannot use 'self' as interface name as it is reserved from 1:26 to 1:29
|
||||
-----
|
||||
<?php class A implements PARENT {}
|
||||
-----
|
||||
Cannot use 'PARENT' as interface name as it is reserved from 1:26 to 1:31
|
||||
-----
|
||||
<?php class A implements static {}
|
||||
-----
|
||||
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NAMESPACE or T_NS_SEPARATOR from 1:26 to 1:31
|
||||
array(
|
||||
)
|
||||
-----
|
||||
<?php interface self {}
|
||||
-----
|
||||
Cannot use 'self' as class name as it is reserved on line 1
|
||||
-----
|
||||
<?php interface PARENT {}
|
||||
-----
|
||||
Cannot use 'PARENT' as class name as it is reserved on line 1
|
||||
-----
|
||||
<?php interface static {}
|
||||
-----
|
||||
Syntax error, unexpected T_STATIC, expecting T_STRING from 1:17 to 1:22
|
||||
array(
|
||||
)
|
||||
-----
|
||||
<?php interface A extends self {}
|
||||
-----
|
||||
Cannot use 'self' as interface name as it is reserved from 1:27 to 1:30
|
||||
-----
|
||||
<?php interface A extends PARENT {}
|
||||
-----
|
||||
Cannot use 'PARENT' as interface name as it is reserved from 1:27 to 1:32
|
||||
-----
|
||||
<?php interface A extends static {}
|
||||
-----
|
||||
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NAMESPACE or T_NS_SEPARATOR from 1:27 to 1:32
|
||||
array(
|
||||
)
|
50
vendor/nikic/php-parser/test/code/parser/stmt/class/php4Style.test
vendored
Normal file
50
vendor/nikic/php-parser/test/code/parser/stmt/class/php4Style.test
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
PHP 4 style declarations
|
||||
-----
|
||||
<?php
|
||||
|
||||
class A {
|
||||
var $foo;
|
||||
function bar() {}
|
||||
static abstract function baz() {}
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Class(
|
||||
type: 0
|
||||
name: A
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
type: 0
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: foo
|
||||
default: null
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_ClassMethod(
|
||||
type: 0
|
||||
byRef: false
|
||||
name: bar
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
2: Stmt_ClassMethod(
|
||||
type: 24
|
||||
byRef: false
|
||||
name: baz
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
155
vendor/nikic/php-parser/test/code/parser/stmt/class/simple.test
vendored
Normal file
155
vendor/nikic/php-parser/test/code/parser/stmt/class/simple.test
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
Class declaration
|
||||
-----
|
||||
<?php
|
||||
|
||||
class A extends B implements C, D {
|
||||
const A = 'B', C = 'D';
|
||||
|
||||
public $a = 'b', $c = 'd';
|
||||
protected $e;
|
||||
private $f;
|
||||
|
||||
public function a() {}
|
||||
public static function b($a) {}
|
||||
public final function c() : B {}
|
||||
protected function d() {}
|
||||
private function e() {}
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Class(
|
||||
type: 0
|
||||
name: A
|
||||
extends: Name(
|
||||
parts: array(
|
||||
0: B
|
||||
)
|
||||
)
|
||||
implements: array(
|
||||
0: Name(
|
||||
parts: array(
|
||||
0: C
|
||||
)
|
||||
)
|
||||
1: Name(
|
||||
parts: array(
|
||||
0: D
|
||||
)
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_ClassConst(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: A
|
||||
value: Scalar_String(
|
||||
value: B
|
||||
)
|
||||
)
|
||||
1: Const(
|
||||
name: C
|
||||
value: Scalar_String(
|
||||
value: D
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Property(
|
||||
type: 1
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: a
|
||||
default: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
1: Stmt_PropertyProperty(
|
||||
name: c
|
||||
default: Scalar_String(
|
||||
value: d
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Stmt_Property(
|
||||
type: 2
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: e
|
||||
default: null
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Stmt_Property(
|
||||
type: 4
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: f
|
||||
default: null
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Stmt_ClassMethod(
|
||||
type: 1
|
||||
byRef: false
|
||||
name: a
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
5: Stmt_ClassMethod(
|
||||
type: 9
|
||||
byRef: false
|
||||
name: b
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: a
|
||||
default: null
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
6: Stmt_ClassMethod(
|
||||
type: 33
|
||||
byRef: false
|
||||
name: c
|
||||
params: array(
|
||||
)
|
||||
returnType: Name(
|
||||
parts: array(
|
||||
0: B
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
7: Stmt_ClassMethod(
|
||||
type: 2
|
||||
byRef: false
|
||||
name: d
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
8: Stmt_ClassMethod(
|
||||
type: 4
|
||||
byRef: false
|
||||
name: e
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
25
vendor/nikic/php-parser/test/code/parser/stmt/class/staticMethod.test
vendored
Normal file
25
vendor/nikic/php-parser/test/code/parser/stmt/class/staticMethod.test
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
Some special methods cannot be static
|
||||
-----
|
||||
<?php class A { static function __construct() {} }
|
||||
-----
|
||||
Constructor __construct() cannot be static on line 1
|
||||
-----
|
||||
<?php class A { static function __destruct() {} }
|
||||
-----
|
||||
Destructor __destruct() cannot be static on line 1
|
||||
-----
|
||||
<?php class A { static function __clone() {} }
|
||||
-----
|
||||
Clone method __clone() cannot be static on line 1
|
||||
-----
|
||||
<?php class A { static function __CONSTRUCT() {} }
|
||||
-----
|
||||
Constructor __CONSTRUCT() cannot be static on line 1
|
||||
-----
|
||||
<?php class A { static function __Destruct() {} }
|
||||
-----
|
||||
Destructor __Destruct() cannot be static on line 1
|
||||
-----
|
||||
<?php class A { static function __cLoNe() {} }
|
||||
-----
|
||||
Clone method __cLoNe() cannot be static on line 1
|
160
vendor/nikic/php-parser/test/code/parser/stmt/class/trait.test
vendored
Normal file
160
vendor/nikic/php-parser/test/code/parser/stmt/class/trait.test
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
Traits
|
||||
-----
|
||||
<?php
|
||||
|
||||
trait A {
|
||||
public function a() {}
|
||||
}
|
||||
|
||||
class B {
|
||||
use C;
|
||||
use D {
|
||||
a as protected b;
|
||||
c as d;
|
||||
e as private;
|
||||
}
|
||||
use E, F, G {
|
||||
E::a insteadof F, G;
|
||||
E::b as protected c;
|
||||
E::d as e;
|
||||
E::f as private;
|
||||
}
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Trait(
|
||||
name: A
|
||||
stmts: array(
|
||||
0: Stmt_ClassMethod(
|
||||
type: 1
|
||||
byRef: false
|
||||
name: a
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Class(
|
||||
type: 0
|
||||
name: B
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_TraitUse(
|
||||
traits: array(
|
||||
0: Name(
|
||||
parts: array(
|
||||
0: C
|
||||
)
|
||||
)
|
||||
)
|
||||
adaptations: array(
|
||||
)
|
||||
)
|
||||
1: Stmt_TraitUse(
|
||||
traits: array(
|
||||
0: Name(
|
||||
parts: array(
|
||||
0: D
|
||||
)
|
||||
)
|
||||
)
|
||||
adaptations: array(
|
||||
0: Stmt_TraitUseAdaptation_Alias(
|
||||
trait: null
|
||||
method: a
|
||||
newModifier: 2
|
||||
newName: b
|
||||
)
|
||||
1: Stmt_TraitUseAdaptation_Alias(
|
||||
trait: null
|
||||
method: c
|
||||
newModifier: null
|
||||
newName: d
|
||||
)
|
||||
2: Stmt_TraitUseAdaptation_Alias(
|
||||
trait: null
|
||||
method: e
|
||||
newModifier: 4
|
||||
newName: null
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Stmt_TraitUse(
|
||||
traits: array(
|
||||
0: Name(
|
||||
parts: array(
|
||||
0: E
|
||||
)
|
||||
)
|
||||
1: Name(
|
||||
parts: array(
|
||||
0: F
|
||||
)
|
||||
)
|
||||
2: Name(
|
||||
parts: array(
|
||||
0: G
|
||||
)
|
||||
)
|
||||
)
|
||||
adaptations: array(
|
||||
0: Stmt_TraitUseAdaptation_Precedence(
|
||||
trait: Name(
|
||||
parts: array(
|
||||
0: E
|
||||
)
|
||||
)
|
||||
method: a
|
||||
insteadof: array(
|
||||
0: Name(
|
||||
parts: array(
|
||||
0: F
|
||||
)
|
||||
)
|
||||
1: Name(
|
||||
parts: array(
|
||||
0: G
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_TraitUseAdaptation_Alias(
|
||||
trait: Name(
|
||||
parts: array(
|
||||
0: E
|
||||
)
|
||||
)
|
||||
method: b
|
||||
newModifier: 2
|
||||
newName: c
|
||||
)
|
||||
2: Stmt_TraitUseAdaptation_Alias(
|
||||
trait: Name(
|
||||
parts: array(
|
||||
0: E
|
||||
)
|
||||
)
|
||||
method: d
|
||||
newModifier: null
|
||||
newName: e
|
||||
)
|
||||
3: Stmt_TraitUseAdaptation_Alias(
|
||||
trait: Name(
|
||||
parts: array(
|
||||
0: E
|
||||
)
|
||||
)
|
||||
method: f
|
||||
newModifier: 4
|
||||
newName: null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
40
vendor/nikic/php-parser/test/code/parser/stmt/const.test
vendored
Normal file
40
vendor/nikic/php-parser/test/code/parser/stmt/const.test
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
Global constants
|
||||
-----
|
||||
<?php
|
||||
|
||||
const A = 0, B = 1.0, C = 'A', D = E;
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Const(
|
||||
consts: array(
|
||||
0: Const(
|
||||
name: A
|
||||
value: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
1: Const(
|
||||
name: B
|
||||
value: Scalar_DNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
2: Const(
|
||||
name: C
|
||||
value: Scalar_String(
|
||||
value: A
|
||||
)
|
||||
)
|
||||
3: Const(
|
||||
name: D
|
||||
value: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: E
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
55
vendor/nikic/php-parser/test/code/parser/stmt/controlFlow.test
vendored
Normal file
55
vendor/nikic/php-parser/test/code/parser/stmt/controlFlow.test
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
Control flow statements
|
||||
-----
|
||||
<?php
|
||||
|
||||
break;
|
||||
break 2;
|
||||
|
||||
continue;
|
||||
continue 2;
|
||||
|
||||
return;
|
||||
return $a;
|
||||
|
||||
throw $e;
|
||||
|
||||
label:
|
||||
goto label;
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Break(
|
||||
num: null
|
||||
)
|
||||
1: Stmt_Break(
|
||||
num: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
2: Stmt_Continue(
|
||||
num: null
|
||||
)
|
||||
3: Stmt_Continue(
|
||||
num: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
4: Stmt_Return(
|
||||
expr: null
|
||||
)
|
||||
5: Stmt_Return(
|
||||
expr: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
6: Stmt_Throw(
|
||||
expr: Expr_Variable(
|
||||
name: e
|
||||
)
|
||||
)
|
||||
7: Stmt_Label(
|
||||
name: label
|
||||
)
|
||||
8: Stmt_Goto(
|
||||
name: label
|
||||
)
|
||||
)
|
47
vendor/nikic/php-parser/test/code/parser/stmt/declare.test
vendored
Normal file
47
vendor/nikic/php-parser/test/code/parser/stmt/declare.test
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
Declare
|
||||
-----
|
||||
<?php
|
||||
|
||||
declare (A='B', C='D') {}
|
||||
|
||||
declare (A='B', C='D'):
|
||||
enddeclare;
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Declare(
|
||||
declares: array(
|
||||
0: Stmt_DeclareDeclare(
|
||||
key: A
|
||||
value: Scalar_String(
|
||||
value: B
|
||||
)
|
||||
)
|
||||
1: Stmt_DeclareDeclare(
|
||||
key: C
|
||||
value: Scalar_String(
|
||||
value: D
|
||||
)
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
1: Stmt_Declare(
|
||||
declares: array(
|
||||
0: Stmt_DeclareDeclare(
|
||||
key: A
|
||||
value: Scalar_String(
|
||||
value: B
|
||||
)
|
||||
)
|
||||
1: Stmt_DeclareDeclare(
|
||||
key: C
|
||||
value: Scalar_String(
|
||||
value: D
|
||||
)
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
32
vendor/nikic/php-parser/test/code/parser/stmt/echo.test
vendored
Normal file
32
vendor/nikic/php-parser/test/code/parser/stmt/echo.test
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
Echo
|
||||
-----
|
||||
<?php
|
||||
|
||||
echo 'Hallo World!';
|
||||
echo 'Hallo', ' ', 'World', '!';
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Echo(
|
||||
exprs: array(
|
||||
0: Scalar_String(
|
||||
value: Hallo World!
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Echo(
|
||||
exprs: array(
|
||||
0: Scalar_String(
|
||||
value: Hallo
|
||||
)
|
||||
1: Scalar_String(
|
||||
value:
|
||||
)
|
||||
2: Scalar_String(
|
||||
value: World
|
||||
)
|
||||
3: Scalar_String(
|
||||
value: !
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
41
vendor/nikic/php-parser/test/code/parser/stmt/function/byRef.test
vendored
Normal file
41
vendor/nikic/php-parser/test/code/parser/stmt/function/byRef.test
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
Return and pass by ref
|
||||
-----
|
||||
<?php
|
||||
|
||||
function a(&$b) {}
|
||||
function &a($b) {}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Function(
|
||||
byRef: false
|
||||
name: a
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: true
|
||||
variadic: false
|
||||
name: b
|
||||
default: null
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
1: Stmt_Function(
|
||||
byRef: true
|
||||
name: a
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: b
|
||||
default: null
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
33
vendor/nikic/php-parser/test/code/parser/stmt/function/conditional.test
vendored
Normal file
33
vendor/nikic/php-parser/test/code/parser/stmt/function/conditional.test
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
Conditional function definition
|
||||
-----
|
||||
<?php
|
||||
|
||||
if (true) {
|
||||
function A() {}
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_If(
|
||||
cond: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: true
|
||||
)
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Function(
|
||||
byRef: false
|
||||
name: A
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
elseifs: array(
|
||||
)
|
||||
else: null
|
||||
)
|
||||
)
|
148
vendor/nikic/php-parser/test/code/parser/stmt/function/defaultValues.test
vendored
Normal file
148
vendor/nikic/php-parser/test/code/parser/stmt/function/defaultValues.test
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
Default values (static scalar tests)
|
||||
-----
|
||||
<?php
|
||||
|
||||
function a(
|
||||
$b = null,
|
||||
$c = 'foo',
|
||||
$d = A::B,
|
||||
$f = +1,
|
||||
$g = -1.0,
|
||||
$h = array(),
|
||||
$i = [],
|
||||
$j = ['foo'],
|
||||
$k = ['foo', 'bar' => 'baz']
|
||||
) {}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Function(
|
||||
byRef: false
|
||||
name: a
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: b
|
||||
default: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: c
|
||||
default: Scalar_String(
|
||||
value: foo
|
||||
)
|
||||
)
|
||||
2: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: d
|
||||
default: Expr_ClassConstFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
name: B
|
||||
)
|
||||
)
|
||||
3: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: f
|
||||
default: Expr_UnaryPlus(
|
||||
expr: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
4: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: g
|
||||
default: Expr_UnaryMinus(
|
||||
expr: Scalar_DNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
5: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: h
|
||||
default: Expr_Array(
|
||||
items: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
6: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: i
|
||||
default: Expr_Array(
|
||||
items: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
7: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: j
|
||||
default: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: foo
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
8: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: k
|
||||
default: Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: foo
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
1: Expr_ArrayItem(
|
||||
key: Scalar_String(
|
||||
value: bar
|
||||
)
|
||||
value: Scalar_String(
|
||||
value: baz
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
262
vendor/nikic/php-parser/test/code/parser/stmt/function/generator.test
vendored
Normal file
262
vendor/nikic/php-parser/test/code/parser/stmt/function/generator.test
vendored
Normal file
@@ -0,0 +1,262 @@
|
||||
Generators (yield expression)
|
||||
-----
|
||||
<?php
|
||||
|
||||
function gen() {
|
||||
// statements
|
||||
yield;
|
||||
yield $value;
|
||||
yield $key => $value;
|
||||
|
||||
// expressions
|
||||
$data = yield;
|
||||
$data = (yield $value);
|
||||
$data = (yield $key => $value);
|
||||
|
||||
// yield in language constructs with their own parentheses
|
||||
if (yield $foo); elseif (yield $foo);
|
||||
if (yield $foo): elseif (yield $foo): endif;
|
||||
while (yield $foo);
|
||||
do {} while (yield $foo);
|
||||
switch (yield $foo) {}
|
||||
die(yield $foo);
|
||||
|
||||
// yield in function calls
|
||||
func(yield $foo);
|
||||
$foo->func(yield $foo);
|
||||
new Foo(yield $foo);
|
||||
|
||||
yield from $foo;
|
||||
yield from $foo and yield from $bar;
|
||||
yield from $foo + $bar;
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Function(
|
||||
byRef: false
|
||||
name: gen
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
0: Expr_Yield(
|
||||
key: null
|
||||
value: null
|
||||
)
|
||||
1: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: value
|
||||
)
|
||||
)
|
||||
2: Expr_Yield(
|
||||
key: Expr_Variable(
|
||||
name: key
|
||||
)
|
||||
value: Expr_Variable(
|
||||
name: value
|
||||
)
|
||||
)
|
||||
3: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: data
|
||||
)
|
||||
expr: Expr_Yield(
|
||||
key: null
|
||||
value: null
|
||||
)
|
||||
)
|
||||
4: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: data
|
||||
)
|
||||
expr: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: value
|
||||
)
|
||||
)
|
||||
)
|
||||
5: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: data
|
||||
)
|
||||
expr: Expr_Yield(
|
||||
key: Expr_Variable(
|
||||
name: key
|
||||
)
|
||||
value: Expr_Variable(
|
||||
name: value
|
||||
)
|
||||
)
|
||||
)
|
||||
6: Stmt_If(
|
||||
cond: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
elseifs: array(
|
||||
0: Stmt_ElseIf(
|
||||
cond: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
else: null
|
||||
)
|
||||
7: Stmt_If(
|
||||
cond: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
elseifs: array(
|
||||
0: Stmt_ElseIf(
|
||||
cond: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
else: null
|
||||
)
|
||||
8: Stmt_While(
|
||||
cond: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
9: Stmt_Do(
|
||||
cond: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
10: Stmt_Switch(
|
||||
cond: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
cases: array(
|
||||
)
|
||||
)
|
||||
11: Expr_Exit(
|
||||
expr: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
)
|
||||
12: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: func
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
)
|
||||
)
|
||||
13: Expr_MethodCall(
|
||||
var: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
name: func
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
)
|
||||
)
|
||||
14: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: Foo
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_Yield(
|
||||
key: null
|
||||
value: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
)
|
||||
)
|
||||
15: Expr_YieldFrom(
|
||||
expr: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
16: Expr_BinaryOp_LogicalAnd(
|
||||
left: Expr_YieldFrom(
|
||||
expr: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
)
|
||||
right: Expr_YieldFrom(
|
||||
expr: Expr_Variable(
|
||||
name: bar
|
||||
)
|
||||
)
|
||||
)
|
||||
17: Expr_YieldFrom(
|
||||
expr: Expr_BinaryOp_Plus(
|
||||
left: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
right: Expr_Variable(
|
||||
name: bar
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
52
vendor/nikic/php-parser/test/code/parser/stmt/function/returnTypes.test
vendored
Normal file
52
vendor/nikic/php-parser/test/code/parser/stmt/function/returnTypes.test
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
Return type declarations
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test1() {}
|
||||
function test2() : array {}
|
||||
function test3() : callable {}
|
||||
function test4() : Foo\Bar {}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Function(
|
||||
byRef: false
|
||||
name: test1
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
1: Stmt_Function(
|
||||
byRef: false
|
||||
name: test2
|
||||
params: array(
|
||||
)
|
||||
returnType: array
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
2: Stmt_Function(
|
||||
byRef: false
|
||||
name: test3
|
||||
params: array(
|
||||
)
|
||||
returnType: callable
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
3: Stmt_Function(
|
||||
byRef: false
|
||||
name: test4
|
||||
params: array(
|
||||
)
|
||||
returnType: Name(
|
||||
parts: array(
|
||||
0: Foo
|
||||
1: Bar
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
51
vendor/nikic/php-parser/test/code/parser/stmt/function/specialVars.test
vendored
Normal file
51
vendor/nikic/php-parser/test/code/parser/stmt/function/specialVars.test
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
Special function variables
|
||||
-----
|
||||
<?php
|
||||
|
||||
function a() {
|
||||
global $a, ${'b'}, $$c;
|
||||
static $c, $d = 'e';
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Function(
|
||||
byRef: false
|
||||
name: a
|
||||
params: array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
0: Stmt_Global(
|
||||
vars: array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
1: Expr_Variable(
|
||||
name: Scalar_String(
|
||||
value: b
|
||||
)
|
||||
)
|
||||
2: Expr_Variable(
|
||||
name: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Static(
|
||||
vars: array(
|
||||
0: Stmt_StaticVar(
|
||||
name: c
|
||||
default: null
|
||||
)
|
||||
1: Stmt_StaticVar(
|
||||
name: d
|
||||
default: Scalar_String(
|
||||
value: e
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
49
vendor/nikic/php-parser/test/code/parser/stmt/function/typeHints.test
vendored
Normal file
49
vendor/nikic/php-parser/test/code/parser/stmt/function/typeHints.test
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
Type hints
|
||||
-----
|
||||
<?php
|
||||
|
||||
function a($b, array $c, callable $d, E $f) {}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Function(
|
||||
byRef: false
|
||||
name: a
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: b
|
||||
default: null
|
||||
)
|
||||
1: Param(
|
||||
type: array
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: c
|
||||
default: null
|
||||
)
|
||||
2: Param(
|
||||
type: callable
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: d
|
||||
default: null
|
||||
)
|
||||
3: Param(
|
||||
type: Name(
|
||||
parts: array(
|
||||
0: E
|
||||
)
|
||||
)
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: f
|
||||
default: null
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
110
vendor/nikic/php-parser/test/code/parser/stmt/function/variadic.test
vendored
Normal file
110
vendor/nikic/php-parser/test/code/parser/stmt/function/variadic.test
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
Variadic functions
|
||||
-----
|
||||
<?php
|
||||
function test($a, ... $b) {}
|
||||
function test($a, &... $b) {}
|
||||
function test($a, Type ... $b) {}
|
||||
function test($a, Type &... $b) {}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Function(
|
||||
byRef: false
|
||||
name: test
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: a
|
||||
default: null
|
||||
)
|
||||
1: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: true
|
||||
name: b
|
||||
default: null
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
1: Stmt_Function(
|
||||
byRef: false
|
||||
name: test
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: a
|
||||
default: null
|
||||
)
|
||||
1: Param(
|
||||
type: null
|
||||
byRef: true
|
||||
variadic: true
|
||||
name: b
|
||||
default: null
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
2: Stmt_Function(
|
||||
byRef: false
|
||||
name: test
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: a
|
||||
default: null
|
||||
)
|
||||
1: Param(
|
||||
type: Name(
|
||||
parts: array(
|
||||
0: Type
|
||||
)
|
||||
)
|
||||
byRef: false
|
||||
variadic: true
|
||||
name: b
|
||||
default: null
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
3: Stmt_Function(
|
||||
byRef: false
|
||||
name: test
|
||||
params: array(
|
||||
0: Param(
|
||||
type: null
|
||||
byRef: false
|
||||
variadic: false
|
||||
name: a
|
||||
default: null
|
||||
)
|
||||
1: Param(
|
||||
type: Name(
|
||||
parts: array(
|
||||
0: Type
|
||||
)
|
||||
)
|
||||
byRef: true
|
||||
variadic: true
|
||||
name: b
|
||||
default: null
|
||||
)
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
6
vendor/nikic/php-parser/test/code/parser/stmt/function/variadicDefaultValue.test
vendored
Normal file
6
vendor/nikic/php-parser/test/code/parser/stmt/function/variadicDefaultValue.test
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Invalid variadic function
|
||||
-----
|
||||
<?php
|
||||
function foo(...$foo = []) {}
|
||||
-----
|
||||
Variadic parameter cannot have a default value from 2:24 to 2:25
|
55
vendor/nikic/php-parser/test/code/parser/stmt/haltCompiler.test
vendored
Normal file
55
vendor/nikic/php-parser/test/code/parser/stmt/haltCompiler.test
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
__halt_compiler
|
||||
-----
|
||||
<?php
|
||||
|
||||
$a;
|
||||
__halt_compiler()
|
||||
?>
|
||||
Hallo World!
|
||||
-----
|
||||
array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
1: Stmt_HaltCompiler(
|
||||
remaining: Hallo World!
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
|
||||
$a;
|
||||
__halt_compiler();Hallo World!
|
||||
-----
|
||||
array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
1: Stmt_HaltCompiler(
|
||||
remaining: Hallo World!
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace A;
|
||||
$a;
|
||||
__halt_compiler();
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: A
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_HaltCompiler(
|
||||
remaining:
|
||||
)
|
||||
)
|
6
vendor/nikic/php-parser/test/code/parser/stmt/haltCompilerInvalidSyntax.test
vendored
Normal file
6
vendor/nikic/php-parser/test/code/parser/stmt/haltCompilerInvalidSyntax.test
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Invalid __halt_compiler() syntax
|
||||
-----
|
||||
<?php
|
||||
__halt_compiler()
|
||||
-----
|
||||
__HALT_COMPILER must be followed by "();" on line 2
|
34
vendor/nikic/php-parser/test/code/parser/stmt/haltCompilerOffset.test
vendored
Normal file
34
vendor/nikic/php-parser/test/code/parser/stmt/haltCompilerOffset.test
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
Use of __HALT_COMPILER_OFFSET__ constant
|
||||
-----
|
||||
<?php
|
||||
|
||||
var_dump(__HALT_COMPILER_OFFSET__);
|
||||
__halt_compiler();
|
||||
Foo
|
||||
-----
|
||||
array(
|
||||
0: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: var_dump
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Arg(
|
||||
value: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: __HALT_COMPILER_OFFSET__
|
||||
)
|
||||
)
|
||||
)
|
||||
byRef: false
|
||||
unpack: false
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_HaltCompiler(
|
||||
remaining:
|
||||
Foo
|
||||
)
|
||||
)
|
8
vendor/nikic/php-parser/test/code/parser/stmt/haltCompilerOutermostScope.test
vendored
Normal file
8
vendor/nikic/php-parser/test/code/parser/stmt/haltCompilerOutermostScope.test
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
__halt_compiler can only be used from outermost scope
|
||||
-----
|
||||
<?php
|
||||
if (true) {
|
||||
__halt_compiler();
|
||||
}
|
||||
-----
|
||||
__HALT_COMPILER() can only be used from the outermost scope from 3:5 to 3:19
|
26
vendor/nikic/php-parser/test/code/parser/stmt/hashbang.test
vendored
Normal file
26
vendor/nikic/php-parser/test/code/parser/stmt/hashbang.test
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
Hashbang line
|
||||
-----
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
echo "foobar";
|
||||
|
||||
?>
|
||||
#!/usr/bin/env php
|
||||
-----
|
||||
array(
|
||||
0: Stmt_InlineHTML(
|
||||
value: #!/usr/bin/env php
|
||||
|
||||
)
|
||||
1: Stmt_Echo(
|
||||
exprs: array(
|
||||
0: Scalar_String(
|
||||
value: foobar
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Stmt_InlineHTML(
|
||||
value: #!/usr/bin/env php
|
||||
)
|
||||
)
|
95
vendor/nikic/php-parser/test/code/parser/stmt/if.test
vendored
Normal file
95
vendor/nikic/php-parser/test/code/parser/stmt/if.test
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
If/Elseif/Else
|
||||
-----
|
||||
<?php
|
||||
|
||||
if ($a) {}
|
||||
elseif ($b) {}
|
||||
elseif ($c) {}
|
||||
else {}
|
||||
|
||||
if ($a) {} // without else
|
||||
|
||||
if ($a):
|
||||
elseif ($b):
|
||||
elseif ($c):
|
||||
else :
|
||||
endif;
|
||||
|
||||
if ($a): endif; // without else
|
||||
-----
|
||||
array(
|
||||
0: Stmt_If(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
elseifs: array(
|
||||
0: Stmt_ElseIf(
|
||||
cond: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
1: Stmt_ElseIf(
|
||||
cond: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
else: Stmt_Else(
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_If(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
elseifs: array(
|
||||
)
|
||||
else: null
|
||||
)
|
||||
2: Stmt_If(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
elseifs: array(
|
||||
0: Stmt_ElseIf(
|
||||
cond: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
1: Stmt_ElseIf(
|
||||
cond: Expr_Variable(
|
||||
name: c
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
else: Stmt_Else(
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
3: Stmt_If(
|
||||
cond: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
elseifs: array(
|
||||
)
|
||||
else: null
|
||||
)
|
||||
)
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user