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

Fix #3163 - map object-like arrays too

This commit is contained in:
Brown 2020-04-19 18:46:24 -04:00
parent 286c396498
commit 6fc18af42e
2 changed files with 53 additions and 0 deletions

View File

@ -522,6 +522,17 @@ class Methods
);
}
if ($atomic_type instanceof Type\Atomic\ObjectLike) {
foreach ($atomic_type->properties as &$property_type) {
$property_type = self::localizeType(
$codebase,
$property_type,
$appearing_fq_class_name,
$base_fq_class_name
);
}
}
if ($atomic_type instanceof Type\Atomic\TCallable
|| $atomic_type instanceof Type\Atomic\TFn
) {
@ -549,6 +560,8 @@ class Methods
}
}
$type->bustCache();
return $type;
}

View File

@ -3907,6 +3907,46 @@ class ClassTemplateExtendsTest extends TestCase
[],
'7.4'
],
'inheritTraitPropertyObjectLike' => [
'<?php
/** @template TValue */
trait A {
/** @psalm-var array{TValue} */
private $foo;
/** @psalm-param array{TValue} $foo */
public function __construct(array $foo)
{
$this->foo = $foo;
}
}
/** @template TValue */
class B {
/** @use A<TValue> */
use A;
}'
],
'inheritTraitPropertyArray' => [
'<?php
/** @template TValue */
trait A {
/** @psalm-var array<TValue> */
private $foo;
/** @psalm-param array<TValue> $foo */
public function __construct(array $foo)
{
$this->foo = $foo;
}
}
/** @template TValue */
class B {
/** @use A<TValue> */
use A;
}'
],
];
}