Comparison operation always true on modified array by reference #10825
-
Hi. First of all, sorry, I'm incredibly new to PHPStan and a VERY old school PHP developer (20+ years). I'm in the process of apply static analysis to some old code to bring it up to date. Most issues are being dealt with fine, but I came across this issue in a library I wrote that uses sockets and I'm not sure it's correct(??). Or can someone explain to me why this is considered invalid? <?php declare(strict_types = 1);
class HelloWorld
{
public function sayHello(): void
{
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
if($socket === false) return;
$read = [$socket];
$write = null;
$except = null;
socket_select($read, $write, $except, 0, 1);
if(count($read) > 0){
echo 'ready to read';
}
}
} You can paste this code into the playground on phpstan.org with at least LEVEL4 and it'll give the error:
However, the purpose of Thanks. I'm really just trying to wrap my head around some of the rules here so bare with me. ;) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, this is a bug. I fixed it: phpstan/phpstan-src@24c5249 |
Beta Was this translation helpful? Give feedback.
Hi, this is a bug. I fixed it: phpstan/phpstan-src@24c5249