Laravel version update
Laravel version update
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Print_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Comment;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
class MethodTest extends TestCase
|
||||
{
|
||||
public function createMethodBuilder($name) {
|
||||
return new Method($name);
|
||||
@@ -23,12 +25,12 @@ class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
'type' => Stmt\Class_::MODIFIER_PUBLIC
|
||||
| Stmt\Class_::MODIFIER_ABSTRACT
|
||||
| Stmt\Class_::MODIFIER_STATIC,
|
||||
new Stmt\ClassMethod('test', [
|
||||
'flags' => Stmt\Class_::MODIFIER_PUBLIC
|
||||
| Stmt\Class_::MODIFIER_ABSTRACT
|
||||
| Stmt\Class_::MODIFIER_STATIC,
|
||||
'stmts' => null,
|
||||
)),
|
||||
]),
|
||||
$node
|
||||
);
|
||||
|
||||
@@ -39,10 +41,10 @@ class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
'type' => Stmt\Class_::MODIFIER_PROTECTED
|
||||
| Stmt\Class_::MODIFIER_FINAL
|
||||
)),
|
||||
new Stmt\ClassMethod('test', [
|
||||
'flags' => Stmt\Class_::MODIFIER_PROTECTED
|
||||
| Stmt\Class_::MODIFIER_FINAL
|
||||
]),
|
||||
$node
|
||||
);
|
||||
|
||||
@@ -52,9 +54,9 @@ class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
new Stmt\ClassMethod('test', [
|
||||
'type' => Stmt\Class_::MODIFIER_PRIVATE
|
||||
)),
|
||||
]),
|
||||
$node
|
||||
);
|
||||
}
|
||||
@@ -66,28 +68,28 @@ class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
new Stmt\ClassMethod('test', [
|
||||
'byRef' => true
|
||||
)),
|
||||
]),
|
||||
$node
|
||||
);
|
||||
}
|
||||
|
||||
public function testParams() {
|
||||
$param1 = new Node\Param('test1');
|
||||
$param2 = new Node\Param('test2');
|
||||
$param3 = new Node\Param('test3');
|
||||
$param1 = new Node\Param(new Variable('test1'));
|
||||
$param2 = new Node\Param(new Variable('test2'));
|
||||
$param3 = new Node\Param(new Variable('test3'));
|
||||
|
||||
$node = $this->createMethodBuilder('test')
|
||||
->addParam($param1)
|
||||
->addParams(array($param2, $param3))
|
||||
->addParams([$param2, $param3])
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
'params' => array($param1, $param2, $param3)
|
||||
)),
|
||||
new Stmt\ClassMethod('test', [
|
||||
'params' => [$param1, $param2, $param3]
|
||||
]),
|
||||
$node
|
||||
);
|
||||
}
|
||||
@@ -99,14 +101,18 @@ class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$node = $this->createMethodBuilder('test')
|
||||
->addStmt($stmt1)
|
||||
->addStmts(array($stmt2, $stmt3))
|
||||
->addStmts([$stmt2, $stmt3])
|
||||
->getNode()
|
||||
;
|
||||
|
||||
$this->assertEquals(
|
||||
new Stmt\ClassMethod('test', array(
|
||||
'stmts' => array($stmt1, $stmt2, $stmt3)
|
||||
)),
|
||||
new Stmt\ClassMethod('test', [
|
||||
'stmts' => [
|
||||
new Stmt\Expression($stmt1),
|
||||
new Stmt\Expression($stmt2),
|
||||
new Stmt\Expression($stmt3),
|
||||
]
|
||||
]),
|
||||
$node
|
||||
);
|
||||
}
|
||||
@@ -115,18 +121,18 @@ class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
->setDocComment('/** Test */')
|
||||
->getNode();
|
||||
|
||||
$this->assertEquals(new Stmt\ClassMethod('test', array(), array(
|
||||
'comments' => array(new Comment\Doc('/** Test */'))
|
||||
)), $node);
|
||||
$this->assertEquals(new Stmt\ClassMethod('test', [], [
|
||||
'comments' => [new Comment\Doc('/** Test */')]
|
||||
]), $node);
|
||||
}
|
||||
|
||||
public function testReturnType() {
|
||||
$node = $this->createMethodBuilder('test')
|
||||
->setReturnType('bool')
|
||||
->getNode();
|
||||
$this->assertEquals(new Stmt\ClassMethod('test', array(
|
||||
$this->assertEquals(new Stmt\ClassMethod('test', [
|
||||
'returnType' => 'bool'
|
||||
), array()), $node);
|
||||
], []), $node);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user