mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Merge pull request #9738 from klimick/fix-invalid-cast-for-templated-class-string
Fix invalid cast for templated class-string
This commit is contained in:
commit
f8895edf4d
@ -80,7 +80,7 @@ class ClassLikeStringComparator
|
|||||||
: $input_type_part->value,
|
: $input_type_part->value,
|
||||||
);
|
);
|
||||||
|
|
||||||
return AtomicTypeComparator::isContainedBy(
|
$isContainedBy = AtomicTypeComparator::isContainedBy(
|
||||||
$codebase,
|
$codebase,
|
||||||
$fake_input_object,
|
$fake_input_object,
|
||||||
$fake_container_object,
|
$fake_container_object,
|
||||||
@ -88,5 +88,16 @@ class ClassLikeStringComparator
|
|||||||
false,
|
false,
|
||||||
$atomic_comparison_result,
|
$atomic_comparison_result,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($atomic_comparison_result
|
||||||
|
&& $atomic_comparison_result->replacement_atomic_type instanceof TNamedObject
|
||||||
|
) {
|
||||||
|
$atomic_comparison_result->replacement_atomic_type = new TClassString(
|
||||||
|
'object',
|
||||||
|
$atomic_comparison_result->replacement_atomic_type,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $isContainedBy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,19 @@ class FunctionCallTest extends TestCase
|
|||||||
public function providerValidCodeParse(): iterable
|
public function providerValidCodeParse(): iterable
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'callFunctionWithTemplateClassStringWillNotFail' => [
|
||||||
|
'code' => '<?php
|
||||||
|
/** @param class-string<SplFixedArray<string>> $classString */
|
||||||
|
function acceptTemplatedClassString(string $classString): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param class-string<SplFixedArray<string>> $classString */
|
||||||
|
function app(string $classString): void
|
||||||
|
{
|
||||||
|
acceptTemplatedClassString($classString);
|
||||||
|
}',
|
||||||
|
],
|
||||||
'inferGenericListFromTuple' => [
|
'inferGenericListFromTuple' => [
|
||||||
'code' => '<?php
|
'code' => '<?php
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user