New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty if clause changes type of variable from T|null to T|array|null #4117
Comments
I'm not surprised this happens, the relationship between NonEmptyArrayType and TemplateMixedType will have to be fixed I guess. |
@AJenbo After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-30: Method GenericList::broken() should return T|null but returns array|T|null.
+30: Method GenericList::broken() should return T|null but returns array|(float&T)|(int&T)|(string&T)|(string&T)|T|(T&bool)|null. Full report
|
Different, but not correct 🙂 |
@AJenbo After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-30: Method GenericList::broken() should return T|null but returns array|T|null.
+PHP 7.4 – 8.0 (1 error)
+==========
+
+30: Method GenericList::broken() should return T|null but returns array|(float&T)|(int&T)|(string&T)|(string&T)|T|(T&bool)|null.
+
+PHP 7.1 – 7.3 (2 errors)
+==========
+
+16: Return type ArrayIterator of method GenericList::getIterator() is not compatible with return type Traversable of method IteratorAggregate::getIterator().
+30: Method GenericList::broken() should return T|null but returns array|(float&T)|(int&T)|(string&T)|(string&T)|T|(T&bool)|null. Full reportPHP 7.4 – 8.0 (1 error)
PHP 7.1 – 7.3 (2 errors)
|
@AJenbo After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-30: Method GenericList::broken() should return T|null but returns array|T|null.
+30: Method GenericList::broken() should return T|null but returns array|(float&T)|(int&T)|(''&T)|('0'&T)|T|(T&bool)|null. Full report
|
@AJenbo After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-30: Method GenericList::broken() should return T|null but returns array|T|null.
+30: Method GenericList::broken() should return T|null but returns array|(float&T)|(int&T)|(string&T)|(string&T)|T of mixed|(T&bool)|null. Full report
|
@AJenbo After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-30: Method GenericList::broken() should return T|null but returns array|T|null.
+30: Method GenericList::broken() should return T but returns array|(float&T)|(int&T)|(string&T)|(string&T)|T of mixed|(T&bool)|null.
+40: Method GenericList::works() should return T but returns T|null. Full report
|
@AJenbo After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-30: Method GenericList::broken() should return T|null but returns array|T|null.
+30: Method GenericList::broken() should return T but returns array|T of mixed|null.
+40: Method GenericList::works() should return T but returns T|null. Full report
|
@AJenbo After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-30: Method GenericList::broken() should return T|null but returns array|T|null.
+30: Method GenericList::broken() should return T|null but returns array|T of mixed|null. Full report
|
@AJenbo After the latest commit in 1.7.x, PHPStan now reports different result with your code snippet: @@ @@
-30: Method GenericList::broken() should return T|null but returns array|T|null.
+30: Method GenericList::broken() should return (T)|null but returns array|(T of mixed)|null. Full report
|
@AJenbo After the latest commit in 1.7.x, PHPStan now reports different result with your code snippet: @@ @@
-30: Method GenericList::broken() should return T|null but returns array|T|null.
+30: Method GenericList::broken() should return T|null but returns array|(T of mixed)|null. Full report
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Method GenericList::broken() should return T|null but returns array|T|null.
Code snippet that reproduces the problem
https://phpstan.org/r/54561da3-8e55-438b-91b1-cf4c73eed57f
Expected output
No errors
The text was updated successfully, but these errors were encountered: