mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #2476 - flesh out iterable params
This commit is contained in:
parent
9d8ca08fb9
commit
734ad02203
@ -1330,7 +1330,10 @@ class ExpressionAnalyzer
|
||||
return $return_type;
|
||||
}
|
||||
|
||||
if ($return_type instanceof Type\Atomic\TArray || $return_type instanceof Type\Atomic\TGenericObject) {
|
||||
if ($return_type instanceof Type\Atomic\TArray
|
||||
|| $return_type instanceof Type\Atomic\TGenericObject
|
||||
|| $return_type instanceof Type\Atomic\TIterable
|
||||
) {
|
||||
foreach ($return_type->type_params as &$type_param) {
|
||||
$type_param = self::fleshOutType(
|
||||
$codebase,
|
||||
|
@ -661,6 +661,28 @@ class ReturnTypeTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'allowIterableReturnTypeCrossover' => [
|
||||
'<?php
|
||||
class Foo {
|
||||
public const TYPE1 = "a";
|
||||
public const TYPE2 = "b";
|
||||
|
||||
public const AVAILABLE_TYPES = [
|
||||
self::TYPE1,
|
||||
self::TYPE2,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return iterable<array-key, array{foo: value-of<self::AVAILABLE_TYPES>}>
|
||||
*/
|
||||
public function foo() {
|
||||
return [
|
||||
["foo" => self::TYPE1],
|
||||
["foo" => self::TYPE2]
|
||||
];
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user