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:
parent
286c396498
commit
6fc18af42e
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user