mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #2849 - allow object-like templated array comparison
This commit is contained in:
parent
a2fbfc1c9e
commit
f44a0f9f4c
@ -874,6 +874,7 @@ class TypeAnalyzer
|
||||
if ($allow_interface_equality
|
||||
|| ($input_type_part instanceof TArray
|
||||
&& !$input_type_part->type_params[1]->isEmpty())
|
||||
|| $input_type_part instanceof ObjectLike
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
@ -467,6 +467,60 @@ class ClassTemplateCovarianceTest extends TestCase
|
||||
public function zip();
|
||||
}',
|
||||
],
|
||||
'extendsArrayWithCovariant' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template-covariant T1
|
||||
*/
|
||||
interface IParentCollection {
|
||||
/**
|
||||
* @return IParentCollection<array<T1>>
|
||||
*/
|
||||
public function getNested(): IParentCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T2
|
||||
*
|
||||
* @extends IParentCollection<T2>
|
||||
*/
|
||||
interface IChildCollection extends IParentCollection {
|
||||
/**
|
||||
* @return IChildCollection<array<T2>>
|
||||
*/
|
||||
public function getNested(): IChildCollection;
|
||||
}',
|
||||
[],
|
||||
[],
|
||||
'7.4',
|
||||
],
|
||||
'extendsObjectLikeWithCovariant' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template-covariant T1
|
||||
*/
|
||||
interface IParentCollection {
|
||||
/**
|
||||
* @return IParentCollection<array{0: T1}>
|
||||
*/
|
||||
public function getNested(): IParentCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T2
|
||||
*
|
||||
* @extends IParentCollection<T2>
|
||||
*/
|
||||
interface IChildCollection extends IParentCollection {
|
||||
/**
|
||||
* @return IChildCollection<array{0: T2}>
|
||||
*/
|
||||
public function getNested(): IChildCollection;
|
||||
}',
|
||||
[],
|
||||
[],
|
||||
'7.4',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user