diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php index a73769fba13..841f6edd2c2 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php @@ -518,6 +518,6 @@ private function narrowBoolType( return $phpParserUnionType; } - return $this->phpStanStaticTypeMapper->mapToPhpParserNode($unionType, $typeKind); + return null; } } diff --git a/rules-tests/Php80/Rector/FunctionLike/UnionTypesRector/Fixture/narrow_bool_false2.php.inc b/rules-tests/Php80/Rector/FunctionLike/UnionTypesRector/Fixture/skip_narrow_bool_false_another_type.php.inc similarity index 50% rename from rules-tests/Php80/Rector/FunctionLike/UnionTypesRector/Fixture/narrow_bool_false2.php.inc rename to rules-tests/Php80/Rector/FunctionLike/UnionTypesRector/Fixture/skip_narrow_bool_false_another_type.php.inc index 5c01fda4886..9d34cfb7c41 100644 --- a/rules-tests/Php80/Rector/FunctionLike/UnionTypesRector/Fixture/narrow_bool_false2.php.inc +++ b/rules-tests/Php80/Rector/FunctionLike/UnionTypesRector/Fixture/skip_narrow_bool_false_another_type.php.inc @@ -2,7 +2,7 @@ namespace Rector\Tests\Php80\Rector\FunctionLike\UnionTypesRector\Fixture; -class NarrowBoolFalse2 +class SkipNarrowBoolFalseAnotherType { /** * @param bool|int|false $param @@ -17,23 +17,3 @@ class NarrowBoolFalse2 return 1; } } - -?> ------ - diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector/FixtureUnion/narrow_union_multi_params.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector/FixtureUnion/narrow_union_multi_params.php.inc new file mode 100644 index 00000000000..8531b9b148d --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector/FixtureUnion/narrow_union_multi_params.php.inc @@ -0,0 +1,51 @@ +someExpr($methodCall, $staticCall); + $this->someExpr($staticCall, $staticCall); + $this->someExpr($string, $staticCall); + } + + private function someExpr($expr, $staticCall) + { + } +} + +?> +----- +someExpr($methodCall, $staticCall); + $this->someExpr($staticCall, $staticCall); + $this->someExpr($string, $staticCall); + } + + private function someExpr(\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Scalar\String_ $expr, \PhpParser\Node\Expr\StaticCall $staticCall) + { + } +} + +?> diff --git a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php index 149799831d6..579d06c3176 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php +++ b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php @@ -38,13 +38,8 @@ public function __construct( public function complete(ClassMethod $classMethod, array $classParameterTypes, int $maxUnionTypes): ?ClassMethod { $hasChanged = false; - $totalTypes = count($classParameterTypes); foreach ($classParameterTypes as $position => $argumentStaticType) { - if ($totalTypes > 1 && $argumentStaticType instanceof UnionType) { - return null; - } - /** @var Type $argumentStaticType */ if ($this->shouldSkipArgumentStaticType($classMethod, $argumentStaticType, $position, $maxUnionTypes)) { continue;