-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Description
Since updating from 0.10.6 to 0.11.1 we get false positives about supposedly empty arrays.
A minimal example to reproduce the problem is this:
<?php
namespace Test;
class Foo
{
public $bar;
public function baz(Foo $foo)
{
$foo->bar = ['a', 'b'];
}
public static function doStuff()
{
$foo = new Foo();
$foo->bar = [];
$foo->baz($foo);
// phpstan 0.11.1 reports on this line that $foo->bar is always empty
foreach ($foo->bar as $value) {
var_dump($value);
}
}
}IMHO the information that $foo->bar is empty should be discarded when we pass $foo to a method because that method might change the value of the object.
The same is when we call a method on the object itself:
<?php
namespace Test;
class Foo
{
public $bar;
public function baz()
{
$this->bar = ['a', 'b'];
}
public function doStuff()
{
$this->bar = [];
$this->baz();
// phpstan 0.11.1 reports on this line that $this->bar is always empty
foreach ($this->bar as $value) {
var_dump($value);
}
}
}Reactions are currently unavailable