Open
Description
Example
class Test extends \PHPUnit\Framework\TestCase
{
public function testAssertVariable()
{
$foo = null;
$value = new \stdClass();
$mock = $this->getMockBuilder('Foo')->setMethods(['update'])->getMock();
$mock->method('update')->willReturnCallback(function () use (&$foo, $value) {
$foo = $value;
});
$this->assertSame($value, $foo);
}
}
$foo
variable equals $value
after $mock->update()
call but PHPStan throws error Call to assertSame() with different types stdClass and null will always result in test failure.
Activity
ondrejmirtes commentedon Dec 12, 2017
Yes, understanding of the could could be improved on PHPStan's part. Meanwhile, you can annotate the variable:
ossinkine commentedon Dec 12, 2017
Yes, I already use
@var
annotation as workaround, thanks