Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFalse positive when using assertNull and assertSame on same method #25
Comments
|
It started to happen with 0.10.2 (was fine in 0.10.1). My workaround is to call |
|
We're facing the same issue here: class Foo {
public static function bar() : object {
return new \stdClass();
}
}
self::assertSame(Foo::bar(), Foo::bar());
|
|
Still happening in 0.11 |
|
Same here. The root issue here seems to stem from the fact that it's deviating from the standard PHPStan behavior, that doesn't lock the return type on a method, only on variables. |
|
I have the same error on PHPStan 0.10.8 and |
|
This will be solved in 0.12. |
|
I can confirm, it's resolved |
|
It's not perfect right now, the example with |
Summary of a problem or a feature request
When asserting a method result to be null, then changing the internal state of the object, and then asserting the method result to be the same as some object, PHPStan currently fails thinking it will still be null, letting assertSame() always fail.
Code snippet that reproduces the problem
Used configuration
Actual output
Expected output
PHPUnit test does run successfully, and so should PHPStan, as all asserts are valid.