1
0
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:
orklah 2021-10-21 22:38:59 +02:00 committed by GitHub
commit 2d90631c87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -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)

View File

@ -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
{
}
',
],
];
}