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
while analyzing a script, it would be nice to be able to inspect the type of a variable if it's not a parameter.
e.g:
$pattern = re"/(?P<language>PHP)/";
$pattern in this case is shape(0 => string, 'langauge' => string), however, the only way to know this statically, is by using an editor with hack plugin, which would ask hh_client for the information.
request
This issue requests a new hh_client "annotation" HH_TYPE/HH_TRACE which will result in an error that contains type information about given variable ( e.g: https://cloud.void.tn/c/36?version=4.114.0 )
There's hh_client --type-at-pos too, but yes, this is useful.
We have something very similar already in hh_single_type_check (used for our unit tests): a fake function called hh_show() that pretty much acts exactly as you're describing.
Perhaps this should be made available in real hh_client/hh_server runs too as HH\show_type_and_raise_error($x) or something like that.
here, the actual type is Regex\Pattern<shape(0 => string, 'language' => string)>, but the type to use in user-land is Regex\Pattern<shape('language' => string, ...)>
so we should have 2 variant of HH\show_type($pattern).
to show the actual type ( internal, not possible in userland, could be a union, intersection, contains wildcard _, ... etc )
to show the use-able type hint ( how can i type hint this in my code? )
2 should be identical to 1, unless 1 is not denotable at all.
If we did do a separate (2) it'd be something like HH\show_unsafe_more_permissive_denotable_type_and_error(), though I don't know if we reliably track the information required to implement that.
while analyzing a script, it would be nice to be able to inspect the type of a variable if it's not a parameter.
e.g:
$pattern
in this case isshape(0 => string, 'langauge' => string)
, however, the only way to know this statically, is by using an editor with hack plugin, which would ask hh_client for the information.request
This issue requests a new hh_client "annotation"
HH_TYPE
/HH_TRACE
which will result in an error that contains type information about given variable ( e.g: https://cloud.void.tn/c/36?version=4.114.0 )This feature is inspired by psalm trace feature: https://psalm.dev/r/1602ca9415
The text was updated successfully, but these errors were encountered: