-<?php
+<?php declare(strict_types=1);
namespace PhpParser\Builder;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
+use PHPUnit\Framework\TestCase;
-class ClassTest extends \PHPUnit_Framework_TestCase
+class ClassTest extends TestCase
{
protected function createClassBuilder($class) {
return new Class_($class);
;
$this->assertEquals(
- new Stmt\Class_('SomeLogger', array(
+ new Stmt\Class_('SomeLogger', [
'extends' => new Name('BaseLogger'),
- 'implements' => array(
+ 'implements' => [
new Name('Namespaced\Logger'),
new Name('SomeInterface'),
new Name\FullyQualified('Fully\Qualified'),
new Name\Relative('NamespaceRelative'),
- ),
- )),
+ ],
+ ]),
$node
);
}
;
$this->assertEquals(
- new Stmt\Class_('Test', array(
+ new Stmt\Class_('Test', [
'flags' => Stmt\Class_::MODIFIER_ABSTRACT
- )),
+ ]),
$node
);
}
;
$this->assertEquals(
- new Stmt\Class_('Test', array(
+ new Stmt\Class_('Test', [
'flags' => Stmt\Class_::MODIFIER_FINAL
- )),
+ ]),
$node
);
}
$method = new Stmt\ClassMethod('testMethod');
$property = new Stmt\Property(
Stmt\Class_::MODIFIER_PUBLIC,
- array(new Stmt\PropertyProperty('testProperty'))
+ [new Stmt\PropertyProperty('testProperty')]
);
- $const = new Stmt\ClassConst(array(
+ $const = new Stmt\ClassConst([
new Node\Const_('TEST_CONST', new Node\Scalar\String_('ABC'))
- ));
- $use = new Stmt\TraitUse(array(new Name('SomeTrait')));
+ ]);
+ $use = new Stmt\TraitUse([new Name('SomeTrait')]);
$node = $this->createClassBuilder('Test')
->addStmt($method)
->addStmt($property)
- ->addStmts(array($const, $use))
+ ->addStmts([$const, $use])
->getNode()
;
$this->assertEquals(
- new Stmt\Class_('Test', array(
- 'stmts' => array($use, $const, $property, $method)
- )),
+ new Stmt\Class_('Test', [
+ 'stmts' => [$use, $const, $property, $method]
+ ]),
$node
);
}
->getNode();
$this->assertEquals(
- new Stmt\Class_('Test', array(), array(
- 'comments' => array(
+ new Stmt\Class_('Test', [], [
+ 'comments' => [
new Comment\Doc($docComment)
- )
- )),
+ ]
+ ]),
$class
);
->getNode();
$this->assertEquals(
- new Stmt\Class_('Test', array(), array(
- 'comments' => array(
+ new Stmt\Class_('Test', [], [
+ 'comments' => [
new Comment\Doc($docComment)
- )
- )),
+ ]
+ ]),
$class
);
}
*/
public function testInvalidStmtError() {
$this->createClassBuilder('Test')
- ->addStmt(new Stmt\Echo_(array()))
+ ->addStmt(new Stmt\Echo_([]))
;
}
/**
* @expectedException \LogicException
- * @expectedExceptionMessage Name must be a string or an instance of PhpParser\Node\Name
+ * @expectedExceptionMessage Name must be a string or an instance of Node\Name
*/
public function testInvalidName() {
$this->createClassBuilder('Test')
- ->extend(array('Foo'));
+ ->extend(['Foo']);
}
}