1
0
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:
orklah 2021-03-16 18:46:23 +01:00 committed by GitHub
parent 1149050817
commit 2777b62d0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -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(

View File

@ -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));
}'
],
];
}