1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

don't use is_a with user classes

This commit is contained in:
orklah 2021-10-25 18:29:09 +02:00
parent e33492398b
commit dcd3601645

View File

@ -2,6 +2,7 @@
namespace Psalm\Internal\Type;
use Iterator;
use Psalm\Codebase;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\Type\Comparator\CallableTypeComparator;
@ -12,6 +13,7 @@ use Psalm\Type\Union;
use function array_merge;
use function array_values;
use function count;
use function in_array;
use function is_a;
use function reset;
use function strpos;
@ -469,6 +471,13 @@ class TemplateStandinTypeReplacer
$matching_atomic_types[$atomic_input_type->getId()] = $atomic_input_type;
continue;
}
if (in_array('Traversable', $classlike_storage->class_implements)
&& $base_type->value === 'Iterator'
) {
$matching_atomic_types[$atomic_input_type->getId()] = $atomic_input_type;
continue;
}
} catch (\InvalidArgumentException $e) {
// do nothing
}
@ -487,12 +496,6 @@ class TemplateStandinTypeReplacer
);
continue;
}
/** @var class-string $key may not always be true but class_exists on built in classes(Iterator) is wrong */
if (is_a($input_key, $key, true)) {
$matching_atomic_types[$atomic_input_type->getId()] = $atomic_input_type;
continue;
}
}
return array_values($matching_atomic_types);