From ec59876935b10327d5e729169b286717d0bc63be Mon Sep 17 00:00:00 2001 From: orklah Date: Mon, 18 Oct 2021 21:27:11 +0200 Subject: [PATCH 1/3] only fuse array & Traversable with phpstorm generics --- src/Psalm/Internal/Type/TypeCombiner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php index 8c86dd9c7..2e4e0e246 100644 --- a/src/Psalm/Internal/Type/TypeCombiner.php +++ b/src/Psalm/Internal/Type/TypeCombiner.php @@ -178,7 +178,7 @@ class TypeCombiner && (isset($combination->named_object_types['Traversable']) || isset($combination->builtin_type_params['Traversable'])) && ( - ($codebase && !$codebase->config->allow_phpstorm_generics) + ($codebase && $codebase->config->allow_phpstorm_generics) || isset($combination->builtin_type_params['Traversable']) || (isset($combination->named_object_types['Traversable']) && $combination->named_object_types['Traversable']->from_docblock) From a9e2284e798d1b46d4a782b3674918edaea8f1d9 Mon Sep 17 00:00:00 2001 From: orklah Date: Mon, 18 Oct 2021 21:51:36 +0200 Subject: [PATCH 2/3] add test --- tests/TypeCombinationTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/TypeCombinationTest.php b/tests/TypeCombinationTest.php index ce7ca543f..09a91aa36 100644 --- a/tests/TypeCombinationTest.php +++ b/tests/TypeCombinationTest.php @@ -65,6 +65,25 @@ class TypeCombinationTest extends TestCase rand(0,1) ? die() : other();', ], + 'ArrayAndTraversableNotIterable' => [ + ' $_a */ + function expectsTraversableOrArray($_a): void + { + + } + ', + ], ]; } From 5d154e1bda597571064235b65667b401ee159e50 Mon Sep 17 00:00:00 2001 From: orklah Date: Mon, 18 Oct 2021 22:00:51 +0200 Subject: [PATCH 3/3] fix test --- tests/TypeCombinationTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/TypeCombinationTest.php b/tests/TypeCombinationTest.php index 09a91aa36..4850c0987 100644 --- a/tests/TypeCombinationTest.php +++ b/tests/TypeCombinationTest.php @@ -68,7 +68,8 @@ class TypeCombinationTest extends TestCase 'ArrayAndTraversableNotIterable' => [ '