Disallow array deref using alternative syntax

f(){0} and a::b(){0} aren't allowed anymore (in compliance with PHP).
$a->b(){0} support stays for now (for technical reason).
This commit is contained in:
nikic 2011-12-04 17:07:17 +01:00
parent fa5f9e0740
commit 1449cc2092
4 changed files with 467 additions and 501 deletions

View File

@ -602,7 +602,7 @@ function_call:
| variable_without_objects '(' argument_list ')' | variable_without_objects '(' argument_list ')'
{ $$ = Expr_FuncCall[$1, $3]; } { $$ = Expr_FuncCall[$1, $3]; }
| function_call '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$1, $3]; } | function_call '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$1, $3]; }
| function_call '{' expr '}' { $$ = Expr_ArrayDimFetch[$1, $3]; } /* alternative array syntax missing intentionally */
; ;
class_name: class_name:
@ -724,6 +724,7 @@ variable:
new_expr_array_deref: new_expr_array_deref:
'(' new_expr ')' '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$2, $5]; } '(' new_expr ')' '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$2, $5]; }
| new_expr_array_deref '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$1, $3]; } | new_expr_array_deref '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$1, $3]; }
/* alternative array syntax missing intentionally */
; ;
object_access: object_access:

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,6 @@ $a{'b'}();
// array dereferencing // array dereferencing
a()['b']; a()['b'];
a(){'b'}; // this is invalid PHP. Remove?
----- -----
array( array(
0: Expr_FuncCall( 0: Expr_FuncCall(
@ -99,18 +98,4 @@ array(
value: b value: b
) )
) )
8: Expr_ArrayDimFetch(
var: Expr_FuncCall(
name: Name(
parts: array(
0: a
)
)
args: array(
)
)
dim: Scalar_String(
value: b
)
)
) )

View File

@ -11,7 +11,6 @@ A::$b['c']['d']();
// array dereferencing // array dereferencing
A::b()['c']; A::b()['c'];
A::b(){'c'}; // this is invalid PHP. Remove?
// class name variations // class name variations
static::b(); static::b();
@ -108,22 +107,7 @@ array(
value: c value: c
) )
) )
6: Expr_ArrayDimFetch( 6: Expr_StaticCall(
var: Expr_StaticCall(
class: Name(
parts: array(
0: A
)
)
name: b
args: array(
)
)
dim: Scalar_String(
value: c
)
)
7: Expr_StaticCall(
class: Name( class: Name(
parts: array( parts: array(
0: static 0: static
@ -133,7 +117,7 @@ array(
args: array( args: array(
) )
) )
8: Expr_StaticCall( 7: Expr_StaticCall(
class: Expr_Variable( class: Expr_Variable(
name: a name: a
) )
@ -141,7 +125,7 @@ array(
args: array( args: array(
) )
) )
9: Expr_StaticCall( 8: Expr_StaticCall(
class: Expr_Variable( class: Expr_Variable(
name: Scalar_String( name: Scalar_String(
value: a value: a
@ -151,7 +135,7 @@ array(
args: array( args: array(
) )
) )
10: Expr_StaticCall( 9: Expr_StaticCall(
class: Expr_ArrayDimFetch( class: Expr_ArrayDimFetch(
var: Expr_Variable( var: Expr_Variable(
name: a name: a