mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
String can be reconciled with Scalar (#5402)
This commit is contained in:
parent
1149050817
commit
2777b62d0b
@ -807,7 +807,7 @@ class SimpleAssertionReconciler extends \Psalm\Type\Reconciler
|
||||
$string_types[] = new TString;
|
||||
$did_remove_type = true;
|
||||
} elseif ($type instanceof TTemplateParam) {
|
||||
if ($type->as->hasString() || $type->as->hasMixed()) {
|
||||
if ($type->as->hasString() || $type->as->hasMixed() || $type->as->hasScalar()) {
|
||||
$type = clone $type;
|
||||
|
||||
$type->as = self::reconcileString(
|
||||
|
@ -805,6 +805,17 @@ class RedundantConditionTest extends \Psalm\Tests\TestCase
|
||||
if ($filter) {}
|
||||
}'
|
||||
],
|
||||
'stringInScalar' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template T of scalar
|
||||
* @param T $value
|
||||
*/
|
||||
function normalizeValue(bool|int|float|string $value): void
|
||||
{
|
||||
assert(is_string($value));
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user