mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
Merge pull request #6689 from orklah/traversable&array
only fuse array & Traversable with phpstorm generics
This commit is contained in:
commit
2d90631c87
@ -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)
|
||||
|
@ -65,6 +65,26 @@ class TypeCombinationTest extends TestCase
|
||||
|
||||
rand(0,1) ? die() : other();',
|
||||
],
|
||||
'ArrayAndTraversableNotIterable' => [
|
||||
'<?php declare(strict_types=1);
|
||||
|
||||
/** @param mixed $identifier */
|
||||
function isNullIdentifier($identifier): bool
|
||||
{
|
||||
if ($identifier instanceof \Traversable || is_array($identifier)) {
|
||||
expectsTraversableOrArray($identifier);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @param Traversable|array<array-key, mixed> $_a */
|
||||
function expectsTraversableOrArray($_a): void
|
||||
{
|
||||
|
||||
}
|
||||
',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user