mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit 2c65489cfd178fbd0e4d2b52b504a7541e34bc59
2c65489cfd
[Php81] Skip another possible cast array to string on NullToStrictStringFuncCallArgRector (#5589)
This commit is contained in:
parent
e32eadddc1
commit
3f928476d9
@ -27,7 +27,6 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\ParametersAcceptorSelectorVariantsWrapper;
|
||||
use Rector\Php81\Enum\NameNullToStrictNullFunctionMap;
|
||||
use Rector\PhpParser\Node\Value\ValueResolver;
|
||||
use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\Reflection\ReflectionResolver;
|
||||
use Rector\ValueObject\PhpVersionFeature;
|
||||
@ -59,18 +58,12 @@ final class NullToStrictStringFuncCallArgRector extends AbstractRector implement
|
||||
* @var \Rector\PhpParser\Node\Value\ValueResolver
|
||||
*/
|
||||
private $valueResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer
|
||||
*/
|
||||
private $unionTypeAnalyzer;
|
||||
public function __construct(ReflectionResolver $reflectionResolver, ArgsAnalyzer $argsAnalyzer, PropertyFetchAnalyzer $propertyFetchAnalyzer, ValueResolver $valueResolver, UnionTypeAnalyzer $unionTypeAnalyzer)
|
||||
public function __construct(ReflectionResolver $reflectionResolver, ArgsAnalyzer $argsAnalyzer, PropertyFetchAnalyzer $propertyFetchAnalyzer, ValueResolver $valueResolver)
|
||||
{
|
||||
$this->reflectionResolver = $reflectionResolver;
|
||||
$this->argsAnalyzer = $argsAnalyzer;
|
||||
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
|
||||
$this->valueResolver = $valueResolver;
|
||||
$this->unionTypeAnalyzer = $unionTypeAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
@ -196,9 +189,25 @@ CODE_SAMPLE
|
||||
$funcCall->args = $args;
|
||||
return $funcCall;
|
||||
}
|
||||
private function isValidUnionType(Type $type) : bool
|
||||
{
|
||||
if (!$type instanceof UnionType) {
|
||||
return \false;
|
||||
}
|
||||
foreach ($type->getTypes() as $childType) {
|
||||
if ($childType->isString()->yes()) {
|
||||
continue;
|
||||
}
|
||||
if ($childType->isNull()->yes()) {
|
||||
continue;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
private function shouldSkipType(Type $type) : bool
|
||||
{
|
||||
return !$type instanceof MixedType && !$type instanceof NullType && !($type instanceof UnionType && $this->unionTypeAnalyzer->isNullable($type, \true));
|
||||
return !$type instanceof MixedType && !$type instanceof NullType && !$this->isValidUnionType($type);
|
||||
}
|
||||
private function shouldSkipTrait(Expr $expr, Type $type, bool $isTrait) : bool
|
||||
{
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'a43f041278835523c96758f6df5d0e964e51ee9d';
|
||||
public const PACKAGE_VERSION = '2c65489cfd178fbd0e4d2b52b504a7541e34bc59';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-02-09 15:09:10';
|
||||
public const RELEASE_DATE = '2024-02-09 15:48:01';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user