Skip to content

Commit 3e869c1

Browse files
committed
Updated Rector to commit 3288dc175f3e33b0f8cba66ca849e46093e92a5a
rectorphp/rector-src@3288dc1 [Php85] Skip defined int or string on ArrayKeyExistsNullToEmptyStringRector (#7758)
1 parent fb1ee2b commit 3e869c1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

rules/Php85/Rector/FuncCall/ArrayKeyExistsNullToEmptyStringRector.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
declare (strict_types=1);
44
namespace Rector\Php85\Rector\FuncCall;
55

6+
use PHPStan\Type\UnionType;
7+
use PHPStan\Type\TypeCombinator;
68
use PhpParser\Node;
79
use PhpParser\Node\Expr\FuncCall;
810
use PHPStan\Analyser\Scope;
@@ -81,8 +83,16 @@ public function refactor(Node $node): ?Node
8183
if (!$functionReflection instanceof FunctionReflection) {
8284
return null;
8385
}
86+
$argPosition = $this->argsAnalyzer->resolveArgPosition($args, 'key', 0);
87+
$originalType = $this->getType($args[$argPosition]->value);
88+
if ($originalType instanceof UnionType) {
89+
$withoutNullParameterType = TypeCombinator::removeNull($originalType);
90+
if ($withoutNullParameterType->equals($originalType)) {
91+
return null;
92+
}
93+
}
8494
$parametersAcceptor = ParametersAcceptorSelectorVariantsWrapper::select($functionReflection, $node, $scope);
85-
$result = $this->nullToStrictStringIntConverter->convertIfNull($node, $args, $this->argsAnalyzer->resolveArgPosition($args, 'key', 0), $isTrait, $scope, $parametersAcceptor);
95+
$result = $this->nullToStrictStringIntConverter->convertIfNull($node, $args, $argPosition, $isTrait, $scope, $parametersAcceptor);
8696
if ($result instanceof Node) {
8797
return $result;
8898
}

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '234de212fc22f05fb5e8914e28d4fea8bd7c3d9f';
22+
public const PACKAGE_VERSION = '3288dc175f3e33b0f8cba66ca849e46093e92a5a';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-12-25 13:11:38';
27+
public const RELEASE_DATE = '2025-12-25 13:15:51';
2828
/**
2929
* @var int
3030
*/

0 commit comments

Comments
 (0)