-
-
Notifications
You must be signed in to change notification settings - Fork 943
Closed
phpstan/phpstan-src
#3901Description
Bug report
In the following code:
<?php declare(strict_types = 1);
class HelloWorld
{
public function sayHello(DateTimeImutable $date): void
{
foreach ($tables as $table) {
// If view exists, and 'add drop view' is selected: Drop it!
if ($_POST['what'] !== 'nocopy' && isset($_POST['drop_if_exists']) && $_POST['drop_if_exists'] === 'true') {
}
}
}
}
The check in the loop will be valid on every iteration. There is nothing to exclude the value from the possible set of values. And PHPStan reports that this will always be true.
Strict comparison using !== between mixed~'nocopy' and 'nocopy' will always evaluate to true.
Code snippet that reproduces the problem
https://phpstan.org/r/30b1edff-a8ea-4ea2-aadd-6536edd0b0e2
Expected output
There should be no warning about the always true strict comparison.
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels