mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix addition of int and string type
This commit is contained in:
parent
8b7657f379
commit
443025eab8
@ -668,10 +668,8 @@ class NonDivArithmeticOpAnalyzer
|
||||
|
||||
if ($parent instanceof PhpParser\Node\Expr\BinaryOp\Mod) {
|
||||
$result_type = Type::getInt();
|
||||
} elseif (!$result_type) {
|
||||
$result_type = Type::getFloat();
|
||||
} else {
|
||||
$result_type = Type::combineUnionTypes(Type::getFloat(), $result_type);
|
||||
$result_type = new Type\Union([new Type\Atomic\TInt, new Type\Atomic\TFloat]);
|
||||
}
|
||||
|
||||
$has_valid_right_operand = true;
|
||||
|
@ -296,6 +296,14 @@ class BinaryOperationTest extends TestCase
|
||||
*/
|
||||
function test(int $tickedTimes): void {}'
|
||||
],
|
||||
'numericPlusIntegerIsIntOrFloat' => [
|
||||
'<?php
|
||||
/** @param numeric-string $s */
|
||||
function foo(string $s) : void {
|
||||
$s = $s + 1;
|
||||
if (is_int($s)) {}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user