-
Notifications
You must be signed in to change notification settings - Fork 672
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
Introduce top type #1729
Comments
Flow handles this with a I think it's an interesting idea, but I wonder whether it would be useful in that many places. |
Right, Hack does the same thing. But I think for PHP If you don't have something like |
PHPStan's |
The only deliberate difference I'm aware of is that a union of The benefit of that is in finding bugs - |
Yes, I want to tackle this by adding this as a property to |
Closing as not really relevant |
Psalm has a bottom type,
no-return
, and the dynamic typemixed
, but I think it might be useful to also have a top type. Taking a lead from typescript,mixed
is comparable to Typescript'sany
,no-return
is comparable to Typescript'snever
, and we could adopt the nameunknown
for the top type.To illustrate the difference, psalm emits
MixedMethodCall
on the call tobar()
below:MixedMethodCall
is (with default Psalm settings) anINFO
, not anERROR
.However if the return statement was changed to
/** @return unknown */
then instead ofMixedMethodCall
psalm would emit some form of error.The top type should be treated as a supertype of all other types, so that the following code should cause no issues:
unknown
would be roughly equivilent toobject|scalar|mixed|array|null
, except currently psalm seems to treatobject
as a form of mixed, rather than as a supertype of all other object types.The text was updated successfully, but these errors were encountered: