remove Argument deprecations

This commit is contained in:
Tomas Votruba 2018-12-12 19:06:31 +01:00
parent 04626f4e5d
commit a3a451f3ab
3 changed files with 2 additions and 69 deletions

View File

@ -1,10 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\Contract\Configuration\Rector;
interface ArgumentRecipeInterface
{
public function getClass(): string;
public function getMethod(): string;
}

View File

@ -1,58 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\Rector\Argument;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Contract\Configuration\Rector\ArgumentRecipeInterface;
use Rector\Rector\AbstractRector;
abstract class AbstractArgumentRector extends AbstractRector
{
protected function isNodeToRecipeMatch(Node $node, ArgumentRecipeInterface $argumentRecipe): bool
{
$type = $argumentRecipe->getClass();
$method = $argumentRecipe->getMethod();
if (! $this->isType($node, $type)) {
return false;
}
return $this->isName($node, $method);
}
/**
* @return Arg[]|Param[]
*/
protected function getNodeArgumentsOrParameters(Node $node): array
{
if ($node instanceof MethodCall || $node instanceof StaticCall) {
return $node->args;
}
if ($node instanceof ClassMethod) {
return $node->params;
}
return [];
}
/**
* @param MethodCall|StaticCall|ClassMethod $node
* @param mixed[] $argumentsOrParameters
*/
protected function setNodeArgumentsOrParameters(Node $node, array $argumentsOrParameters): void
{
if ($node instanceof MethodCall || $node instanceof StaticCall) {
$node->args = $argumentsOrParameters;
}
if ($node instanceof ClassMethod) {
$node->params = $argumentsOrParameters;
}
}
}

View File

@ -10,10 +10,11 @@ use PhpParser\Node\Arg;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\ConfiguredCodeSample;
use Rector\RectorDefinition\RectorDefinition;
final class ArgumentDefaultValueReplacerRector extends AbstractArgumentRector
final class ArgumentDefaultValueReplacerRector extends AbstractRector
{
/**
* @var mixed[]