remove few PHP-Parser rules to prevent package-rules vs package-features confussion

This commit is contained in:
Tomas Votruba 2019-09-06 12:30:58 +02:00
parent 84adad668b
commit 2cb3f04945
27 changed files with 118 additions and 906 deletions

View File

@ -1,4 +1,4 @@
# All 336 Rectors Overview
# All 335 Rectors Overview
- [Projects](#projects)
- [General](#general)
@ -26,7 +26,6 @@
- [PHPUnitSymfony](#phpunitsymfony)
- [PSR4](#psr4)
- [Php](#php)
- [PhpParser](#phpparser)
- [PhpSpecToPHPUnit](#phpspectophpunit)
- [RemovingStatic](#removingstatic)
- [Restoration](#restoration)
@ -1390,6 +1389,29 @@ services:
## DeadCode
### `RemoveAlwaysTrueIfConditionRector`
- class: `Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector`
Remove if condition that is always true
```diff
final class SomeClass
{
public function go()
{
- if (1 === 1) {
- return 'yes';
- }
+ return 'yes';
return 'no';
}
}
```
<br>
### `RemoveAndTrueRector`
- class: `Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector`
@ -1928,9 +1950,25 @@ Removes unneeded $a = $a assigns
## Doctrine
### `AliasToClassRector`
### `AddUuidMirrorForRelationPropertyRector`
- class: `Rector\Doctrine\Rector\AliasToClassRector`
- class: `Rector\Doctrine\Rector\Class_\AddUuidMirrorForRelationPropertyRector`
Adds $uuid property to entities, that already have $id with integer type.Require for step-by-step migration from int to uuid.
<br>
### `AddUuidToEntityWhereMissingRector`
- class: `Rector\Doctrine\Rector\Class_\AddUuidToEntityWhereMissingRector`
Adds $uuid property to entities, that already have $id with integer type.Require for step-by-step migration from int to uuid. In following step it should be renamed to $id and replace it
<br>
### `EntityAliasToClassConstantReferenceRector`
- class: `Rector\Doctrine\Rector\MethodCall\EntityAliasToClassConstantReferenceRector`
Replaces doctrine alias with class.
@ -2721,6 +2759,72 @@ Removes non-existing @var annotations above the code
## PHPUnit
### `AddSeeTestAnnotationRector`
- class: `Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector`
Add @see annotation test of the class for faster jump to test. Make it FQN, so it stays in the annotation, not in the PHP source code.
```diff
+/**
+ * @see \SomeServiceTest
+ */
class SomeService
{
}
class SomeServiceTest extends \PHPUnit\Framework\TestCase
{
}
```
<br>
### `ArrayArgumentInTestToDataProviderRector`
- class: `Rector\PHPUnit\Rector\Class_\ArrayArgumentInTestToDataProviderRector`
Move array argument from tests into data provider [configurable]
```yaml
services:
Rector\PHPUnit\Rector\Class_\ArrayArgumentInTestToDataProviderRector:
$configuration:
-
class: PHPUnit\Framework\TestCase
old_method: doTestMultiple
new_method: doTestSingle
```
```diff
class SomeServiceTest extends \PHPUnit\Framework\TestCase
{
- public function test()
+ /**
+ * @dataProvider provideDataForTest()
+ */
+ public function test(int $value)
{
- $this->doTestMultiple([1, 2, 3]);
+ $this->doTestSingle($value);
+ }
+
+ /**
+ * @return int[]
+ */
+ public function provideDataForTest(): iterable
+ {
+ yield 1;
+ yield 2;
+ yield 3;
}
}
```
<br>
### `AssertCompareToSpecificMethodRector`
- class: `Rector\PHPUnit\Rector\SpecificMethod\AssertCompareToSpecificMethodRector`
@ -4486,100 +4590,6 @@ each() function is deprecated, use foreach() instead.
<br>
## PhpParser
### `CatchAndClosureUseNameRector`
- class: `Rector\PhpParser\Rector\CatchAndClosureUseNameRector`
Turns `$catchNode->var` to its new `name` property in php-parser
```diff
-$catchNode->var;
+$catchNode->var->name
```
<br>
### `IdentifierRector`
- class: `Rector\PhpParser\Rector\IdentifierRector`
Turns node string names to Identifier object in php-parser
```diff
$constNode = new PhpParser\Node\Const_;
-$name = $constNode->name;
+$name = $constNode->name->toString();'
```
<br>
### `ParamAndStaticVarNameRector`
- class: `Rector\PhpParser\Rector\ParamAndStaticVarNameRector`
Turns old string `var` to `var->name` sub-variable in Node of PHP-Parser
```diff
-$paramNode->name;
+$paramNode->var->name;
```
```diff
-$staticVarNode->name;
+$staticVarNode->var->name;
```
<br>
### `RemoveNodeRector`
- class: `Rector\PhpParser\Rector\RemoveNodeRector`
Turns integer return to remove node to constant in NodeVisitor of PHP-Parser
```diff
public function leaveNode()
{
- return false;
+ return NodeTraverser::REMOVE_NODE;
}
```
<br>
### `SetLineRector`
- class: `Rector\PhpParser\Rector\SetLineRector`
Turns standalone line method to attribute in Node of PHP-Parser
```diff
-$node->setLine(5);
+$node->setAttribute("line", 5);
```
<br>
### `UseWithAliasRector`
- class: `Rector\PhpParser\Rector\UseWithAliasRector`
Turns use property to method and `$node->alias` to last name in UseAlias Node of PHP-Parser
```diff
-$node->alias;
+$node->getAlias();
```
```diff
-$node->name->getLast();
+$node->alias
```
<br>
## PhpSpecToPHPUnit
### `AddMockPropertiesRector`
@ -6874,8 +6884,9 @@ Turns defined annotations above properties and methods to their new values.
```yaml
services:
Rector\Rector\Annotation\RenameAnnotationRector:
PHPUnit\Framework\TestCase:
test: scenario
$classToAnnotationMap:
PHPUnit\Framework\TestCase:
test: scenario
```
@ -6953,7 +6964,8 @@ Replaces defined classes by new ones.
```yaml
services:
Rector\Rector\Class_\RenameClassRector:
App\SomeOldClass: App\SomeNewClass
$oldToNewClasses:
App\SomeOldClass: App\SomeNewClass
```

View File

@ -2,7 +2,6 @@
namespace Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer;
use PhpParser\Node\Stmt\Use_;
use Nette\Utils\Strings;
use PhpParser\Comment\Doc;
use PhpParser\Node;
@ -11,6 +10,7 @@ use PhpParser\Node\FunctionLike;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Use_;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;

View File

@ -1,65 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Rector;
use PhpParser\Node;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
/**
* @see \Rector\PhpParser\Tests\Rector\CatchAndClosureUseNameRector\CatchAndClosureUseNameRectorTest
*/
final class CatchAndClosureUseNameRector extends AbstractRector
{
public function getDefinition(): RectorDefinition
{
return new RectorDefinition('Turns `$catchNode->var` to its new `name` property in php-parser', [
new CodeSample('$catchNode->var;', '$catchNode->var->name'),
]);
}
/**
* @return string[]
*/
public function getNodeTypes(): array
{
return [PropertyFetch::class];
}
/**
* @param PropertyFetch $node
*/
public function refactor(Node $node): ?Node
{
if (! $this->isObjectTypes($node->var, ['PhpParser\Node\Stmt\Catch_', 'PhpParser\Node\Expr\ClosureUse'])) {
return null;
}
if (! $this->isName($node, 'var')) {
return null;
}
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof PropertyFetch) {
return null;
}
/** @var Variable $variableNode */
$variableNode = $node->var;
$variableName = $this->getName($variableNode);
if ($variableName === null) {
return null;
}
$node->var = $this->createPropertyFetch($variableName, 'var');
$node->name = new Identifier('name');
return $node;
}
}

View File

@ -1,94 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Rector;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\PropertyFetch;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
/**
* Covers part of https://github.com/nikic/PHP-Parser/blob/master/UPGRADE-4.0.md
* @see \Rector\PhpParser\Tests\Rector\IdentifierRector\IdentifierRectorTest
*/
final class IdentifierRector extends AbstractRector
{
/**
* @var string[][]
*/
private $typeToPropertiesMap = [
'PhpParser\Node\Const_' => ['name'],
'PhpParser\Node\NullableType' => ['type'], // sometimes only
'PhpParser\Node\Param' => ['type'], // sometimes only
'PhpParser\Node\Expr\ClassConstFetch' => ['name'],
'PhpParser\Node\Expr\Closure' => ['returnType'], // sometimes only
'PhpParser\Node\Expr\MethodCall' => ['name'],
'PhpParser\Node\Expr\PropertyFetch' => ['name'],
'PhpParser\Node\Expr\StaticCall' => ['name'],
'PhpParser\Node\Expr\StaticPropertyFetch' => ['name'],
'PhpParser\Node\Stmt\Class_' => ['name'],
'PhpParser\Node\Stmt\ClassMethod' => ['name', 'returnType' /* sometimes only */],
'PhpParser\Node\Stmt\Function' => ['name', 'returnType' /* sometimes only */],
'PhpParser\Node\Stmt\Goto_' => ['name'],
'PhpParser\Node\Stmt\Interface_' => ['name'],
'PhpParser\Node\Stmt\Label' => ['name'],
'PhpParser\Node\Stmt\PropertyProperty' => ['name'],
'PhpParser\Node\Stmt\TraitUseAdaptation\Alias' => ['method', 'newName'],
'PhpParser\Node\Stmt\TraitUseAdaptation\Precedence' => ['method'],
'PhpParser\Node\Stmt\Trait_' => ['name'],
'PhpParser\Node\Stmt\UseUse' => ['alias'],
];
public function getDefinition(): RectorDefinition
{
return new RectorDefinition('Turns node string names to Identifier object in php-parser', [
new CodeSample(
<<<'CODE_SAMPLE'
$constNode = new PhpParser\Node\Const_;
$name = $constNode->name;
CODE_SAMPLE
,
<<<'CODE_SAMPLE'
$constNode = new PhpParser\Node\Const_;
$name = $constNode->name->toString();'
CODE_SAMPLE
),
]);
}
/**
* @return string[]
*/
public function getNodeTypes(): array
{
return [PropertyFetch::class];
}
/**
* @param PropertyFetch $node
*/
public function refactor(Node $node): ?Node
{
foreach ($this->typeToPropertiesMap as $type => $properties) {
if (! $this->isObjectType($node->var, $type)) {
continue;
}
if (! $this->isNames($node, $properties)) {
continue;
}
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof MethodCall) {
continue;
}
return $this->createMethodCall($node, 'toString');
}
return null;
}
}

View File

@ -1,50 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Rector;
use PhpParser\Node;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Identifier;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
/**
* @see \Rector\PhpParser\Tests\Rector\ParamAndStaticVarNameRector\ParamAndStaticVarNameRectorTest
*/
final class ParamAndStaticVarNameRector extends AbstractRector
{
public function getDefinition(): RectorDefinition
{
return new RectorDefinition('Turns old string `var` to `var->name` sub-variable in Node of PHP-Parser', [
new CodeSample('$paramNode->name;', '$paramNode->var->name;'),
new CodeSample('$staticVarNode->name;', '$staticVarNode->var->name;'),
]);
}
/**
* @return string[]
*/
public function getNodeTypes(): array
{
return [PropertyFetch::class];
}
/**
* @param PropertyFetch $node
*/
public function refactor(Node $node): ?Node
{
if (! $this->isObjectTypes($node->var, ['PhpParser\Node\Param', 'PhpParser\Node\Stmt\StaticVar'])) {
return null;
}
if (! $this->isName($node, 'name')) {
return null;
}
$node->name = new Identifier('var');
return new PropertyFetch($node, 'name');
}
}

View File

@ -1,70 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Rector;
use PhpParser\Node;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Stmt\Return_;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
/**
* Covers: https://github.com/nikic/PHP-Parser/commit/987c61e935a7d73485b4d73aef7a17a4c1e2e325
* @see \Rector\PhpParser\Tests\Rector\RemoveNodeRector\RemoveNodeRectorTest
*/
final class RemoveNodeRector extends AbstractRector
{
public function getDefinition(): RectorDefinition
{
return new RectorDefinition('Turns integer return to remove node to constant in NodeVisitor of PHP-Parser', [
new CodeSample(
<<<'CODE_SAMPLE'
public function leaveNode()
{
return false;
}
CODE_SAMPLE
,
<<<'CODE_SAMPLE'
public function leaveNode()
{
return NodeTraverser::REMOVE_NODE;
}
CODE_SAMPLE
),
]);
}
/**
* @return string[]
*/
public function getNodeTypes(): array
{
return [Return_::class];
}
/**
* @param Return_ $node
*/
public function refactor(Node $node): ?Node
{
if (! $node->expr instanceof ConstFetch) {
return null;
}
$methodName = $node->getAttribute(AttributeKey::METHOD_NAME);
if ($methodName !== 'leaveNode') {
return null;
}
if (! $this->isFalse($node->expr)) {
return null;
}
$node->expr = $this->createClassConstant('PhpParser\NodeTraverser', 'REMOVE_NODE');
return $node;
}
}

View File

@ -1,53 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Rector;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Scalar\String_;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
/**
* @see \Rector\PhpParser\Tests\Rector\SetLineRector\SetLineRectorTest
*/
final class SetLineRector extends AbstractRector
{
public function getDefinition(): RectorDefinition
{
return new RectorDefinition('Turns standalone line method to attribute in Node of PHP-Parser', [
new CodeSample('$node->setLine(5);', '$node->setAttribute("line", 5);'),
]);
}
/**
* @return string[]
*/
public function getNodeTypes(): array
{
return [MethodCall::class];
}
/**
* @param MethodCall $node
*/
public function refactor(Node $node): ?Node
{
if (! $this->isObjectType($node->var, 'PhpParser\Node')) {
return null;
}
if (! $this->isName($node, 'setLine')) {
return null;
}
$node->name = new Identifier('setAttribute');
$node->args[1] = $node->args[0];
$node->args[0] = $this->createArg(new String_('line'));
return $node;
}
}

View File

@ -1,53 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Rector;
use PhpParser\Node;
use PhpParser\Node\Expr\PropertyFetch;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition;
/**
* Covers https://github.com/nikic/PHP-Parser/commit/3da189769cfa19dabd890b85e1a4bfe63cfcc7fb
* @see \Rector\PhpParser\Tests\Rector\UseWithAliasRector\UseWithAliasRectorTest
*/
final class UseWithAliasRector extends AbstractRector
{
public function getDefinition(): RectorDefinition
{
return new RectorDefinition(
'Turns use property to method and `$node->alias` to last name in UseAlias Node of PHP-Parser',
[
new CodeSample('$node->alias;', '$node->getAlias();'),
new CodeSample('$node->name->getLast();', '$node->alias'),
]
);
}
/**
* @return string[]
*/
public function getNodeTypes(): array
{
return [PropertyFetch::class];
}
/**
* @param PropertyFetch $node
*/
public function refactor(Node $node): ?Node
{
if (! $this->isObjectType($node->var, 'PhpParser\Node\Stmt\UseUse')) {
return null;
}
if (! $this->isName($node, 'alias')) {
return null;
}
$getAliasMethodCall = $this->createMethodCall($node->var, 'getAlias');
return $this->createMethodCall($getAliasMethodCall, 'toString');
}
}

View File

@ -1,19 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Tests\Rector\CatchAndClosureUseNameRector;
use Rector\PhpParser\Rector\CatchAndClosureUseNameRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class CatchAndClosureUseNameRectorTest extends AbstractRectorTestCase
{
public function test(): void
{
$this->doTestFiles([__DIR__ . '/Fixture/fixture.php.inc']);
}
public function getRectorClass(): string
{
return CatchAndClosureUseNameRector::class;
}
}

View File

@ -1,23 +0,0 @@
<?php
function catchAndClosureUseName()
{
$closureUseNode = new PhpParser\Node\Expr\ClosureUse;
$string = $closureUseNode->var;
$string = $closureUseNode->var->name;
}
?>
-----
<?php
function catchAndClosureUseName()
{
$closureUseNode = new PhpParser\Node\Expr\ClosureUse;
$string = $closureUseNode->var->name;
$string = $closureUseNode->var->name;
}
?>

View File

@ -1,19 +0,0 @@
<?php
function identifier()
{
$constNode = new \PhpParser\Node\Const_;
$name = $constNode->name;
}
?>
-----
<?php
function identifier()
{
$constNode = new \PhpParser\Node\Const_;
$name = $constNode->name->toString();
}
?>

View File

@ -1,33 +0,0 @@
<?php
namespace Roave\BetterReflection\NodeCompiler;
use PhpParser\Node;
function compileClassConstFetch(Node\Expr\ClassConstFetch $node)
{
if ('class' === $node->name) {
return 'className';
}
return $node->name->toString();
}
?>
-----
<?php
namespace Roave\BetterReflection\NodeCompiler;
use PhpParser\Node;
function compileClassConstFetch(Node\Expr\ClassConstFetch $node)
{
if ('class' === $node->name->toString()) {
return 'className';
}
return $node->name->toString();
}
?>

View File

@ -1,19 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Tests\Rector\IdentifierRector;
use Rector\PhpParser\Rector\IdentifierRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class IdentifierRectorTest extends AbstractRectorTestCase
{
public function test(): void
{
$this->doTestFiles([__DIR__ . '/Fixture/fixture.php.inc', __DIR__ . '/Fixture/fixture2.php.inc']);
}
public function getRectorClass(): string
{
return IdentifierRector::class;
}
}

View File

@ -1,19 +0,0 @@
<?php
function paramAndStaticVarName()
{
$paramNode = new PhpParser\Node\Param;
$paramName = $paramNode->name;
}
?>
-----
<?php
function paramAndStaticVarName()
{
$paramNode = new PhpParser\Node\Param;
$paramName = $paramNode->var->name;
}
?>

View File

@ -1,19 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Tests\Rector\ParamAndStaticVarNameRector;
use Rector\PhpParser\Rector\ParamAndStaticVarNameRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class ParamAndStaticVarNameRectorTest extends AbstractRectorTestCase
{
public function test(): void
{
$this->doTestFiles([__DIR__ . '/Fixture/fixture.php.inc']);
}
public function getRectorClass(): string
{
return ParamAndStaticVarNameRector::class;
}
}

View File

@ -1,27 +0,0 @@
<?php
namespace Rector\PhpParser\Tests\Rector\RemoveNodeRector\Fixture;
class SomeVisitor extends \PhpParser\NodeVisitorAbstract
{
public function leaveNode(\PhpParser\Node $node)
{
return false;
}
}
?>
-----
<?php
namespace Rector\PhpParser\Tests\Rector\RemoveNodeRector\Fixture;
class SomeVisitor extends \PhpParser\NodeVisitorAbstract
{
public function leaveNode(\PhpParser\Node $node)
{
return \PhpParser\NodeTraverser::REMOVE_NODE;
}
}
?>

View File

@ -1,55 +0,0 @@
<?php
namespace Rector\PhpParser\Tests\Rector\RemoveNodeRector\Fixture;
use PhpParser\Node;
class SomeVisitor2 implements \PhpParser\NodeVisitor
{
public function leaveNode(\PhpParser\Node $node)
{
return false;
}
public function beforeTraverse(array $nodes)
{
}
public function enterNode(Node $node)
{
}
public function afterTraverse(array $nodes)
{
}
}
?>
-----
<?php
namespace Rector\PhpParser\Tests\Rector\RemoveNodeRector\Fixture;
use PhpParser\Node;
class SomeVisitor2 implements \PhpParser\NodeVisitor
{
public function leaveNode(\PhpParser\Node $node)
{
return \PhpParser\NodeTraverser::REMOVE_NODE;
}
public function beforeTraverse(array $nodes)
{
}
public function enterNode(Node $node)
{
}
public function afterTraverse(array $nodes)
{
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\PhpParser\Tests\Rector\RemoveNodeRector\Fixture;
class MyAbstractVisitor extends \PhpParser\NodeVisitorAbstract
{
}
class Visitor3 extends MyAbstractVisitor
{
public function leaveNode(\PhpParser\Node $node)
{
return false;
}
}
?>
-----
<?php
namespace Rector\PhpParser\Tests\Rector\RemoveNodeRector\Fixture;
class MyAbstractVisitor extends \PhpParser\NodeVisitorAbstract
{
}
class Visitor3 extends MyAbstractVisitor
{
public function leaveNode(\PhpParser\Node $node)
{
return \PhpParser\NodeTraverser::REMOVE_NODE;
}
}
?>

View File

@ -1,27 +0,0 @@
<?php
namespace Rector\PhpParser\Tests\Rector\RemoveNodeRector\Fixture;
class Visitor4 extends \PhpParser\NodeVisitorAbstract
{
public function leaveNode(\PhpParser\Node $node)
{
return FALSE;
}
}
?>
-----
<?php
namespace Rector\PhpParser\Tests\Rector\RemoveNodeRector\Fixture;
class Visitor4 extends \PhpParser\NodeVisitorAbstract
{
public function leaveNode(\PhpParser\Node $node)
{
return \PhpParser\NodeTraverser::REMOVE_NODE;
}
}
?>

View File

@ -1,24 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Tests\Rector\RemoveNodeRector;
use Rector\PhpParser\Rector\RemoveNodeRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class RemoveNodeRectorTest extends AbstractRectorTestCase
{
public function test(): void
{
$this->doTestFiles([
__DIR__ . '/Fixture/fixture.php.inc',
__DIR__ . '/Fixture/fixture2.php.inc',
__DIR__ . '/Fixture/fixture3.php.inc',
__DIR__ . '/Fixture/fixture4.php.inc',
]);
}
public function getRectorClass(): string
{
return RemoveNodeRector::class;
}
}

View File

@ -1,27 +0,0 @@
<?php
namespace Rector\PhpParser\Tests\Rector\SetLineRector\Fixture;
use PhpParser\Node\Scalar\String_;
function setLine()
{
$node = new String_('hey');
$node->setLine(5);
}
?>
-----
<?php
namespace Rector\PhpParser\Tests\Rector\SetLineRector\Fixture;
use PhpParser\Node\Scalar\String_;
function setLine()
{
$node = new String_('hey');
$node->setAttribute('line', 5);
}
?>

View File

@ -1,19 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Tests\Rector\SetLineRector;
use Rector\PhpParser\Rector\SetLineRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class SetLineRectorTest extends AbstractRectorTestCase
{
public function test(): void
{
$this->doTestFiles([__DIR__ . '/Fixture/fixture.php.inc']);
}
public function getRectorClass(): string
{
return SetLineRector::class;
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace Rector\PhpParser\Tests\Rector\UseWithAliasRector\Fixture;
use PhpParser\Node\Stmt\UseUse;
function useWithAlias()
{
array_map(function (UseUse $useUse) {
return $useUse->alias;
}, null);
}
?>
-----
<?php
namespace Rector\PhpParser\Tests\Rector\UseWithAliasRector\Fixture;
use PhpParser\Node\Stmt\UseUse;
function useWithAlias()
{
array_map(function (UseUse $useUse) {
return $useUse->getAlias()->toString();
}, null);
}
?>

View File

@ -1,19 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\PhpParser\Tests\Rector\UseWithAliasRector;
use Rector\PhpParser\Rector\UseWithAliasRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class UseWithAliasRectorTest extends AbstractRectorTestCase
{
public function test(): void
{
$this->doTestFiles([__DIR__ . '/Fixture/fixture.php.inc']);
}
public function getRectorClass(): string
{
return UseWithAliasRector::class;
}
}

View File

@ -2,11 +2,11 @@
namespace Rector\Rector\AbstractRector;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;

View File

@ -2,8 +2,8 @@
namespace Rector\Rector\Annotation;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Property;
use Rector\NodeTypeResolver\Node\AttributeKey;

View File

@ -2,7 +2,6 @@
namespace Rector\Rector\Argument;
use PhpParser\Node\Stmt\Class_;
use PhpParser\BuilderHelpers;
use PhpParser\Node;
use PhpParser\Node\Arg;
@ -12,6 +11,7 @@ use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Rector\AbstractRector;