Skip to content

Commit ad4d6d1

Browse files
committed
Added support for Class::{expr}() syntax (Pierrick)
1 parent 2edd901 commit ad4d6d1

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
. Short array syntax, see UPGRADING guide for full details (rsky0711 at gmail
66
. com, sebastian.deutsch at 9elements . com, Pierre)
77
. Binary numbers format (0b001010). (Jonah dot Harris at gmail dot com)
8+
. Support for Class::{expr}() syntax (Pierrick)
89

910
- Removed features:
1011
. Removed magic_quotes_gpc, magic_quotes_runtime and magic_quotes_sybase ini options.

Zend/tests/bug55247.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Request #55247 (Parser problem with static calls using string method name)
3+
--FILE--
4+
<?php
5+
class Test{
6+
public static function __callStatic($method, $arguments)
7+
{
8+
echo $method . PHP_EOL;
9+
}
10+
public function __call($method, $arguments)
11+
{
12+
echo $method . PHP_EOL;
13+
}
14+
}
15+
16+
$method = 'method';
17+
18+
$test = new Test();
19+
20+
$test->method();
21+
$test->$method();
22+
$test->{'method'}();
23+
24+
Test::method();
25+
Test::$method();
26+
Test::{'method'}();
27+
--EXPECT--
28+
method
29+
method
30+
method
31+
method
32+
method
33+
method

Zend/zend_language_parser.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,13 +797,13 @@ function_call:
797797
| T_NS_SEPARATOR namespace_name '(' { $3.u.op.opline_num = zend_do_begin_function_call(&$2, 0 TSRMLS_CC); }
798798
function_call_parameter_list
799799
')' { zend_do_end_function_call(&$2, &$$, &$5, 0, $3.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
800-
| class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { $4.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
800+
| class_name T_PAAMAYIM_NEKUDOTAYIM variable_name '(' { $4.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
801801
function_call_parameter_list
802802
')' { zend_do_end_function_call($4.u.op.opline_num?NULL:&$3, &$$, &$6, $4.u.op.opline_num, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
803803
| class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
804804
function_call_parameter_list
805805
')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
806-
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
806+
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name '(' { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
807807
function_call_parameter_list
808808
')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
809809
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }

0 commit comments

Comments
 (0)