mirror of
https://github.com/danog/psalm.git
synced 2024-11-29 20:28:59 +01:00
Fix #4945 - use assertion string for scalar templated assertions
This commit is contained in:
parent
31be6212b7
commit
4c5c32bc93
@ -721,7 +721,7 @@ class CallAnalyzer
|
||||
} elseif ($replacement_atomic_type instanceof Type\Atomic\TNamedObject) {
|
||||
$ored_type_assertions[] = $prefix . $replacement_atomic_type->value;
|
||||
} 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) {
|
||||
$ored_type_assertions[] = $prefix . 'null';
|
||||
} elseif ($replacement_atomic_type instanceof Type\Atomic\TTemplateParam) {
|
||||
|
@ -715,6 +715,23 @@ class FunctionTemplateAssertTest extends TestCase
|
||||
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