dmitry                                   Mon, 01 Aug 2011 12:08:44 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=314025

Log:
Added support for Class::{expr}() syntax (Pierrick)

Changed paths:
    U   php/php-src/branches/PHP_5_4/NEWS
    A   php/php-src/branches/PHP_5_4/Zend/tests/bug55247.phpt
    U   php/php-src/branches/PHP_5_4/Zend/zend_language_parser.y
    A   php/php-src/trunk/Zend/tests/bug55247.phpt
    U   php/php-src/trunk/Zend/zend_language_parser.y

Modified: php/php-src/branches/PHP_5_4/NEWS
===================================================================
--- php/php-src/branches/PHP_5_4/NEWS   2011-08-01 12:08:29 UTC (rev 314024)
+++ php/php-src/branches/PHP_5_4/NEWS   2011-08-01 12:08:44 UTC (rev 314025)
@@ -5,6 +5,7 @@
  . Short array syntax, see UPGRADING guide for full details (rsky0711 at gmail
    . com, sebastian.deutsch at 9elements . com, Pierre)
  . Binary numbers format (0b001010). (Jonah dot Harris at gmail dot com)
+ . Support for Class::{expr}() syntax (Pierrick)

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

Added: php/php-src/branches/PHP_5_4/Zend/tests/bug55247.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/bug55247.phpt                       
        (rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/bug55247.phpt       2011-08-01 
12:08:44 UTC (rev 314025)
@@ -0,0 +1,33 @@
+--TEST--
+Request #55247 (Parser problem with static calls using string method name)
+--FILE--
+<?php
+class Test{
+    public static function __callStatic($method, $arguments)
+       {
+        echo $method . PHP_EOL;
+    }
+    public function __call($method, $arguments)
+       {
+        echo $method . PHP_EOL;
+    }
+}
+
+$method = 'method';
+
+$test = new Test();
+
+$test->method();
+$test->$method();
+$test->{'method'}();
+
+Test::method();
+Test::$method();
+Test::{'method'}();
+--EXPECT--
+method
+method
+method
+method
+method
+method

Modified: php/php-src/branches/PHP_5_4/Zend/zend_language_parser.y
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/zend_language_parser.y    2011-08-01 
12:08:29 UTC (rev 314024)
+++ php/php-src/branches/PHP_5_4/Zend/zend_language_parser.y    2011-08-01 
12:08:44 UTC (rev 314025)
@@ -797,13 +797,13 @@
        |       T_NS_SEPARATOR namespace_name '(' { $3.u.op.opline_num = 
zend_do_begin_function_call(&$2, 0 TSRMLS_CC); }
                                function_call_parameter_list
                                ')' { zend_do_end_function_call(&$2, &$$, &$5, 
0, $3.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
-       |       class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { 
$4.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 
TSRMLS_CC); }
+       |       class_name T_PAAMAYIM_NEKUDOTAYIM variable_name '(' { 
$4.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 
TSRMLS_CC); }
                        function_call_parameter_list
                        ')' { 
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);}
        |       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); }
                        function_call_parameter_list
                        ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 
TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
-       |       variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { 
zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
+       |       variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name '(' { 
zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
                        function_call_parameter_list
                        ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 
TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
        |       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); }

Added: php/php-src/trunk/Zend/tests/bug55247.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug55247.phpt                          (rev 0)
+++ php/php-src/trunk/Zend/tests/bug55247.phpt  2011-08-01 12:08:44 UTC (rev 
314025)
@@ -0,0 +1,33 @@
+--TEST--
+Request #55247 (Parser problem with static calls using string method name)
+--FILE--
+<?php
+class Test{
+    public static function __callStatic($method, $arguments)
+       {
+        echo $method . PHP_EOL;
+    }
+    public function __call($method, $arguments)
+       {
+        echo $method . PHP_EOL;
+    }
+}
+
+$method = 'method';
+
+$test = new Test();
+
+$test->method();
+$test->$method();
+$test->{'method'}();
+
+Test::method();
+Test::$method();
+Test::{'method'}();
+--EXPECT--
+method
+method
+method
+method
+method
+method

Modified: php/php-src/trunk/Zend/zend_language_parser.y
===================================================================
--- php/php-src/trunk/Zend/zend_language_parser.y       2011-08-01 12:08:29 UTC 
(rev 314024)
+++ php/php-src/trunk/Zend/zend_language_parser.y       2011-08-01 12:08:44 UTC 
(rev 314025)
@@ -797,13 +797,13 @@
        |       T_NS_SEPARATOR namespace_name '(' { $3.u.op.opline_num = 
zend_do_begin_function_call(&$2, 0 TSRMLS_CC); }
                                function_call_parameter_list
                                ')' { zend_do_end_function_call(&$2, &$$, &$5, 
0, $3.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
-       |       class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { 
$4.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 
TSRMLS_CC); }
+       |       class_name T_PAAMAYIM_NEKUDOTAYIM variable_name '(' { 
$4.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 
TSRMLS_CC); }
                        function_call_parameter_list
                        ')' { 
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);}
        |       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); }
                        function_call_parameter_list
                        ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 
TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
-       |       variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { 
zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
+       |       variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name '(' { 
zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
                        function_call_parameter_list
                        ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 
TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
        |       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); }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to