mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
Fix #4945 - use assertion string for scalar templated assertions
This commit is contained in:
parent
0e17a3354f
commit
603ecadbb7
@ -721,7 +721,7 @@ class CallAnalyzer
|
|||||||
} elseif ($replacement_atomic_type instanceof Type\Atomic\TNamedObject) {
|
} elseif ($replacement_atomic_type instanceof Type\Atomic\TNamedObject) {
|
||||||
$ored_type_assertions[] = $prefix . $replacement_atomic_type->value;
|
$ored_type_assertions[] = $prefix . $replacement_atomic_type->value;
|
||||||
} elseif ($replacement_atomic_type instanceof Type\Atomic\Scalar) {
|
} elseif ($replacement_atomic_type instanceof Type\Atomic\Scalar) {
|
||||||
$ored_type_assertions[] = $prefix . $replacement_atomic_type->getId();
|
$ored_type_assertions[] = $prefix . $replacement_atomic_type->getAssertionString();
|
||||||
} elseif ($replacement_atomic_type instanceof Type\Atomic\TNull) {
|
} elseif ($replacement_atomic_type instanceof Type\Atomic\TNull) {
|
||||||
$ored_type_assertions[] = $prefix . 'null';
|
$ored_type_assertions[] = $prefix . 'null';
|
||||||
} elseif ($replacement_atomic_type instanceof Type\Atomic\TTemplateParam) {
|
} elseif ($replacement_atomic_type instanceof Type\Atomic\TTemplateParam) {
|
||||||
|
@ -715,6 +715,23 @@ class FunctionTemplateAssertTest extends TestCase
|
|||||||
return $value;
|
return $value;
|
||||||
}'
|
}'
|
||||||
],
|
],
|
||||||
|
'noCrashOnListKeyAssertion' => [
|
||||||
|
'<?php
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @param T $t
|
||||||
|
* @param mixed $other
|
||||||
|
* @psalm-assert =T $other
|
||||||
|
*/
|
||||||
|
function assertSame($t, $other) : void {}
|
||||||
|
|
||||||
|
/** @param list<int> $list */
|
||||||
|
function takesList(array $list) : void {
|
||||||
|
foreach ($list as $i => $l) {
|
||||||
|
assertSame($i, $l);
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user