diff --git a/hphp/runtime/ext/ext_reflection.cpp b/hphp/runtime/ext/ext_reflection.cpp index 0631c6c7c..3a167932c 100644 --- a/hphp/runtime/ext/ext_reflection.cpp +++ b/hphp/runtime/ext/ext_reflection.cpp @@ -83,6 +83,7 @@ static StaticString s___invoke("__invoke"); static StaticString s_closure_in_braces("{closure}"); static StaticString s_closureobj("closureobj"); static StaticString s_return_type("return_type"); +static StaticString s_type_hint("type_hint"); static const VM::Class* get_cls(CVarRef class_or_object) { VM::Class* cls = NULL; @@ -348,9 +349,12 @@ static void set_function_info(Array &ret, const VM::Func* func) { param.set(s_index, VarNR((int)i)); VarNR name(func->localNames()[i]); param.set(s_name, name); - const StringData* type = fpi.userType() ? - fpi.userType() : empty_string.get(); + const StringData* type = fpi.typeConstraint().exists() ? + fpi.typeConstraint().typeName() : empty_string.get(); param.set(s_type, VarNR(type)); + const StringData* typeHint = fpi.userType() ? + fpi.userType() : empty_string.get(); + param.set(s_type_hint, VarNR(typeHint)); param.set(s_function, VarNR(func->name())); if (func->preClass()) { param.set(s_class, VarNR(func->cls() ? func->cls()->name() : diff --git a/hphp/system/classes/reflection.php b/hphp/system/classes/reflection.php index 9c1566b39..dc7126574 100644 --- a/hphp/system/classes/reflection.php +++ b/hphp/system/classes/reflection.php @@ -162,8 +162,8 @@ class ReflectionParameter implements Reflector { } public function getTypehintText() { - if (isset($this->info['type'])) { - return $this->info['type']; + if (isset($this->info['type_hint'])) { + return $this->info['type_hint']; } return ''; } diff --git a/hphp/test/quick/reflection.php.expectf b/hphp/test/quick/reflection.php.expectf index db4b2f139..bf30386ab 100644 --- a/hphp/test/quick/reflection.php.expectf +++ b/hphp/test/quick/reflection.php.expectf @@ -27,13 +27,15 @@ array(4) { [0]=> object(ReflectionParameter)#5 (1) { ["info"]=> - array(6) { + array(7) { ["index"]=> int(0) ["name"]=> string(1) "a" ["type"]=> string(0) "" + ["type_hint"]=> + string(0) "" ["function"]=> string(1) "f" ["nullable"]=> @@ -46,13 +48,15 @@ array(4) { [1]=> object(ReflectionParameter)#6 (1) { ["info"]=> - array(7) { + array(8) { ["index"]=> int(1) ["name"]=> string(1) "b" ["type"]=> string(0) "" + ["type_hint"]=> + string(0) "" ["function"]=> string(1) "f" ["nullable"]=> @@ -67,13 +71,15 @@ array(4) { [2]=> object(ReflectionParameter)#7 (1) { ["info"]=> - array(8) { + array(9) { ["index"]=> int(2) ["name"]=> string(1) "c" ["type"]=> string(0) "" + ["type_hint"]=> + string(0) "" ["function"]=> string(1) "f" ["nullable"]=> @@ -90,13 +96,15 @@ array(4) { [3]=> object(ReflectionParameter)#8 (1) { ["info"]=> - array(8) { + array(9) { ["index"]=> int(3) ["name"]=> string(1) "d" ["type"]=> string(0) "" + ["type_hint"]=> + string(0) "" ["function"]=> string(1) "f" ["nullable"]=> diff --git a/hphp/test/quick/reflection2.php.expectf b/hphp/test/quick/reflection2.php.expectf index 5112788ea..1582ef813 100644 --- a/hphp/test/quick/reflection2.php.expectf +++ b/hphp/test/quick/reflection2.php.expectf @@ -248,13 +248,15 @@ array(6) { } object(ReflectionParameter)#9 (1) { ["info"]=> - array(6) { + array(7) { ["index"]=> int(0) ["name"]=> string(1) "c" ["type"]=> string(7) "MyClass" + ["type_hint"]=> + string(7) "MyClass" ["function"]=> string(1) "f" ["class"]=> diff --git a/hphp/test/slow/reflection_classes/1366.php b/hphp/test/slow/reflection_classes/1366.php index 013ee2c5c..afaac9d1b 100644 --- a/hphp/test/slow/reflection_classes/1366.php +++ b/hphp/test/slow/reflection_classes/1366.php @@ -137,4 +137,14 @@ class TC { } $rc = new ReflectionClass('TC'); printClass($rc); - +function ff(Vector $i, ?string $s, @C $c, array $a) {} +$rf = new ReflectionFunction('ff'); +$rps = $rf->getParameters(); +foreach ($rps as $rp) { + var_dump($rp->getTypehintText()); + if ($rp->getClass() != null) { + var_dump($rp->getClass()->getName()); + } else { + var_dump(""); + } +} diff --git a/hphp/test/slow/reflection_classes/1366.php.expect b/hphp/test/slow/reflection_classes/1366.php.expect index 60f73dfdc..9fae70bb2 100644 --- a/hphp/test/slow/reflection_classes/1366.php.expect +++ b/hphp/test/slow/reflection_classes/1366.php.expect @@ -63,3 +63,11 @@ string(9) ":xhp:html" string(26) "@array>" string(41) "(function (@int, (double, string)): void)" string(38) "array, :xhp:html>>" +string(11) "Vector" +string(6) "Vector" +string(7) "?string" +string(0) "" +string(2) "@C" +string(0) "" +string(5) "array" +string(0) ""