mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Allow parameter types to be contained by a class template type (#8731)
* Allow parameter types to be contained by a class template type in function calls * Specify PHP version of tests * Fix tests
This commit is contained in:
parent
f846906b29
commit
54db59682d
@ -1096,10 +1096,6 @@ class CallAnalyzer
|
||||
$statements_analyzer->getCodebase(),
|
||||
$lower_bound->type,
|
||||
$bound_with_equality->type
|
||||
) && UnionTypeComparator::isContainedBy(
|
||||
$statements_analyzer->getCodebase(),
|
||||
$bound_with_equality->type,
|
||||
$lower_bound->type
|
||||
)) {
|
||||
continue 2;
|
||||
}
|
||||
|
@ -1621,6 +1621,47 @@ class FunctionTemplateTest extends TestCase
|
||||
return $p - 1;
|
||||
}'
|
||||
],
|
||||
'literalIsAlwaysContainedInString' => [
|
||||
'code' => '<?php
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
interface Norm
|
||||
{
|
||||
/**
|
||||
* @param T $input
|
||||
* @return T
|
||||
*/
|
||||
public function normalize(mixed $input): mixed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @implements Norm<string>
|
||||
*/
|
||||
class StringNorm implements Norm
|
||||
{
|
||||
public function normalize(mixed $input): mixed
|
||||
{
|
||||
return strtolower($input);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template TNorm
|
||||
*
|
||||
* @param TNorm $value
|
||||
* @param Norm<TNorm> $n
|
||||
*/
|
||||
function normalizeField(mixed $value, Norm $n): void
|
||||
{
|
||||
$n->normalize($value);
|
||||
}
|
||||
|
||||
normalizeField("foo", new StringNorm());',
|
||||
'assertions' => [],
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.0'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user