allow (clone)->bar() and (<xhp>)->bar()
People have asked for ##(new Foo)->bar()##, ##(clone Foo)->bar## and ##(<xhp>)->toString()##.
Esse commit está contido em:
+614
-614
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
class A {
|
||||
public function b() {
|
||||
return 'c';
|
||||
}
|
||||
}
|
||||
$d = new A;
|
||||
var_dump((clone $d)->b());
|
||||
@@ -0,0 +1 @@
|
||||
string(1) "c"
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
# These are all not parse errors anymore
|
||||
(print 3)[1];
|
||||
|
||||
# And this works now
|
||||
var_dump((array(3))[0]);
|
||||
@@ -0,0 +1,2 @@
|
||||
3HipHop Warning: Cannot use a scalar value as an array in %s on line 4
|
||||
int(3)
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
class :foo {
|
||||
public function bar() { return 'baz'; }
|
||||
}
|
||||
|
||||
var_dump((<foo />)->bar());
|
||||
@@ -0,0 +1 @@
|
||||
string(3) "baz"
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
class D {
|
||||
public $prop = 300;
|
||||
public function prop() { return 350; }
|
||||
public $yo = 500;
|
||||
public function yo() { return 550; }
|
||||
public $blah = 600;
|
||||
public function blah() { return 650; }
|
||||
}
|
||||
class C {
|
||||
public static $x = 100;
|
||||
public static $y = array(200);
|
||||
public static $z = array();
|
||||
public static function foo1() { return 150; }
|
||||
public static function foo2() { return 250; }
|
||||
public $bar1 = 400;
|
||||
public function bar2() { return 450; }
|
||||
public $baz;
|
||||
public $w = array();
|
||||
public function __construct() {
|
||||
$this->baz = new D();
|
||||
$this->w[] = new D();
|
||||
}
|
||||
}
|
||||
C::$z[] = new D();
|
||||
|
||||
var_dump(C::$x);
|
||||
$x = 'foo1';
|
||||
var_dump(C::$x());
|
||||
|
||||
var_dump(C::$y[0]);
|
||||
$y = array('foo2');
|
||||
var_dump(C::$y[0]());
|
||||
|
||||
var_dump(C::$z[0]->prop);
|
||||
var_dump(C::$z[0]->prop());
|
||||
|
||||
$obj = new C;
|
||||
$x = array('bar1');
|
||||
var_dump($obj->$x[0]);
|
||||
$x = array('bar2');
|
||||
var_dump($obj->$x[0]());
|
||||
|
||||
$obj = new C;
|
||||
var_dump($obj->w[0]->yo);
|
||||
var_dump($obj->w[0]->yo());
|
||||
|
||||
$obj = new C;
|
||||
$w = array('baz');
|
||||
var_dump($obj->$w[0]->blah);
|
||||
var_dump($obj->$w[0]->blah());
|
||||
@@ -0,0 +1,12 @@
|
||||
int(100)
|
||||
int(150)
|
||||
int(200)
|
||||
int(250)
|
||||
int(300)
|
||||
int(350)
|
||||
int(400)
|
||||
int(450)
|
||||
int(500)
|
||||
int(550)
|
||||
int(600)
|
||||
int(650)
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
class D {
|
||||
public $prop = 300;
|
||||
public function prop() { return 350; }
|
||||
public $yo = 500;
|
||||
public function yo() { return 550; }
|
||||
public $blah = 600;
|
||||
public function blah() { return 650; }
|
||||
}
|
||||
class C {
|
||||
public static $x = 100;
|
||||
public static $y = array(200);
|
||||
public static $z = array();
|
||||
public static function foo1() { return 150; }
|
||||
public static function foo2() { return 250; }
|
||||
public $bar1 = 400;
|
||||
public function bar2() { return 450; }
|
||||
public $baz;
|
||||
public $w = array();
|
||||
public function __construct() {
|
||||
$this->baz = new D();
|
||||
$this->w[] = new D();
|
||||
}
|
||||
}
|
||||
C::$z[] = new D();
|
||||
|
||||
var_dump(C::$x);
|
||||
$x = 'foo1';
|
||||
var_dump(C::$x());
|
||||
|
||||
var_dump((C::$y)[0]);
|
||||
$y = array('foo2');
|
||||
var_dump(C::$y[0]());
|
||||
|
||||
var_dump(((C::$z)[0])->prop);
|
||||
var_dump(((C::$z)[0])->prop());
|
||||
|
||||
$obj = new C;
|
||||
$x = array('bar1');
|
||||
var_dump(($obj->$x)[0]);
|
||||
$x = array('bar2');
|
||||
var_dump($obj->$x[0]());
|
||||
|
||||
$obj = new C;
|
||||
var_dump(($obj->w)[0]->yo);
|
||||
var_dump(($obj->w)[0]->yo());
|
||||
|
||||
$obj = new C;
|
||||
$w = array('baz');
|
||||
var_dump(($obj->$w)[0]->blah);
|
||||
var_dump($obj->$w[0]->blah());
|
||||
@@ -0,0 +1,15 @@
|
||||
int(100)
|
||||
int(150)
|
||||
int(200)
|
||||
int(250)
|
||||
int(300)
|
||||
int(350)
|
||||
HipHop Notice: Undefined property: C::$Array in %s on line 40
|
||||
NULL
|
||||
int(450)
|
||||
int(500)
|
||||
int(550)
|
||||
HipHop Notice: Undefined property: C::$Array in %s on line 50
|
||||
HipHop Warning: Cannot access property on non-object in %s on line 50
|
||||
NULL
|
||||
int(650)
|
||||
+22
-16
@@ -1503,11 +1503,12 @@ class_constant_declaration:
|
||||
| T_CONST hh_name_with_type '=' static_scalar { _p->onClassConstant($$,0,$2,$4);}
|
||||
;
|
||||
|
||||
new_expr:
|
||||
T_NEW class_name_reference
|
||||
expr_with_parens:
|
||||
'(' expr_with_parens ')' { $$ = $2;}
|
||||
| T_NEW class_name_reference
|
||||
ctor_arguments { _p->onNewObject($$, $2, $3);}
|
||||
| '(' new_expr ')' { $$ = $2;}
|
||||
;
|
||||
| T_CLONE expr { UEXP($$,$2,T_CLONE,1);}
|
||||
| xhp_tag { $$ = $1;}
|
||||
|
||||
parenthesis_expr:
|
||||
'(' expr ')' { $$ = $2;}
|
||||
@@ -1539,7 +1540,7 @@ yield_list_assign_expr:
|
||||
expr:
|
||||
expr_no_variable { $$ = $1;}
|
||||
| variable { $$ = $1;}
|
||||
| new_expr { $$ = $1;}
|
||||
| expr_with_parens { $$ = $1;}
|
||||
|
||||
expr_no_variable:
|
||||
T_LIST '(' assignment_list ')'
|
||||
@@ -1549,7 +1550,6 @@ expr_no_variable:
|
||||
| variable '=' '&' T_NEW
|
||||
class_name_reference
|
||||
ctor_arguments { _p->onAssignNew($$,$1,$5,$6);}
|
||||
| T_CLONE expr { UEXP($$,$2,T_CLONE,1);}
|
||||
| variable T_PLUS_EQUAL expr { BEXP($$,$1,$3,T_PLUS_EQUAL);}
|
||||
| variable T_MINUS_EQUAL expr { BEXP($$,$1,$3,T_MINUS_EQUAL);}
|
||||
| variable T_MUL_EQUAL expr { BEXP($$,$1,$3,T_MUL_EQUAL);}
|
||||
@@ -1631,7 +1631,6 @@ expr_no_variable:
|
||||
'{' inner_statement_list '}' { Token u; u.reset();
|
||||
_p->onClosure($$,u,$3,$6,$9,$11,1);
|
||||
_p->popLabelInfo();}
|
||||
| xhp_tag { $$ = $1;}
|
||||
| dim_expr { $$ = $1;}
|
||||
| collection_literal { $$ = $1;}
|
||||
;
|
||||
@@ -2098,13 +2097,15 @@ array_access:
|
||||
|
||||
dimmable_variable_access:
|
||||
dimmable_variable array_access { _p->onRefDim($$, $1, $2);}
|
||||
| '(' new_expr ')' array_access { _p->onRefDim($$, $2, $4);}
|
||||
| '(' expr_with_parens ')'
|
||||
array_access { _p->onRefDim($$, $2, $4);}
|
||||
;
|
||||
|
||||
dimmable_variable_no_calls_access:
|
||||
dimmable_variable_no_calls
|
||||
array_access { _p->onRefDim($$, $1, $2);}
|
||||
| '(' new_expr ')' array_access { _p->onRefDim($$, $2, $4);}
|
||||
| '(' expr_with_parens ')'
|
||||
array_access { _p->onRefDim($$, $2, $4);}
|
||||
;
|
||||
|
||||
variable:
|
||||
@@ -2114,7 +2115,8 @@ variable:
|
||||
| class_method_call { $$ = $1;}
|
||||
| dimmable_variable_access { $$ = $1;}
|
||||
| variable property_access { _p->onObjectProperty($$,$1,$2);}
|
||||
| '(' new_expr ')' property_access { _p->onObjectProperty($$,$2,$4);}
|
||||
| '(' expr_with_parens ')'
|
||||
property_access { _p->onObjectProperty($$,$2,$4);}
|
||||
| static_class_name
|
||||
T_PAAMAYIM_NEKUDOTAYIM
|
||||
variable_without_objects { _p->onStaticMember($$,$1,$3);}
|
||||
@@ -2130,7 +2132,7 @@ dimmable_variable:
|
||||
| dimmable_variable_access { $$ = $1;}
|
||||
| variable
|
||||
property_access_without_variables { _p->onObjectProperty($$,$1,$2);}
|
||||
| '(' new_expr ')'
|
||||
| '(' expr_with_parens ')'
|
||||
property_access_without_variables { _p->onObjectProperty($$,$2,$4);}
|
||||
| callable_variable '('
|
||||
function_call_parameter_list ')' { _p->onCall($$,1,$1,$3,NULL);}
|
||||
@@ -2153,13 +2155,16 @@ object_method_call:
|
||||
| variable T_OBJECT_OPERATOR
|
||||
'{' expr '}' '('
|
||||
function_call_parameter_list ')' { _p->onObjectMethodCall($$,$1,$4,$7);}
|
||||
| '(' new_expr ')' T_OBJECT_OPERATOR
|
||||
| '(' expr_with_parens ')'
|
||||
T_OBJECT_OPERATOR
|
||||
ident hh_typeargs_opt '('
|
||||
function_call_parameter_list ')' { _p->onObjectMethodCall($$,$2,$5,$8);}
|
||||
| '(' new_expr ')' T_OBJECT_OPERATOR
|
||||
| '(' expr_with_parens ')'
|
||||
T_OBJECT_OPERATOR
|
||||
variable_without_objects '('
|
||||
function_call_parameter_list ')' { _p->onObjectMethodCall($$,$2,$5,$7);}
|
||||
| '(' new_expr ')' T_OBJECT_OPERATOR
|
||||
| '(' expr_with_parens ')'
|
||||
T_OBJECT_OPERATOR
|
||||
'{' expr '}' '('
|
||||
function_call_parameter_list ')' { _p->onObjectMethodCall($$,$2,$6,$9);}
|
||||
;
|
||||
@@ -2205,7 +2210,8 @@ variable_no_calls:
|
||||
variable_without_objects { $$ = $1;}
|
||||
| dimmable_variable_no_calls_access { $$ = $1;}
|
||||
| variable_no_calls property_access { _p->onObjectProperty($$,$1,$2);}
|
||||
| '(' new_expr ')' property_access { _p->onObjectProperty($$,$2,$4);}
|
||||
| '(' expr_with_parens ')'
|
||||
property_access { _p->onObjectProperty($$,$2,$4);}
|
||||
| static_class_name
|
||||
T_PAAMAYIM_NEKUDOTAYIM
|
||||
variable_without_objects { _p->onStaticMember($$,$1,$3);}
|
||||
@@ -2216,7 +2222,7 @@ dimmable_variable_no_calls:
|
||||
| dimmable_variable_no_calls_access { $$ = $1;}
|
||||
| variable_no_calls
|
||||
property_access_without_variables { _p->onObjectProperty($$,$1,$2);}
|
||||
| '(' new_expr ')'
|
||||
| '(' expr_with_parens ')'
|
||||
property_access_without_variables { _p->onObjectProperty($$,$2,$4);}
|
||||
| '(' variable ')' { $$ = $2;}
|
||||
;
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário