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
We have been using Psalm for a while now, and already improved our codebase quite a bit!
However, we ran into a problem while adding Psalm to yet another project: the Psalm runner actually crashes. I managed to find out where the error occurs, and it is really quite specific.
The error occurs whenever a switch on the value of gettype has at least two case statements, namely resource (closed) and unknown type. The case statements should be in that order for the error to show, and the resource (closed)-case and all the other cases between case resource (closed): and case unknown type: should not have a statement which exits the switch-statement (i.e., a break, throw, return or even continue).
So the following fails:
<?php
$data = "foo";
switch (gettype($data)) {
case "resource (closed)":
case "unknown type":
return "foo";
}
<?php
$data = "foo";
switch (gettype($data)) {
case "unknown type":
case "resource (closed)":
return "foo";
}
In our codebase we can easily change the order of the case-statements and thereby evade this error. I don't know whether this issue maybe signifies a larger bug, so I would like to report this issue nonetheless.
Keep up the good work :)
The text was updated successfully, but these errors were encountered:
Hi!
We have been using Psalm for a while now, and already improved our codebase quite a bit!
However, we ran into a problem while adding Psalm to yet another project: the Psalm runner actually crashes. I managed to find out where the error occurs, and it is really quite specific.
A minimal example can be found here: https://psalm.dev/r/648ae887e8
The error occurs whenever a
switch
on the value ofgettype
has at least two case statements, namelyresource (closed)
andunknown type
. Thecase
statements should be in that order for the error to show, and theresource (closed)
-case and all the other cases betweencase resource (closed):
andcase unknown type:
should not have a statement which exits theswitch
-statement (i.e., abreak
,throw
,return
or evencontinue
).So the following fails:
but this does not (https://psalm.dev/r/c95469669e):
In our codebase we can easily change the order of the case-statements and thereby evade this error. I don't know whether this issue maybe signifies a larger bug, so I would like to report this issue nonetheless.
Keep up the good work :)
The text was updated successfully, but these errors were encountered: