Skip to content
Permalink
Browse files

Fix #2476 - flesh out iterable params

  • Loading branch information
muglug committed Dec 18, 2019
1 parent 9d8ca08 commit 734ad0220376d90477754eddbb6652e88854d185
Showing with 26 additions and 1 deletion.
  1. +4 −1 src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php
  2. +22 −0 tests/ReturnTypeTest.php
@@ -1330,7 +1330,10 @@ private static function fleshOutAtomicType(
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 @@ public function foo(): array {
}
}',
],
'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]
];
}
}',
],
];
}

0 comments on commit 734ad02

Please sign in to comment.
You can’t perform that action at this time.