1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Fix #4326 - Prevent later remapping of properties

This commit is contained in:
Matt Brown 2020-10-14 21:35:46 -04:00 committed by Daniil Gentili
parent 1915f34959
commit 05f2d01cb6
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 46 additions and 5 deletions

View File

@ -1004,9 +1004,7 @@ class InstancePropertyFetchAnalyzer
$class_storage,
$declaring_class_storage
);
}
if ($lhs_type_part instanceof TGenericObject) {
} elseif ($lhs_type_part instanceof TGenericObject) {
$class_property_type = self::localizePropertyType(
$codebase,
$class_property_type,

View File

@ -3005,7 +3005,7 @@ class ClassTemplateTest extends TestCase
}
}'
],
'flippedParamsInside' => [
'flippedParamsMethodInside' => [
'<?php
/**
* @template A
@ -3026,7 +3026,7 @@ class ClassTemplateTest extends TestCase
}
}'
],
'flippedParamsOutside' => [
'flippedParamsMethodOutside' => [
'<?php
/**
* @template B
@ -3048,6 +3048,49 @@ class ClassTemplateTest extends TestCase
public abstract function getTraversable() : Traversable;
}'
],
'flippedParamsPropertyInside' => [
'<?php
/**
* @template A
* @template B
*/
abstract class Foo
{
/** @var Traversable<A, B> */
public $traversable;
/**
* @param Foo<B, A> $flipped
* @return Traversable<B, A>
*/
public function getFlippedTraversable(Foo $flipped): Traversable
{
return $flipped->traversable;
}
}'
],
'flippedParamsPropertyOutside' => [
'<?php
/**
* @template B
* @template A
* @param Foo<B, A> $flipped
* @return Traversable<B, A>
*/
function getFlippedTraversable(Foo $flipped): Traversable {
return $flipped->traversable;
}
/**
* @template A
* @template B
*/
abstract class Foo
{
/** @var Traversable<A, B> */
public $traversable;
}'
],
];
}