mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 09:20:52 +00:00
fix cs
This commit is contained in:
parent
a270d174c9
commit
3bfad4e873
|
@ -124,7 +124,7 @@ final class ArgumentReplacerRector extends AbstractRector
|
|||
$argumentReplacerItemRecipes = [];
|
||||
|
||||
foreach ($this->argumentReplacerRecipes as $argumentReplacerRecipe) {
|
||||
if ($this->isTypeAndMethod($node, $argumentReplacerRecipe->getClass(), $argumentReplacerRecipe->getMethod())) {
|
||||
if ($this->isRecipeMatch($node, $argumentReplacerRecipe)) {
|
||||
$argumentReplacerItemRecipes[] = $argumentReplacerRecipe;
|
||||
}
|
||||
}
|
||||
|
@ -161,8 +161,11 @@ final class ArgumentReplacerRector extends AbstractRector
|
|||
}
|
||||
}
|
||||
|
||||
private function isTypeAndMethod(Node $node, string $type, string $method): bool
|
||||
private function isRecipeMatch(Node $node, ArgumentReplacerRecipe $argumentReplacerRecipe): bool
|
||||
{
|
||||
$type = $argumentReplacerRecipe->getClass();
|
||||
$method = $argumentReplacerRecipe->getMethod();
|
||||
|
||||
if ($this->methodCallAnalyzer->isTypeAndMethods($node, $type, [$method])) {
|
||||
return true;
|
||||
}
|
||||
|
@ -174,6 +177,9 @@ final class ArgumentReplacerRector extends AbstractRector
|
|||
return $this->classMethodAnalyzer->isTypeAndMethods($node, $type, [$method]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $configurationArrays
|
||||
*/
|
||||
private function loadArgumentReplacerItemRecipes(array $configurationArrays): void
|
||||
{
|
||||
foreach ($configurationArrays as $configurationArray) {
|
||||
|
|
|
@ -25,14 +25,17 @@ final class ArgumentReplacerRecipe
|
|||
* @var string
|
||||
*/
|
||||
private $class;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $method;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $position;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -74,14 +77,7 @@ final class ArgumentReplacerRecipe
|
|||
public static function createFromArray(array $data): self
|
||||
{
|
||||
// @todo: make exceptions clear for end user
|
||||
Assert::keyExists($data, 'class');
|
||||
Assert::keyExists($data, 'method');
|
||||
Assert::keyExists($data, 'position');
|
||||
Assert::keyExists($data, 'type');
|
||||
|
||||
if ($data['type'] === 'replace_default_value') {
|
||||
Assert::keyExists($data, 'replace_map');
|
||||
}
|
||||
self::validateArrayData($data);
|
||||
|
||||
return new self(
|
||||
$data['class'],
|
||||
|
@ -93,6 +89,21 @@ final class ArgumentReplacerRecipe
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
private static function validateArrayData(array $data): void
|
||||
{
|
||||
Assert::keyExists($data, 'class');
|
||||
Assert::keyExists($data, 'method');
|
||||
Assert::keyExists($data, 'position');
|
||||
Assert::keyExists($data, 'type');
|
||||
|
||||
if ($data['type'] === 'replace_default_value') {
|
||||
Assert::keyExists($data, 'replace_map');
|
||||
}
|
||||
}
|
||||
|
||||
public function getClass(): string
|
||||
{
|
||||
return $this->class;
|
||||
|
|
Loading…
Reference in New Issue
Block a user