Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -1,12 +1,13 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Builder;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Scalar;
use PHPUnit\Framework\TestCase;
class ParamTest extends \PHPUnit_Framework_TestCase
class ParamTest extends TestCase
{
public function createParamBuilder($name) {
return new Param($name);
@@ -25,42 +26,42 @@ class ParamTest extends \PHPUnit_Framework_TestCase
}
public function provideTestDefaultValues() {
return array(
array(
return [
[
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(
],
[
[1, 2, 3],
new Expr\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(
])
],
[
['foo' => 'bar', 'bar' => 'foo'],
new Expr\Array_([
new Expr\ArrayItem(
new Scalar\String_('bar'),
new Scalar\String_('foo')
@@ -69,45 +70,79 @@ class ParamTest extends \PHPUnit_Framework_TestCase
new Scalar\String_('foo'),
new Scalar\String_('bar')
),
))
),
array(
])
],
[
new Scalar\MagicConst\Dir,
new Scalar\MagicConst\Dir
)
);
]
];
}
public function testTypeHints() {
/**
* @dataProvider provideTestTypeHints
*/
public function testTypeHints($typeHint, $expectedType) {
$node = $this->createParamBuilder('test')
->setTypeHint('array')
->setTypeHint($typeHint)
->getNode()
;
$type = $node->type;
$this->assertEquals(
new Node\Param('test', null, 'array'),
$node
);
/* Manually implement comparison to avoid __toString stupidity */
if ($expectedType instanceof Node\NullableType) {
$this->assertInstanceOf(get_class($expectedType), $type);
$expectedType = $expectedType->type;
$type = $type->type;
}
$node = $this->createParamBuilder('test')
->setTypeHint('callable')
->getNode()
;
$this->assertInstanceOf(get_class($expectedType), $type);
$this->assertEquals($expectedType, $type);
}
$this->assertEquals(
new Node\Param('test', null, 'callable'),
$node
);
public function provideTestTypeHints() {
return [
['array', new Node\Identifier('array')],
['callable', new Node\Identifier('callable')],
['bool', new Node\Identifier('bool')],
['int', new Node\Identifier('int')],
['float', new Node\Identifier('float')],
['string', new Node\Identifier('string')],
['iterable', new Node\Identifier('iterable')],
['object', new Node\Identifier('object')],
['Array', new Node\Identifier('array')],
['CALLABLE', new Node\Identifier('callable')],
['Some\Class', new Node\Name('Some\Class')],
['\Foo', new Node\Name\FullyQualified('Foo')],
['self', new Node\Name('self')],
['?array', new Node\NullableType(new Node\Identifier('array'))],
['?Some\Class', new Node\NullableType(new Node\Name('Some\Class'))],
[new Node\Name('Some\Class'), new Node\Name('Some\Class')],
[
new Node\NullableType(new Node\Identifier('int')),
new Node\NullableType(new Node\Identifier('int'))
],
[
new Node\NullableType(new Node\Name('Some\Class')),
new Node\NullableType(new Node\Name('Some\Class'))
],
];
}
$node = $this->createParamBuilder('test')
->setTypeHint('Some\Class')
->getNode()
;
/**
* @expectedException \LogicException
* @expectedExceptionMessage Parameter type cannot be void
*/
public function testVoidTypeError() {
$this->createParamBuilder('test')->setTypeHint('void');
}
$this->assertEquals(
new Node\Param('test', null, new Node\Name('Some\Class')),
$node
);
/**
* @expectedException \LogicException
* @expectedExceptionMessage Type must be a string, or an instance of Name, Identifier or NullableType
*/
public function testInvalidTypeError() {
$this->createParamBuilder('test')->setTypeHint(new \stdClass);
}
public function testByRef() {
@@ -117,7 +152,19 @@ class ParamTest extends \PHPUnit_Framework_TestCase
;
$this->assertEquals(
new Node\Param('test', null, null, true),
new Node\Param(new Expr\Variable('test'), null, null, true),
$node
);
}
public function testVariadic() {
$node = $this->createParamBuilder('test')
->makeVariadic()
->getNode()
;
$this->assertEquals(
new Node\Param(new Expr\Variable('test'), null, null, false, true),
$node
);
}