mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #2827 - detect literal numeric values
This commit is contained in:
parent
4707b21227
commit
9f13341ef9
@ -1404,6 +1404,9 @@ class TypeAnalyzer
|
||||
&& ($container_type_part instanceof TNumericString
|
||||
|| $container_type_part instanceof THtmlEscapedString)
|
||||
) {
|
||||
if ($input_type_part instanceof TLiteralString) {
|
||||
return is_numeric($input_type_part->value);
|
||||
}
|
||||
if ($atomic_comparison_result) {
|
||||
$atomic_comparison_result->type_coerced = true;
|
||||
}
|
||||
|
@ -646,6 +646,20 @@ class ValueTest extends TestCase
|
||||
return false;
|
||||
}'
|
||||
],
|
||||
'numericStringValue' => [
|
||||
'<?php
|
||||
/** @psalm-return numeric-string */
|
||||
function makeNumeric() : string {
|
||||
return "12.34";
|
||||
}
|
||||
|
||||
/** @psalm-param numeric-string $string */
|
||||
function consumeNumeric(string $string) : void {
|
||||
\error_log($string);
|
||||
}
|
||||
|
||||
consumeNumeric("12.34");'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user