Laravel version update
Laravel version update
This commit is contained in:
31
vendor/nikic/php-parser/test/PhpParser/Node/IdentifierTest.php
vendored
Normal file
31
vendor/nikic/php-parser/test/PhpParser/Node/IdentifierTest.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Node;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class IdentifierTest extends TestCase
|
||||
{
|
||||
public function testToString() {
|
||||
$identifier = new Identifier('Foo');
|
||||
|
||||
$this->assertSame('Foo', (string) $identifier);
|
||||
$this->assertSame('Foo', $identifier->toString());
|
||||
$this->assertSame('foo', $identifier->toLowerString());
|
||||
}
|
||||
|
||||
/** @dataProvider provideTestIsSpecialClassName */
|
||||
public function testIsSpecialClassName($identifier, $expected) {
|
||||
$identifier = new Identifier($identifier);
|
||||
$this->assertSame($expected, $identifier->isSpecialClassName());
|
||||
}
|
||||
|
||||
public function provideTestIsSpecialClassName() {
|
||||
return [
|
||||
['self', true],
|
||||
['PARENT', true],
|
||||
['Static', true],
|
||||
['other', false],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,20 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Node;
|
||||
|
||||
class NameTest extends \PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NameTest extends TestCase
|
||||
{
|
||||
public function testConstruct() {
|
||||
$name = new Name(array('foo', 'bar'));
|
||||
$this->assertSame(array('foo', 'bar'), $name->parts);
|
||||
$name = new Name(['foo', 'bar']);
|
||||
$this->assertSame(['foo', 'bar'], $name->parts);
|
||||
|
||||
$name = new Name('foo\bar');
|
||||
$this->assertSame(array('foo', 'bar'), $name->parts);
|
||||
$this->assertSame(['foo', 'bar'], $name->parts);
|
||||
|
||||
$name = new Name($name);
|
||||
$this->assertSame(['foo', 'bar'], $name->parts);
|
||||
}
|
||||
|
||||
public function testGet() {
|
||||
@@ -23,93 +28,61 @@ class NameTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
public function testToString() {
|
||||
$name = new Name('foo\bar');
|
||||
$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());
|
||||
$this->assertSame('Foo\Bar', (string) $name);
|
||||
$this->assertSame('Foo\Bar', $name->toString());
|
||||
$this->assertSame('foo\bar', $name->toLowerString());
|
||||
}
|
||||
|
||||
public function testSlice() {
|
||||
$name = new Name('foo\bar');
|
||||
$this->assertEquals(new Name('foo\bar'), $name->slice(0));
|
||||
$this->assertEquals(new Name('bar'), $name->slice(1));
|
||||
$this->assertEquals(new Name([]), $name->slice(2));
|
||||
$name = new Name('foo\bar\baz');
|
||||
$this->assertEquals(new Name('foo\bar\baz'), $name->slice(0));
|
||||
$this->assertEquals(new Name('bar\baz'), $name->slice(1));
|
||||
$this->assertNull($name->slice(3));
|
||||
$this->assertEquals(new Name('foo\bar\baz'), $name->slice(-3));
|
||||
$this->assertEquals(new Name('bar\baz'), $name->slice(-2));
|
||||
$this->assertEquals(new Name('foo\bar'), $name->slice(0, -1));
|
||||
$this->assertNull($name->slice(0, -3));
|
||||
$this->assertEquals(new Name('bar'), $name->slice(1, -1));
|
||||
$this->assertNull($name->slice(1, -2));
|
||||
$this->assertEquals(new Name('bar'), $name->slice(-2, 1));
|
||||
$this->assertEquals(new Name('bar'), $name->slice(-2, -1));
|
||||
$this->assertNull($name->slice(-2, -2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
* @expectedExceptionMessage Offset 4 is out of bounds
|
||||
*/
|
||||
public function testSliceException() {
|
||||
public function testSliceOffsetTooLarge() {
|
||||
(new Name('foo\bar\baz'))->slice(4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
* @expectedExceptionMessage Offset -4 is out of bounds
|
||||
*/
|
||||
public function testSliceOffsetTooSmall() {
|
||||
(new Name('foo\bar\baz'))->slice(-4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
* @expectedExceptionMessage Length 4 is out of bounds
|
||||
*/
|
||||
public function testSliceLengthTooLarge() {
|
||||
(new Name('foo\bar\baz'))->slice(0, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
* @expectedExceptionMessage Length -4 is out of bounds
|
||||
*/
|
||||
public function testSliceLengthTooSmall() {
|
||||
(new Name('foo\bar\baz'))->slice(0, -4);
|
||||
}
|
||||
|
||||
public function testConcat() {
|
||||
$this->assertEquals(new Name('foo\bar\baz'), Name::concat('foo', 'bar\baz'));
|
||||
$this->assertEquals(
|
||||
@@ -123,42 +96,78 @@ class NameTest extends \PHPUnit_Framework_TestCase
|
||||
Name\Relative::concat(new Name\FullyQualified('foo\bar'), 'baz', $attributes)
|
||||
);
|
||||
|
||||
$this->assertEquals(new Name('foo'), Name::concat([], 'foo'));
|
||||
$this->assertEquals(new Name([]), Name::concat([], []));
|
||||
$this->assertEquals(new Name('foo'), Name::concat(null, 'foo'));
|
||||
$this->assertEquals(new Name('foo'), Name::concat('foo', null));
|
||||
$this->assertNull(Name::concat(null, null));
|
||||
}
|
||||
|
||||
public function testIs() {
|
||||
public function testNameTypes() {
|
||||
$name = new Name('foo');
|
||||
$this->assertTrue ($name->isUnqualified());
|
||||
$this->assertTrue($name->isUnqualified());
|
||||
$this->assertFalse($name->isQualified());
|
||||
$this->assertFalse($name->isFullyQualified());
|
||||
$this->assertFalse($name->isRelative());
|
||||
$this->assertSame('foo', $name->toCodeString());
|
||||
|
||||
$name = new Name('foo\bar');
|
||||
$this->assertFalse($name->isUnqualified());
|
||||
$this->assertTrue ($name->isQualified());
|
||||
$this->assertTrue($name->isQualified());
|
||||
$this->assertFalse($name->isFullyQualified());
|
||||
$this->assertFalse($name->isRelative());
|
||||
$this->assertSame('foo\bar', $name->toCodeString());
|
||||
|
||||
$name = new Name\FullyQualified('foo');
|
||||
$this->assertFalse($name->isUnqualified());
|
||||
$this->assertFalse($name->isQualified());
|
||||
$this->assertTrue ($name->isFullyQualified());
|
||||
$this->assertTrue($name->isFullyQualified());
|
||||
$this->assertFalse($name->isRelative());
|
||||
$this->assertSame('\foo', $name->toCodeString());
|
||||
|
||||
$name = new Name\Relative('foo');
|
||||
$this->assertFalse($name->isUnqualified());
|
||||
$this->assertFalse($name->isQualified());
|
||||
$this->assertFalse($name->isFullyQualified());
|
||||
$this->assertTrue ($name->isRelative());
|
||||
$this->assertTrue($name->isRelative());
|
||||
$this->assertSame('namespace\foo', $name->toCodeString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage When changing a name you need to pass either a string, an array or a Name node
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Expected string, array of parts or Name instance
|
||||
*/
|
||||
public function testInvalidArg() {
|
||||
$name = new Name('foo');
|
||||
$name->set(new \stdClass);
|
||||
Name::concat('foo', new \stdClass);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Name cannot be empty
|
||||
*/
|
||||
public function testInvalidEmptyString() {
|
||||
new Name('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Name cannot be empty
|
||||
*/
|
||||
public function testInvalidEmptyArray() {
|
||||
new Name([]);
|
||||
}
|
||||
|
||||
/** @dataProvider provideTestIsSpecialClassName */
|
||||
public function testIsSpecialClassName($name, $expected) {
|
||||
$name = new Name($name);
|
||||
$this->assertSame($expected, $name->isSpecialClassName());
|
||||
}
|
||||
|
||||
public function provideTestIsSpecialClassName() {
|
||||
return [
|
||||
['self', true],
|
||||
['PARENT', true],
|
||||
['Static', true],
|
||||
['self\not', false],
|
||||
['not\self', false],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Node\Scalar;
|
||||
|
||||
class MagicConstTest extends \PHPUnit_Framework_TestCase {
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MagicConstTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestGetName
|
||||
*/
|
||||
@@ -11,15 +14,15 @@ class MagicConstTest extends \PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
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__'),
|
||||
);
|
||||
return [
|
||||
[new MagicConst\Class_, '__CLASS__'],
|
||||
[new MagicConst\Dir, '__DIR__'],
|
||||
[new MagicConst\File, '__FILE__'],
|
||||
[new MagicConst\Function_, '__FUNCTION__'],
|
||||
[new MagicConst\Line, '__LINE__'],
|
||||
[new MagicConst\Method, '__METHOD__'],
|
||||
[new MagicConst\Namespace_, '__NAMESPACE__'],
|
||||
[new MagicConst\Trait_, '__TRAIT__'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Node\Scalar;
|
||||
|
||||
class StringTest extends \PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StringTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestParseEscapeSequences
|
||||
@@ -25,34 +27,34 @@ class StringTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
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),
|
||||
);
|
||||
return [
|
||||
['"', '\\"', '"'],
|
||||
['\\"', '\\"', '`'],
|
||||
['\\"\\`', '\\"\\`', null],
|
||||
["\\\$\n\r\t\f\v", '\\\\\$\n\r\t\f\v', null],
|
||||
["\x1B", '\e', null],
|
||||
[chr(255), '\xFF', null],
|
||||
[chr(255), '\377', null],
|
||||
[chr(0), '\400', null],
|
||||
["\0", '\0', null],
|
||||
['\xFF', '\\\\xFF', null],
|
||||
];
|
||||
}
|
||||
|
||||
public function provideTestParse() {
|
||||
$tests = array(
|
||||
array('A', '\'A\''),
|
||||
array('A', 'b\'A\''),
|
||||
array('A', '"A"'),
|
||||
array('A', 'b"A"'),
|
||||
array('\\', '\'\\\\\''),
|
||||
array('\'', '\'\\\'\''),
|
||||
);
|
||||
$tests = [
|
||||
['A', '\'A\''],
|
||||
['A', 'b\'A\''],
|
||||
['A', '"A"'],
|
||||
['A', 'b"A"'],
|
||||
['\\', '\'\\\\\''],
|
||||
['\'', '\'\\\'\''],
|
||||
];
|
||||
|
||||
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] . '"');
|
||||
if ($i !== 1 && $i !== 2) {
|
||||
$tests[] = [$test[0], '"' . $test[1] . '"'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
36
vendor/nikic/php-parser/test/PhpParser/Node/Stmt/ClassConstTest.php
vendored
Normal file
36
vendor/nikic/php-parser/test/PhpParser/Node/Stmt/ClassConstTest.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ClassConstTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideModifiers
|
||||
*/
|
||||
public function testModifiers($modifier) {
|
||||
$node = new ClassConst(
|
||||
[], // invalid
|
||||
constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier))
|
||||
);
|
||||
|
||||
$this->assertTrue($node->{'is' . $modifier}());
|
||||
}
|
||||
|
||||
public function testNoModifiers() {
|
||||
$node = new ClassConst([], 0);
|
||||
|
||||
$this->assertTrue($node->isPublic());
|
||||
$this->assertFalse($node->isProtected());
|
||||
$this->assertFalse($node->isPrivate());
|
||||
}
|
||||
|
||||
public function provideModifiers() {
|
||||
return [
|
||||
['public'],
|
||||
['protected'],
|
||||
['private'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,27 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
class ClassMethodTest extends \PHPUnit_Framework_TestCase
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Param;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ClassMethodTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideModifiers
|
||||
*/
|
||||
public function testModifiers($modifier) {
|
||||
$node = new ClassMethod('foo', array(
|
||||
$node = new ClassMethod('foo', [
|
||||
'type' => constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier))
|
||||
));
|
||||
]);
|
||||
|
||||
$this->assertTrue($node->{'is' . $modifier}());
|
||||
}
|
||||
|
||||
public function testNoModifiers() {
|
||||
$node = new ClassMethod('foo', array('type' => 0));
|
||||
$node = new ClassMethod('foo', ['type' => 0]);
|
||||
|
||||
$this->assertTrue($node->isPublic());
|
||||
$this->assertFalse($node->isProtected());
|
||||
@@ -24,17 +29,18 @@ class ClassMethodTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($node->isAbstract());
|
||||
$this->assertFalse($node->isFinal());
|
||||
$this->assertFalse($node->isStatic());
|
||||
$this->assertFalse($node->isMagic());
|
||||
}
|
||||
|
||||
public function provideModifiers() {
|
||||
return array(
|
||||
array('public'),
|
||||
array('protected'),
|
||||
array('private'),
|
||||
array('abstract'),
|
||||
array('final'),
|
||||
array('static'),
|
||||
);
|
||||
return [
|
||||
['public'],
|
||||
['protected'],
|
||||
['private'],
|
||||
['abstract'],
|
||||
['final'],
|
||||
['static'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,22 +48,77 @@ class ClassMethodTest extends \PHPUnit_Framework_TestCase
|
||||
*
|
||||
* @dataProvider implicitPublicModifiers
|
||||
*
|
||||
* @param integer $modifier Node type modifier
|
||||
* @param string $modifier Node type modifier
|
||||
*/
|
||||
public function testImplicitPublic($modifier)
|
||||
public function testImplicitPublic(string $modifier)
|
||||
{
|
||||
$node = new ClassMethod('foo', array(
|
||||
$node = new ClassMethod('foo', [
|
||||
'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'),
|
||||
);
|
||||
return [
|
||||
['abstract'],
|
||||
['final'],
|
||||
['static'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideMagics
|
||||
*
|
||||
* @param string $name Node name
|
||||
*/
|
||||
public function testMagic(string $name) {
|
||||
$node = new ClassMethod($name);
|
||||
$this->assertTrue($node->isMagic(), 'Method should be magic');
|
||||
}
|
||||
|
||||
public function provideMagics() {
|
||||
return [
|
||||
['__construct'],
|
||||
['__DESTRUCT'],
|
||||
['__caLL'],
|
||||
['__callstatic'],
|
||||
['__get'],
|
||||
['__set'],
|
||||
['__isset'],
|
||||
['__unset'],
|
||||
['__sleep'],
|
||||
['__wakeup'],
|
||||
['__tostring'],
|
||||
['__set_state'],
|
||||
['__clone'],
|
||||
['__invoke'],
|
||||
['__debuginfo'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testFunctionLike() {
|
||||
$param = new Param(new Variable('a'));
|
||||
$type = new Name('Foo');
|
||||
$return = new Return_(new Variable('a'));
|
||||
$method = new ClassMethod('test', [
|
||||
'byRef' => false,
|
||||
'params' => [$param],
|
||||
'returnType' => $type,
|
||||
'stmts' => [$return],
|
||||
]);
|
||||
|
||||
$this->assertFalse($method->returnsByRef());
|
||||
$this->assertSame([$param], $method->getParams());
|
||||
$this->assertSame($type, $method->getReturnType());
|
||||
$this->assertSame([$return], $method->getStmts());
|
||||
|
||||
$method = new ClassMethod('test', [
|
||||
'byRef' => true,
|
||||
'stmts' => null,
|
||||
]);
|
||||
|
||||
$this->assertTrue($method->returnsByRef());
|
||||
$this->assertNull($method->getStmts());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
class ClassTest extends \PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ClassTest extends TestCase
|
||||
{
|
||||
public function testIsAbstract() {
|
||||
$class = new Class_('Foo', array('type' => Class_::MODIFIER_ABSTRACT));
|
||||
$class = new Class_('Foo', ['type' => Class_::MODIFIER_ABSTRACT]);
|
||||
$this->assertTrue($class->isAbstract());
|
||||
|
||||
$class = new Class_('Foo');
|
||||
@@ -13,7 +15,7 @@ class ClassTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
public function testIsFinal() {
|
||||
$class = new Class_('Foo', array('type' => Class_::MODIFIER_FINAL));
|
||||
$class = new Class_('Foo', ['type' => Class_::MODIFIER_FINAL]);
|
||||
$this->assertTrue($class->isFinal());
|
||||
|
||||
$class = new Class_('Foo');
|
||||
@@ -21,21 +23,21 @@ class ClassTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
public function testGetMethods() {
|
||||
$methods = array(
|
||||
$methods = [
|
||||
new ClassMethod('foo'),
|
||||
new ClassMethod('bar'),
|
||||
new ClassMethod('fooBar'),
|
||||
);
|
||||
$class = new Class_('Foo', array(
|
||||
'stmts' => array(
|
||||
new TraitUse(array()),
|
||||
];
|
||||
$class = new Class_('Foo', [
|
||||
'stmts' => [
|
||||
new TraitUse([]),
|
||||
$methods[0],
|
||||
new ClassConst(array()),
|
||||
new ClassConst([]),
|
||||
$methods[1],
|
||||
new Property(0, array()),
|
||||
new Property(0, []),
|
||||
$methods[2],
|
||||
)
|
||||
));
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertSame($methods, $class->getMethods());
|
||||
}
|
||||
@@ -43,14 +45,14 @@ class ClassTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetMethod() {
|
||||
$methodConstruct = new ClassMethod('__CONSTRUCT');
|
||||
$methodTest = new ClassMethod('test');
|
||||
$class = new Class_('Foo', array(
|
||||
'stmts' => array(
|
||||
new ClassConst(array()),
|
||||
$class = new Class_('Foo', [
|
||||
'stmts' => [
|
||||
new ClassConst([]),
|
||||
$methodConstruct,
|
||||
new Property(0, array()),
|
||||
new Property(0, []),
|
||||
$methodTest,
|
||||
)
|
||||
));
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertSame($methodConstruct, $class->getMethod('__construct'));
|
||||
$this->assertSame($methodTest, $class->getMethod('test'));
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class InterfaceTest extends \PHPUnit_Framework_TestCase
|
||||
class InterfaceTest extends TestCase
|
||||
{
|
||||
public function testGetMethods() {
|
||||
$methods = array(
|
||||
$methods = [
|
||||
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')))),
|
||||
];
|
||||
$interface = new Class_('Foo', [
|
||||
'stmts' => [
|
||||
new Node\Stmt\ClassConst([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')))),
|
||||
new Node\Stmt\ClassConst([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')))),
|
||||
)
|
||||
));
|
||||
new Node\Stmt\ClassConst([new Node\Const_('C3', new Node\Scalar\String_('C3'))]),
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertSame($methods, $interface->getMethods());
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
class PropertyTest extends \PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PropertyTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideModifiers
|
||||
@@ -10,14 +12,14 @@ class PropertyTest extends \PHPUnit_Framework_TestCase
|
||||
public function testModifiers($modifier) {
|
||||
$node = new Property(
|
||||
constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier)),
|
||||
array() // invalid
|
||||
[] // invalid
|
||||
);
|
||||
|
||||
$this->assertTrue($node->{'is' . $modifier}());
|
||||
}
|
||||
|
||||
public function testNoModifiers() {
|
||||
$node = new Property(0, array());
|
||||
$node = new Property(0, []);
|
||||
|
||||
$this->assertTrue($node->isPublic());
|
||||
$this->assertFalse($node->isProtected());
|
||||
@@ -26,7 +28,7 @@ class PropertyTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
public function testStaticImplicitlyPublic() {
|
||||
$node = new Property(Class_::MODIFIER_STATIC, array());
|
||||
$node = new Property(Class_::MODIFIER_STATIC, []);
|
||||
$this->assertTrue($node->isPublic());
|
||||
$this->assertFalse($node->isProtected());
|
||||
$this->assertFalse($node->isPrivate());
|
||||
@@ -34,11 +36,11 @@ class PropertyTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
public function provideModifiers() {
|
||||
return array(
|
||||
array('public'),
|
||||
array('protected'),
|
||||
array('private'),
|
||||
array('static'),
|
||||
);
|
||||
return [
|
||||
['public'],
|
||||
['protected'],
|
||||
['private'],
|
||||
['static'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user