Skip to content
Permalink
Browse files

updates via "rectorphp/rector" (#573)

- "global" -> remove unused "use" statements
- "phpunit" -> fix "@Covers" comments
- "phpunit" -> replace "->will($this->returnValue()" with "->willReturn()"
- "UseTest.php" -> add missing namespace
- "composer.json" -> use "autoload-dev"
- remove -> "require_once" usage in the tests (use autoload-dev via composer.json)

-> most of the changes are done automatically by "https://github.com/rectorphp/rector"
  • Loading branch information...
voku authored and nikic committed Jan 19, 2019
1 parent 594bcae commit b7e63615366dfacfbf29af9823d55c92ddbfd043
Showing with 75 additions and 148 deletions.
  1. +5 −0 composer.json
  2. +1 −2 lib/PhpParser/BuilderFactory.php
  3. +3 −5 lib/PhpParser/NodeAbstract.php
  4. +0 −1 lib/PhpParser/NodeVisitor/NameResolver.php
  5. +0 −1 lib/PhpParser/PrettyPrinterAbstract.php
  6. +1 −2 test/PhpParser/Builder/ClassTest.php
  7. +1 −2 test/PhpParser/Builder/FunctionTest.php
  8. +1 −2 test/PhpParser/Builder/InterfaceTest.php
  9. +1 −2 test/PhpParser/Builder/MethodTest.php
  10. +1 −2 test/PhpParser/Builder/NamespaceTest.php
  11. +1 −2 test/PhpParser/Builder/ParamTest.php
  12. +1 −2 test/PhpParser/Builder/PropertyTest.php
  13. +1 −2 test/PhpParser/Builder/TraitTest.php
  14. +1 −4 test/PhpParser/Builder/TraitUseAdaptationTest.php
  15. +1 −4 test/PhpParser/Builder/TraitUseTest.php
  16. +3 −2 test/PhpParser/Builder/UseTest.php
  17. +1 −4 test/PhpParser/BuilderFactoryTest.php
  18. +2 −4 test/PhpParser/CodeParsingTest.php
  19. +1 −5 test/PhpParser/CodeTestAbstract.php
  20. +1 −3 test/PhpParser/CommentTest.php
  21. +1 −2 test/PhpParser/ConstExprEvaluatorTest.php
  22. +1 −2 test/PhpParser/ErrorHandler/CollectingTest.php
  23. +1 −2 test/PhpParser/ErrorHandler/ThrowingTest.php
  24. +1 −3 test/PhpParser/ErrorTest.php
  25. +1 −3 test/PhpParser/Internal/DifferTest.php
  26. +1 −3 test/PhpParser/JsonDecoderTest.php
  27. +0 −2 test/PhpParser/Lexer/EmulativeTest.php
  28. +1 −2 test/PhpParser/LexerTest.php
  29. +1 −2 test/PhpParser/NameContextTest.php
  30. +1 −3 test/PhpParser/Node/IdentifierTest.php
  31. +1 −3 test/PhpParser/Node/NameTest.php
  32. +1 −3 test/PhpParser/Node/Scalar/MagicConstTest.php
  33. +1 −3 test/PhpParser/Node/Scalar/StringTest.php
  34. +1 −3 test/PhpParser/Node/Stmt/ClassConstTest.php
  35. +1 −2 test/PhpParser/Node/Stmt/ClassMethodTest.php
  36. +1 −3 test/PhpParser/Node/Stmt/ClassTest.php
  37. +1 −2 test/PhpParser/Node/Stmt/InterfaceTest.php
  38. +1 −3 test/PhpParser/Node/Stmt/PropertyTest.php
  39. +1 −3 test/PhpParser/NodeAbstractTest.php
  40. +1 −3 test/PhpParser/NodeDumperTest.php
  41. +1 −2 test/PhpParser/NodeFinderTest.php
  42. +19 −21 test/PhpParser/NodeTraverserTest.php
  43. +1 −2 test/PhpParser/NodeVisitor/FindingVisitorTest.php
  44. +1 −2 test/PhpParser/NodeVisitor/FirstFindingVisitorTest.php
  45. +3 −4 test/PhpParser/NodeVisitor/NameResolverTest.php
  46. +2 −4 test/PhpParser/Parser/MultipleTest.php
  47. +0 −2 test/PhpParser/Parser/Php5Test.php
  48. +0 −2 test/PhpParser/Parser/Php7Test.php
  49. +1 −2 test/PhpParser/ParserFactoryTest.php
  50. +1 −2 test/PhpParser/ParserTest.php
  51. +0 −2 test/PhpParser/PrettyPrinterTest.php
@@ -29,6 +29,11 @@
"PhpParser\\": "lib/PhpParser"
}
},
"autoload-dev": {
"psr-4": {
"PhpParser\\": "test/PhpParser/"
}
},
"bin": [
"bin/php-parse"
]
@@ -8,7 +8,6 @@
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Use_;
class BuilderFactory
@@ -77,7 +76,7 @@ public function useTrait(...$traits) : Builder\TraitUse {
* @return Builder\TraitUseAdaptation The create trait use adaptation builder
*/
public function traitUseAdaptation($trait, $method = null) : Builder\TraitUseAdaptation {
if (is_null($method)) {
if ($method === null) {
$method = $trait;
$trait = null;
}
@@ -2,8 +2,6 @@
namespace PhpParser;
use PhpParser\Node;
abstract class NodeAbstract implements Node, \JsonSerializable
{
protected $attributes;
@@ -159,11 +157,11 @@ public function hasAttribute(string $key) : bool {
}
public function getAttribute(string $key, $default = null) {
if (!array_key_exists($key, $this->attributes)) {
return $default;
} else {
if (array_key_exists($key, $this->attributes)) {
return $this->attributes[$key];
}
return $default;
}
public function getAttributes() : array {
@@ -2,7 +2,6 @@
namespace PhpParser\NodeVisitor;
use PhpParser\Error;
use PhpParser\ErrorHandler;
use PhpParser\NameContext;
use PhpParser\Node;
@@ -9,7 +9,6 @@
use PhpParser\Node\Expr\AssignOp;
use PhpParser\Node\Expr\BinaryOp;
use PhpParser\Node\Expr\Cast;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar;
use PhpParser\Node\Stmt;
@@ -6,9 +6,8 @@
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
use PHPUnit\Framework\TestCase;
class ClassTest extends TestCase
class ClassTest extends \PHPUnit\Framework\TestCase
{
protected function createClassBuilder($class) {
return new Class_($class);
@@ -8,9 +8,8 @@
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt;
use PHPUnit\Framework\TestCase;
class FunctionTest extends TestCase
class FunctionTest extends \PHPUnit\Framework\TestCase
{
public function createFunctionBuilder($name) {
return new Function_($name);
@@ -6,9 +6,8 @@
use PhpParser\Node;
use PhpParser\Node\Scalar\DNumber;
use PhpParser\Node\Stmt;
use PHPUnit\Framework\TestCase;
class InterfaceTest extends TestCase
class InterfaceTest extends \PHPUnit\Framework\TestCase
{
/** @var Interface_ */
protected $builder;
@@ -8,9 +8,8 @@
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt;
use PHPUnit\Framework\TestCase;
class MethodTest extends TestCase
class MethodTest extends \PHPUnit\Framework\TestCase
{
public function createMethodBuilder($name) {
return new Method($name);
@@ -5,9 +5,8 @@
use PhpParser\Comment\Doc;
use PhpParser\Node;
use PhpParser\Node\Stmt;
use PHPUnit\Framework\TestCase;
class NamespaceTest extends TestCase
class NamespaceTest extends \PHPUnit\Framework\TestCase
{
protected function createNamespaceBuilder($fqn) {
return new Namespace_($fqn);
@@ -5,9 +5,8 @@
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Scalar;
use PHPUnit\Framework\TestCase;
class ParamTest extends TestCase
class ParamTest extends \PHPUnit\Framework\TestCase
{
public function createParamBuilder($name) {
return new Param($name);
@@ -7,9 +7,8 @@
use PhpParser\Node\Name;
use PhpParser\Node\Scalar;
use PhpParser\Node\Stmt;
use PHPUnit\Framework\TestCase;
class PropertyTest extends TestCase
class PropertyTest extends \PHPUnit\Framework\TestCase
{
public function createPropertyBuilder($name) {
return new Property($name);
@@ -5,9 +5,8 @@
use PhpParser\Comment;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
use PHPUnit\Framework\TestCase;
class TraitTest extends TestCase
class TraitTest extends \PHPUnit\Framework\TestCase
{
protected function createTraitBuilder($class) {
return new Trait_($class);
@@ -2,14 +2,11 @@
namespace PhpParser\Builder;
use PhpParser\Comment;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Class_;
use PHPUnit\Framework\TestCase;
class TraitUseAdaptationTest extends TestCase
class TraitUseAdaptationTest extends \PHPUnit\Framework\TestCase
{
protected function createTraitUseAdaptationBuilder($trait, $method) {
return new TraitUseAdaptation($trait, $method);
@@ -2,13 +2,10 @@
namespace PhpParser\Builder;
use PhpParser\Comment;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
use PHPUnit\Framework\TestCase;
class TraitUseTest extends TestCase
class TraitUseTest extends \PHPUnit\Framework\TestCase
{
protected function createTraitUseBuilder(...$traits) {
return new TraitUse(...$traits);
@@ -1,11 +1,12 @@
<?php declare(strict_types=1);
namespace PhpParser\Builder;
use PhpParser\Builder;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
use PHPUnit\Framework\TestCase;
class UseTest extends TestCase
class UseTest extends \PHPUnit\Framework\TestCase
{
protected function createUseBuilder($name, $type = Stmt\Use_::TYPE_NORMAL) {
return new Builder\Use_($name, $type);
@@ -2,18 +2,15 @@
namespace PhpParser;
use PhpParser\Builder;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\String_;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Tests\A;
class BuilderFactoryTest extends TestCase
class BuilderFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider provideTestFactory
@@ -5,8 +5,6 @@
use PhpParser\Node\Expr;
use PhpParser\Node\Stmt;
require_once __DIR__ . '/CodeTestAbstract.php';
class CodeParsingTest extends CodeTestAbstract
{
/**
@@ -79,9 +77,9 @@ public function provideTestParse() {
private function formatErrorMessage(Error $e, $code) {
if ($e->hasColumnInfo()) {
return $e->getMessageWithColumnInfo($code);
} else {
return $e->getMessage();
}
return $e->getMessage();
}
private function checkAttributes($stmts) {
@@ -2,11 +2,7 @@
namespace PhpParser;
use PHPUnit\Framework\TestCase;
require_once __DIR__ . '/CodeTestParser.php';
abstract class CodeTestAbstract extends TestCase
abstract class CodeTestAbstract extends \PHPUnit\Framework\TestCase
{
protected function getTests($directory, $fileExtension, $chunksPerTest = 2) {
$parser = new CodeTestParser;
@@ -2,9 +2,7 @@
namespace PhpParser;
use PHPUnit\Framework\TestCase;
class CommentTest extends TestCase
class CommentTest extends \PHPUnit\Framework\TestCase
{
public function testGetSet() {
$comment = new Comment('/* Some comment */', 1, 10, 2);
@@ -4,9 +4,8 @@
use PhpParser\Node\Expr;
use PhpParser\Node\Scalar;
use PHPUnit\Framework\TestCase;
class ConstExprEvaluatorTest extends TestCase
class ConstExprEvaluatorTest extends \PHPUnit\Framework\TestCase
{
/** @dataProvider provideTestEvaluate */
public function testEvaluate($exprString, $expected) {
@@ -3,9 +3,8 @@
namespace PhpParser\ErrorHandler;
use PhpParser\Error;
use PHPUnit\Framework\TestCase;
class CollectingTest extends TestCase
class CollectingTest extends \PHPUnit\Framework\TestCase
{
public function testHandleError() {
$errorHandler = new Collecting();
@@ -3,9 +3,8 @@
namespace PhpParser\ErrorHandler;
use PhpParser\Error;
use PHPUnit\Framework\TestCase;
class ThrowingTest extends TestCase
class ThrowingTest extends \PHPUnit\Framework\TestCase
{
public function testHandleError() {
$this->expectException(Error::class);
@@ -2,9 +2,7 @@
namespace PhpParser;
use PHPUnit\Framework\TestCase;
class ErrorTest extends TestCase
class ErrorTest extends \PHPUnit\Framework\TestCase
{
public function testConstruct() {
$attributes = [
@@ -2,9 +2,7 @@
namespace PhpParser\Internal;
use PHPUnit\Framework\TestCase;
class DifferTest extends TestCase
class DifferTest extends \PHPUnit\Framework\TestCase
{
private function formatDiffString(array $diff) {
$diffStr = '';
@@ -2,9 +2,7 @@
namespace PhpParser;
use PHPUnit\Framework\TestCase;
class JsonDecoderTest extends TestCase
class JsonDecoderTest extends \PHPUnit\Framework\TestCase
{
public function testRoundTrip() {
$code = <<<'PHP'
@@ -6,8 +6,6 @@
use PhpParser\LexerTest;
use PhpParser\Parser\Tokens;
require_once __DIR__ . '/../LexerTest.php';
class EmulativeTest extends LexerTest
{
protected function getLexer(array $options = []) {
@@ -3,9 +3,8 @@
namespace PhpParser;
use PhpParser\Parser\Tokens;
use PHPUnit\Framework\TestCase;
class LexerTest extends TestCase
class LexerTest extends \PHPUnit\Framework\TestCase
{
/* To allow overwriting in parent class */
protected function getLexer(array $options = []) {
@@ -4,9 +4,8 @@
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Use_;
use PHPUnit\Framework\TestCase;
class NameContextTest extends TestCase
class NameContextTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider provideTestGetPossibleNames
@@ -2,9 +2,7 @@
namespace PhpParser\Node;
use PHPUnit\Framework\TestCase;
class IdentifierTest extends TestCase
class IdentifierTest extends \PHPUnit\Framework\TestCase
{
public function testToString() {
$identifier = new Identifier('Foo');
@@ -2,9 +2,7 @@
namespace PhpParser\Node;
use PHPUnit\Framework\TestCase;
class NameTest extends TestCase
class NameTest extends \PHPUnit\Framework\TestCase
{
public function testConstruct() {
$name = new Name(['foo', 'bar']);
@@ -2,9 +2,7 @@
namespace PhpParser\Node\Scalar;
use PHPUnit\Framework\TestCase;
class MagicConstTest extends TestCase
class MagicConstTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider provideTestGetName

0 comments on commit b7e6361

Please sign in to comment.
You can’t perform that action at this time.