drop CompilerAddPassPriorityRector, still optional

This commit is contained in:
Tomas Votruba 2018-04-08 11:54:15 +02:00
parent e7e5676475
commit a89860e631
6 changed files with 0 additions and 120 deletions

View File

@ -4,7 +4,6 @@ services:
Rector\Rector\Contrib\Symfony\Form\StringFormTypeToClassRector: ~
Rector\Rector\Contrib\Symfony\VarDumper\VarDumperTestTraitMethodArgsRector: ~
Rector\Rector\Contrib\Symfony\DependencyInjection\ContainerBuilderCompileEnvArgumentRector: ~
Rector\Rector\Contrib\Symfony\DependencyInjection\CompilerAddPassPriorityRector: ~
Rector\Rector\Contrib\Symfony\Process\ProcessBuilderInstanceRector: ~
Rector\Rector\Contrib\Symfony\Process\ProcessBuilderGetProcessRector: ~

View File

@ -1,75 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\Rector\Contrib\Symfony\DependencyInjection;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use Rector\Node\NodeFactory;
use Rector\NodeAnalyzer\MethodCallAnalyzer;
use Rector\Rector\AbstractRector;
/**
* Covers @see \Symfony\Component\DependencyInjection\Compiler\Compiler::addPass()
*
* Before:
* - add($pass)
* - add($pass, $type)
* - add($pass, $type, 0)
*
* After:
* ?
*/
final class CompilerAddPassPriorityRector extends AbstractRector
{
/**
* @var MethodCallAnalyzer
*/
private $methodCallAnalyzer;
/**
* @var NodeFactory
*/
private $nodeFactory;
public function __construct(MethodCallAnalyzer $methodCallAnalyzer, NodeFactory $nodeFactory)
{
$this->methodCallAnalyzer = $methodCallAnalyzer;
$this->nodeFactory = $nodeFactory;
}
public function isCandidate(Node $node): bool
{
if ($this->methodCallAnalyzer->isTypeAndMethods(
$node,
'Symfony\Component\DependencyInjection\Compiler\Compiler',
['addPass']
) === false) {
return false;
}
/** @var MethodCall $methodCallNode */
$methodCallNode = $node;
$args = $methodCallNode->args;
// has 3 arguments, all is done
return count($args) !== 3;
}
/**
* @param MethodCall $methodCallNode
*/
public function refactor(Node $methodCallNode): ?Node
{
$arguments = $methodCallNode->args;
if (count($arguments) === 2) {
// add 3rd one
$arguments[] = $this->nodeFactory->createArg(0);
$methodCallNode->args = $arguments;
}
return $methodCallNode;
}
}

View File

@ -1,34 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\Tests\Rector\Contrib\Symfony\DependencyInjection\CompileAddPassPriorityRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
/**
* @covers \Rector\Rector\Contrib\Symfony\DependencyInjection\CompilerAddPassPriorityRector
*/
final class CompileAddPassPriorityRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideWrongToFixedFiles()
*/
public function test(string $wrong, string $fixed): void
{
$this->doTestFileMatchesExpectedContent($wrong, $fixed);
}
/**
* @return string[][]
*/
public function provideWrongToFixedFiles(): array
{
return [
[__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc'],
];
}
protected function provideConfig(): string
{
return __DIR__ . '/config.yml';
}
}

View File

@ -1,4 +0,0 @@
<?php declare(strict_types=1);
$compiler = new \Symfony\Component\DependencyInjection\Compiler\Compiler();
$compiler->addPass($somePass, 5, 0);

View File

@ -1,4 +0,0 @@
<?php declare(strict_types=1);
$compiler = new \Symfony\Component\DependencyInjection\Compiler\Compiler();
$compiler->addPass($somePass, 5);

View File

@ -1,2 +0,0 @@
services:
Rector\Rector\Contrib\Symfony\DependencyInjection\CompilerAddPassPriorityRector: ~