mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 11:44:14 +01:00
fix cyclox
This commit is contained in:
parent
f6d01ebfec
commit
7203e18c7f
@ -35,19 +35,17 @@ final class UnsetAndIssetToMethodCallRector extends AbstractRector
|
||||
private $nodeFactory;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $activeTransformation;
|
||||
private $activeTransformation = [];
|
||||
|
||||
/**
|
||||
* Type to method call()
|
||||
*
|
||||
* @param string[] $typeToMethodCalls
|
||||
*/
|
||||
public function __construct(
|
||||
array $typeToMethodCalls,
|
||||
NodeFactory $nodeFactory
|
||||
) {
|
||||
public function __construct(array $typeToMethodCalls, NodeFactory $nodeFactory)
|
||||
{
|
||||
$this->typeToMethodCalls = $typeToMethodCalls;
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
@ -64,17 +62,13 @@ final class UnsetAndIssetToMethodCallRector extends AbstractRector
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @var ArrayDimFetch $var */
|
||||
foreach ($node->vars as $var) {
|
||||
$variableNode = $var->var;
|
||||
$variableNodeType = $variableNode->getAttribute(Attribute::TYPE);
|
||||
|
||||
foreach ($this->typeToMethodCalls as $type => $transformation) {
|
||||
if ($variableNodeType === $type) {
|
||||
$this->activeTransformation = $transformation;
|
||||
|
||||
return true;
|
||||
if (! $var instanceof ArrayDimFetch) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->matchArrayDimFetch($var)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,4 +117,19 @@ final class UnsetAndIssetToMethodCallRector extends AbstractRector
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function matchArrayDimFetch(ArrayDimFetch $arrayDimFetchNode): bool
|
||||
{
|
||||
$variableNodeType = $arrayDimFetchNode->var->getAttribute(Attribute::TYPE);
|
||||
|
||||
foreach ($this->typeToMethodCalls as $type => $transformation) {
|
||||
if ($variableNodeType === $type) {
|
||||
$this->activeTransformation = $transformation;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user