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
I have been using HH\ReifiedGenerics\get_type_structure<T>() recently to feed some type driven codegen. The HH\TypeStructure<T> shape sometimes contains a "opaque" key with the value true.
hphpd> newtype A = int;
newtype A = int;
hphpd> =\HH\ReifiedGenerics\get_type_structure<A>();
=\HH\ReifiedGenerics\get_type_structure<A>();
Dict
(
[kind] => 1
[opaque] => true
[alias] => "A"
)
I would have expected "opaque" to be present here, but it is not. Going via new ReflectionTypeAlias('B') does yield an "opaque" key, but it seems to use a different "kind" under the hood, namely \HH\TypeStructureKind::OF_UNRESOLVED.
hphpd> = (new \ReflectionTypeAlias('B'))->getTypeStructure();
= (new \ReflectionTypeAlias('B'))->getTypeStructure();
Dict
(
[kind] => 101
[classname] => "stdClass"
[opaque] => true
)
I'd love to know the what and how of this, but I didn't know who to ask.
Also, I tried to figure out whether this was a feature or a bug. This test and expect seems to lean towards the feature side of things.
I do know that this is an experimental feature of hhvm that may need to be removed in the future. I am not using this in ways that couldn't be achieved via other means. This is however a lot simpler than the alternatives. I am aware that I might need to go the alternative route later if / when this function gets removed from hhvm.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all,
I have been using
HH\ReifiedGenerics\get_type_structure<T>()
recently to feed some type driven codegen. TheHH\TypeStructure<T>
shape sometimes contains a"opaque"
key with the value true.But sometimes it goes missing.
I would have expected
"opaque"
to be present here, but it is not. Going vianew ReflectionTypeAlias('B')
does yield an"opaque"
key, but it seems to use a different"kind"
under the hood, namely\HH\TypeStructureKind::OF_UNRESOLVED
.I'd love to know the what and how of this, but I didn't know who to ask.
Also, I tried to figure out whether this was a feature or a bug. This test and expect seems to lean towards the feature side of things.
I do know that this is an experimental feature of hhvm that may need to be removed in the future. I am not using this in ways that couldn't be achieved via other means. This is however a lot simpler than the alternatives. I am aware that I might need to go the alternative route later if / when this function gets removed from hhvm.
Beta Was this translation helpful? Give feedback.
All reactions