Skip to content

Commit 7d4f22c

Browse files
committed
use
1 parent 1909e73 commit 7d4f22c

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

rules/Php85/Rector/FuncCall/ArrayKeyExistsNullToEmptyStringRector.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PHPStan\Analyser\Scope;
1212
use PHPStan\Reflection\ClassReflection;
1313
use PHPStan\Reflection\FunctionReflection;
14+
use Rector\NodeAnalyzer\ArgsAnalyzer;
1415
use Rector\NodeTypeResolver\Node\AttributeKey;
1516
use Rector\NodeTypeResolver\PHPStan\ParametersAcceptorSelectorVariantsWrapper;
1617
use Rector\Php81\NodeManipulator\NullToStrictStringIntConverter;
@@ -29,7 +30,8 @@ final class ArrayKeyExistsNullToEmptyStringRector extends AbstractRector impleme
2930
{
3031
public function __construct(
3132
private readonly ReflectionResolver $reflectionResolver,
32-
private readonly NullToStrictStringIntConverter $nullToStrictStringIntConverter
33+
private readonly NullToStrictStringIntConverter $nullToStrictStringIntConverter,
34+
private readonly ArgsAnalyzer $argsAnalyzer
3335
) {
3436
}
3537

@@ -93,7 +95,7 @@ public function refactor(Node $node): ?Node
9395
$result = $this->nullToStrictStringIntConverter->convertIfNull(
9496
$node,
9597
$args,
96-
$this->resolvePosition($args),
98+
$this->argsAnalyzer->resolveArgPosition($args, 'key', 0),
9799
$isTrait,
98100
$scope,
99101
$parametersAcceptor
@@ -109,18 +111,4 @@ public function provideMinPhpVersion(): int
109111
{
110112
return PhpVersionFeature::DEPRECATE_NULL_ARG_IN_ARRAY_KEY_EXISTS_FUNCTION;
111113
}
112-
113-
/**
114-
* @param Arg[] $args
115-
*/
116-
private function resolvePosition(array $args): int
117-
{
118-
foreach ($args as $position => $arg) {
119-
if ($arg->name instanceof Identifier && $arg->name->toString() === 'key') {
120-
return $position;
121-
}
122-
}
123-
124-
return 0;
125-
}
126114
}

0 commit comments

Comments
 (0)