-
-
Notifications
You must be signed in to change notification settings - Fork 935
Open
phpstan/phpstan-src
#4168Labels
Milestone
Description
Bug report
Strange evaluation of the comparasion operator for levels 6 and lower. Levels 7 and higher returns "No errors found."
/**
* @param string|array<int|string>|null $value
*
* @return string|array<int|string>|null
*/
public function transform($value) {
if ($value !== null && !is_array($value) && $value != -1) {
$transformed = [
'year' => gmdate('Y', (int) $value),
'month' => gmdate('n', (int) $value),
];
} elseif ($value == -1) {
$transformed = [
'year' => -1,
'month' => -1,
];
} else {
$transformed = $value;
}
return $transformed;
}
Level 6 reports:
https://phpstan.org/r/04cc3e0d-5cab-417e-a9ee-41cb96bf39d7
Comparison operation "==" between array<int|string>|string|null and -1 results in an error.
Level 7 for same code reports:
https://phpstan.org/r/d068bb79-a0e4-4fb6-a797-867538af2091
No errors!
Code snippet that reproduces the problem
Error with level 6:
https://phpstan.org/r/04cc3e0d-5cab-417e-a9ee-41cb96bf39d7
Expected output
No errors!
for all levels