<?php
/**
* @param mixed $width
* @param mixed $height
*
* @throws RuntimeException
*/
function Foo($width, $height) : void {
if ( ! (is_int($width) || is_float($width)) || ! (is_int($height) || is_float($height))) {
throw new RuntimeException('Width & Height were not numeric!');
}
echo sprintf('padding-top:%s%%;', 100 * ($height/$width));
}
Psalm output (using commit 34ebf5c):
INFO: MixedOperand - 14:44 - Left operand cannot be mixed
INFO: MixedArgument - 14:37 - Argument 2 of sprintf cannot be mixed, expecting string|int|float
The exception is thrown only if width or height are not either an int or a float, therefore in any subsequent code the types should be int|float
p.s. this issue also occurs with is_numeric.
is_numeric issue fixed in cadee4d
This works: https://psalm.dev/r/0d11d03290
Improved handling slightly in 8751bf2 to work around a problem this fix introduced