diff --git a/hphp/compiler/parser/hphp.tab.cpp b/hphp/compiler/parser/hphp.tab.cpp index cf151b88d..c38299e02 100644 --- a/hphp/compiler/parser/hphp.tab.cpp +++ b/hphp/compiler/parser/hphp.tab.cpp @@ -10376,7 +10376,7 @@ yyreduce: _p->onTypeList((yyvsp[(2) - (5)]), (yyvsp[(4) - (5)])); Token t; t.reset(); t.setText("array"); _p->onTypeAnnotation((yyval), t, (yyvsp[(2) - (5)])); - _p->onTypeSpecialization((yyval), 's'); ;} + _p->onTypeSpecialization((yyval), 't'); ;} break; case 705: diff --git a/hphp/test/slow/reflection_classes/1366.php b/hphp/test/slow/reflection_classes/1366.php new file mode 100644 index 000000000..013ee2c5c --- /dev/null +++ b/hphp/test/slow/reflection_classes/1366.php @@ -0,0 +1,140 @@ +getParameters(); + foreach($rps as $rp) { + var_dump($rp->getTypehintText()); + } + var_dump($rf->getReturnTypehintText()); +} +function printClass($rc) { + $rms = $rc->getMethods(); + $meths = array(); + foreach($rms as $rm) { + $meths[$rm->getName()] = $rm; + } + ksort($meths); + foreach($meths as $meth) { + printFunc($meth); + } + $rps = $rc->getProperties(); + $props = array(); + foreach($rps as $rp) { + $props[$rp->getName()] = $rp; + } + ksort($props); + foreach($props as $prop) { + var_dump($prop->getTypehintText()); + } +} +function f() { +} +$rf = new ReflectionFunction('f'); +printFunc($rf); +function f1(int $t) { +} +$rf = new ReflectionFunction('f1'); +printFunc($rf); +function f2(@string $s) { +} +$rf = new ReflectionFunction('f2'); +printFunc($rf); +function f3(?:xhp:hello $x) { +} +$rf = new ReflectionFunction('f3'); +printFunc($rf); +function f100(): int { +} +$rf = new ReflectionFunction('f100'); +printFunc($rf); +function f101(): string { +} +$rf = new ReflectionFunction('f101'); +printFunc($rf); +function f102(): Vector<:xhp:element> { +} +$rf = new ReflectionFunction('f102'); +printFunc($rf); +function f200((string, Template, ?int, Vector>) $tuple): ?int { +} +$rf = new ReflectionFunction('f200'); +printFunc($rf); +function f201((function (@int, Map>>):Vector) $i): ClassA { +} +$rf = new ReflectionFunction('f201'); +printFunc($rf); +function f202(:xhp:html-element $html): Map> { +} +$rf = new ReflectionFunction('f202'); +printFunc($rf); +function f203((int, Vector) $tupple): array { +} +$rf = new ReflectionFunction('f203'); +printFunc($rf); +function f204((function (int): Vector) $f): array { +} +$rf = new ReflectionFunction('f204'); +printFunc($rf); +function f300(Y $y, ?double $d): X { +} +$rf = new ReflectionFunction('f300'); +printFunc($rf); +function f301((function (): Vector) $f): array { +} +$rf = new ReflectionFunction('f301'); +printFunc($rf); +function f302((Y, X, double, string) $f): ?Y { +} +$rf = new ReflectionFunction('f302'); +printFunc($rf); +class C { + public @int $a; + public ?string $b; + public Vector $v; + public (string, (function(?int, (string, string)):void)) $c; + public function __construct(?int $i, (int, string) $c) { +} + static public function m1() { +} + public function m2(@double $d) : void { +} + static public function m3(Vector>> $v, :xhp:html $x) : @array> { +} + public function m4((function(@int, (string, string)): void) $v) : array> { +} +} +$rc = new ReflectionClass('C'); +printClass($rc); +class CT { + public @int $a; + public ?string $b; + public Vector $v; + public (string, (function(?int, (X, Y)):void)) $c; + public function __construct(?int $i, (int, X) $c) { +} + static public function m1() { +} + public function m2(@Y $d) : void { +} + static public function m3(Vector>> $v, :xhp:html $x) : @array> { +} + public function m4((function(@int, (X, string)): void) $v) : array> { +} +} +$rc = new ReflectionClass('CT'); +printClass($rc); +trait T { + static public function m1() { +} + public function m2(@int $d) : void { +} + static public function m3(Vector>> $v, :xhp:html $x) : @array> { +} + public function m4((function(@int, (double, string)): void) $v) : array, :xhp:html>> { +} +} +class TC { + use T; +} +$rc = new ReflectionClass('TC'); +printClass($rc); + diff --git a/hphp/test/slow/reflection_classes/1366.php.expect b/hphp/test/slow/reflection_classes/1366.php.expect new file mode 100644 index 000000000..60f73dfdc --- /dev/null +++ b/hphp/test/slow/reflection_classes/1366.php.expect @@ -0,0 +1,65 @@ +bool(false) +string(3) "int" +bool(false) +string(7) "@string" +bool(false) +string(11) "?:xhp:hello" +bool(false) +string(3) "int" +string(6) "string" +string(20) "Vector<:xhp:element>" +string(53) "(string, Template, ?int, Vector>)" +string(4) "?int" +string(67) "(function (@int, Map>>): Vector)" +string(6) "ClassA" +string(17) ":xhp:html-element" +string(38) "Map>" +string(21) "(int, Vector)" +string(13) "array" +string(32) "(function (int): Vector)" +string(21) "array" +string(1) "Y" +string(7) "?double" +string(1) "X" +string(24) "(function (): Vector)" +string(16) "array" +string(22) "(Y, X, double, string)" +string(2) "?Y" +string(4) "?int" +string(13) "(int, string)" +bool(false) +bool(false) +string(7) "@double" +string(4) "void" +string(33) "Vector>>" +string(9) ":xhp:html" +string(28) "@array>" +string(41) "(function (@int, (string, string)): void)" +string(29) "array>" +string(4) "@int" +string(7) "?string" +string(51) "(string, (function (?int, (string, string)): void))" +string(9) "Vector" +string(4) "?int" +string(8) "(int, X)" +bool(false) +bool(false) +string(2) "@Y" +string(4) "void" +string(28) "Vector>>" +string(9) ":xhp:html" +string(26) "@array>" +string(36) "(function (@int, (X, string)): void)" +string(24) "array>" +string(4) "@int" +string(7) "?string" +string(41) "(string, (function (?int, (X, Y)): void))" +string(9) "Vector" +bool(false) +string(4) "@int" +string(4) "void" +string(28) "Vector>>" +string(9) ":xhp:html" +string(26) "@array>" +string(41) "(function (@int, (double, string)): void)" +string(38) "array, :xhp:html>>" diff --git a/hphp/util/parser/test/hphp.tab.cpp b/hphp/util/parser/test/hphp.tab.cpp index 92dce225d..b9f980563 100644 --- a/hphp/util/parser/test/hphp.tab.cpp +++ b/hphp/util/parser/test/hphp.tab.cpp @@ -10372,7 +10372,7 @@ yyreduce: _p->onTypeList((yyvsp[(2) - (5)]), (yyvsp[(4) - (5)])); Token t; t.reset(); t.setText("array"); _p->onTypeAnnotation((yyval), t, (yyvsp[(2) - (5)])); - _p->onTypeSpecialization((yyval), 's'); ;} + _p->onTypeSpecialization((yyval), 't'); ;} break; case 705: