Call to function count() with argument type mixed[]|mixed[][]|string will always result in number 1.
https://phpstan.org/r/3334ad999449bb29b040df8d583d3b1f
/** @var mixed[]|mixed[][]|string */
$var = [];
count($var);
Actually, not always, but may sometimes.
I get that the always word is meant in other meaning, e.g. string, but there may be a better message such as: Call to function count() with argument type mixed[]|mixed[][]|string, where string type will always result in number 1., etc.
Same issue here, minimal failing test:
<?php
declare(strict_types=1);
class Foo
{
/** @var int[]|null */
private $array;
public function __construct()
{
// no expensive operations
}
private function init(): void
{
// expensive operations for lazy init
$this->array = [1, 2, 3];
}
private function doCalculations(): void
{
// identified as error
if (count($this->array) > 0) {
// do some stuff
}
// no error
if (is_array($this->array) && count($this->array) > 0) {
// do some stuff
}
}
}
Causes:

Closing this since there's no longer a problem on dev-master:
https://phpstan.org/r/92d13b0f2fd544371f2eed4075949634 (no problem reported until level 6)
Most helpful comment
Closing this since there's no longer a problem on dev-master:
https://phpstan.org/r/92d13b0f2fd544371f2eed4075949634 (no problem reported until level 6)