You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This reports "(string) gimmeSomething() would express the intent better".
I've put a lot of thought in this last year, and I think an explicit ->__toString() call is preferable. Specifically, if gimmeSomething() changes to nullable:
functiongimmeSomething() : ?Something
{
// ...
}
Then the expression (string) echo gimmeSomething() keeps working (bug), while echo gimmeSomething()->__toString(); crashes (null pointer exception, expected).
Consider following code snippet:
This reports
"(string) gimmeSomething() would express the intent better"
.I've put a lot of thought in this last year, and I think an explicit
->__toString()
call is preferable. Specifically, ifgimmeSomething()
changes to nullable:Then the expression
(string) echo gimmeSomething()
keeps working (bug), whileecho gimmeSomething()->__toString();
crashes (null pointer exception, expected).I've documented this in more detail at ShittySoft/symfony-live-berlin-2018-doctrine-tutorial#3 (comment), but using a
(string)
cast is most probably not to be endorsed.I'm not sure if this is related to the discussion above (or if it is a core IDE bug), but the following doesn't seem to report a NPE either:
The text was updated successfully, but these errors were encountered: