Skip to content

Commit

Permalink
t7651104 - Stop returning values by reference from magical XHP method…
Browse files Browse the repository at this point in the history
…s (fix in fbcode/hphp)

Summary:
This is part of fix on fbcode side (hphp parser) to remove return by reference from 3 XHP methods:
__xhpAttributeDeclaration
__xhpChildrenDeclaration
__xhpCategoryDeclaration

WWW change to xhp.php is in another diff D2826347

Reviewed By: markw65

Differential Revision: D2826329

fb-gh-sync-id: 3b661ccec10ae9358cddc0f02ff4a4707c6253bf
  • Loading branch information
Ning Sun authored and hhvm-bot committed Jan 21, 2016
1 parent c173a0f commit 1f707a8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions hphp/parser/hphp.5.tab.cpp
Expand Up @@ -466,7 +466,7 @@ static void xhp_attribute_stmt(Parser *_p, Token &out, Token &attributes) {
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
Token params, ret, ref; ref = 0;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
Expand Down Expand Up @@ -516,7 +516,7 @@ static void xhp_category_stmt(Parser *_p, Token &out, Token &categories) {
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
Token params, ret, ref; ref = 0;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
Expand Down Expand Up @@ -604,7 +604,7 @@ static void xhp_children_stmt(Parser *_p, Token &out, Token &children) {
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
Token params, ret, ref; ref = 0;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions hphp/parser/hphp.7.tab.cpp
Expand Up @@ -466,7 +466,7 @@ static void xhp_attribute_stmt(Parser *_p, Token &out, Token &attributes) {
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
Token params, ret, ref; ref = 0;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
Expand Down Expand Up @@ -516,7 +516,7 @@ static void xhp_category_stmt(Parser *_p, Token &out, Token &categories) {
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
Token params, ret, ref; ref = 0;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
Expand Down Expand Up @@ -604,7 +604,7 @@ static void xhp_children_stmt(Parser *_p, Token &out, Token &children) {
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
Token params, ret, ref; ref = 0;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions hphp/parser/hphp.y
Expand Up @@ -386,7 +386,7 @@ static void xhp_attribute_stmt(Parser *_p, Token &out, Token &attributes) {
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
Token params, ret, ref; ref = 0;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
Expand Down Expand Up @@ -436,7 +436,7 @@ static void xhp_category_stmt(Parser *_p, Token &out, Token &categories) {
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
Token params, ret, ref; ref = 0;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
Expand Down Expand Up @@ -524,7 +524,7 @@ static void xhp_children_stmt(Parser *_p, Token &out, Token &children) {
stmt = 1;
}
{
Token params, ret, ref; ref = 1;
Token params, ret, ref; ref = 0;
_p->onMethod(out, modifiers, ret, ref, fname, params, stmt, nullptr, false);
}
}
Expand Down
28 changes: 14 additions & 14 deletions hphp/test/ext/test_parser_expr.cpp
Expand Up @@ -469,7 +469,7 @@ bool TestParserExpr::TestXHP() {
V("<?hh class :thing { attribute Thing a, Thing b; }",

"class xhp_thing {\n"
"protected static function &__xhpAttributeDeclaration() {\n"
"protected static function __xhpAttributeDeclaration() {\n"
"static $_ = -1;\n"
"if ($_ === -1) {\n"
"$_ = array_merge(parent::__xhpAttributeDeclaration(), "
Expand All @@ -484,7 +484,7 @@ bool TestParserExpr::TestXHP() {
V("<?hh class :thing { attribute enum { 123, 456 } a; }",

"class xhp_thing {\n"
"protected static function &__xhpAttributeDeclaration() {\n"
"protected static function __xhpAttributeDeclaration() {\n"
"static $_ = -1;\n"
"if ($_ === -1) {\n"
"$_ = array_merge(parent::__xhpAttributeDeclaration(), "
Expand All @@ -499,7 +499,7 @@ bool TestParserExpr::TestXHP() {
" class :bar { attribute :foo, :foo, string bar; }",

"class xhp_foo {\n"
"protected static function &__xhpAttributeDeclaration() {\n"
"protected static function __xhpAttributeDeclaration() {\n"
"static $_ = -1;\n"
"if ($_ === -1) {\n"
"$_ = array_merge(parent::__xhpAttributeDeclaration(), "
Expand All @@ -509,7 +509,7 @@ bool TestParserExpr::TestXHP() {
"}\n"
"}\n"
"class xhp_bar {\n"
"protected static function &__xhpAttributeDeclaration() {\n"
"protected static function __xhpAttributeDeclaration() {\n"
"static $_ = -1;\n"
"if ($_ === -1) {\n"
"$_ = array_merge(parent::__xhpAttributeDeclaration(), "
Expand All @@ -525,7 +525,7 @@ bool TestParserExpr::TestXHP() {
V("<?hh class :thing { attribute int a = 123 @required, var b; }",

"class xhp_thing {\n"
"protected static function &__xhpAttributeDeclaration() {\n"
"protected static function __xhpAttributeDeclaration() {\n"
"static $_ = -1;\n"
"if ($_ === -1) {\n"
"$_ = array_merge(parent::__xhpAttributeDeclaration(), "
Expand All @@ -539,7 +539,7 @@ bool TestParserExpr::TestXHP() {
V("<?hh class :thing { category %a:foo, %b; }",

"class xhp_thing {\n"
"protected function &__xhpCategoryDeclaration() {\n"
"protected function __xhpCategoryDeclaration() {\n"
"static $_ = array('a:foo' => 1, 'b' => 1);\n"
"return $_;\n"
"}\n"
Expand All @@ -549,7 +549,7 @@ bool TestParserExpr::TestXHP() {
V("<?hh class :thing { children(any,any); }",

"class xhp_thing {\n"
"protected function &__xhpChildrenDeclaration() {\n"
"protected function __xhpChildrenDeclaration() {\n"
"static $_ = array(0, 5, array(4, array(0, 1, null), "
"array(0, 1, null)));\n"
"return $_;\n"
Expand All @@ -559,7 +559,7 @@ bool TestParserExpr::TestXHP() {
V("<?hh class :thing { children any; }",

"class xhp_thing {\n"
"protected function &__xhpChildrenDeclaration() {\n"
"protected function __xhpChildrenDeclaration() {\n"
"static $_ = 1;\n"
"return $_;\n"
"}\n"
Expand All @@ -568,7 +568,7 @@ bool TestParserExpr::TestXHP() {
V("<?hh class :thing { children ((:a:foo | %b:bar)+, pcdata); }",

"class xhp_thing {\n"
"protected function &__xhpChildrenDeclaration() {\n"
"protected function __xhpChildrenDeclaration() {\n"
"static $_ = array(0, 5, array(4, array(3, 5, "
"array(5, array(0, 3, 'xhp_a__foo'), array(0, 4, 'b__bar'))), "
"array(0, 2, null)));\n"
Expand All @@ -582,11 +582,11 @@ bool TestParserExpr::TestXHP() {
" children any; }",

"class xhp_thing {\n"
"protected function &__xhpCategoryDeclaration() {\n"
"protected function __xhpCategoryDeclaration() {\n"
"static $_ = array('a:foo' => 1, 'b' => 1);\n"
"return $_;\n"
"}\n"
"protected function &__xhpChildrenDeclaration() {\n"
"protected function __xhpChildrenDeclaration() {\n"
"static $_ = 1;\n"
"return $_;\n"
"}\n"
Expand All @@ -602,19 +602,19 @@ bool TestParserExpr::TestXHP() {
"}",

"class xhp_thing {\n"
"protected function &__xhpCategoryDeclaration() {\n"
"protected function __xhpCategoryDeclaration() {\n"
"static $_ = array('a' => 1);\n"
"return $_;\n"
"}\n"
"protected function &__xhpChildrenDeclaration() {\n"
"protected function __xhpChildrenDeclaration() {\n"
"static $_ = 1;\n"
"return $_;\n"
"}\n"
"public function foo() {\n"
"}\n"
"public function bar() {\n"
"}\n"
"protected static function &__xhpAttributeDeclaration() {\n"
"protected static function __xhpAttributeDeclaration() {\n"
"static $_ = -1;\n"
"if ($_ === -1) {\n"
"$_ = array_merge(parent::__xhpAttributeDeclaration(), "
Expand Down

0 comments on commit 1f707a8

Please sign in to comment.