-
-
Notifications
You must be signed in to change notification settings - Fork 947
Expression on left side of ?? is only nullable, but non-nullable properties do not cause an error #6063
Description
Bug report
When the return value of a method is non-nullable, using the null coalescing operator causes an error.
But, When a property is non-nullable, using the null coalescing operator doesn't cause an error.
Isn't it right to make an error?
Code snippet that reproduces the problem
Expected output
expect errors like this.
+--------------------------------------------------------------------------------------------------+
| Line | User.php |
+--------------------------------------------------------------------------------------------------+
| 14 | Expression on left side of ?? is not nullable. |
+--------------------------------------------------------------------------------------------------+
Did PHPStan help you today? Did it make you happy in any way?
Thanks to PHPStan, PHP is now a null-safe language! That's wonderful!!
It supports the latest PHP versions so quickly, and I was very impressed when the null safe operator gave an error when called on a non-nullable type.
I reported this because I wanted the null coalesce operator to have the same error when it is used with non-nullable types.
Please consider.