And again, as .txt

Am 11.07.11 00:36 schrieb "Lars Strojny" unter <l...@strojny.net>:

>Hi everybody,
>
>Attached is the patch against current trunk with a testcase, tokenizer
>tests do not break. If nobody objects, could somebody with commit access
>to Zend could commit this patch?
>
>With regards,
>Lars
>
>Am 10.07.11 23:51 schrieb "Nikita Popov" unter
><nikita....@googlemail.com>:
>
>>On Sun, Jul 10, 2011 at 11:37 PM, Lars Strojny <l...@strojny.net> wrote:
>>>
>>> Very good find of an inconsistency. Does the testsuite reveal something
>>> strange with that patch?
>>
>>
>>I didn't test that patch, just found it in the bugtracker.
>>cel...@php.net would be a better person to ask, as he wrote it. But
>>just from glancing at it I could imagine that it would break
>>token_get_all() as CG(active_class_entry) wouldn't be set
>>appropriately (though that's just a guess).
>>
>>MfG Nikita
>>
>>-- 
>>PHP Internals - PHP Runtime Development Mailing List
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
>-- 
>PHP Internals - PHP Runtime Development Mailing List
>To unsubscribe, visit: http://www.php.net/unsub.php

Index: Zend/zend_language_scanner.l
===================================================================
--- Zend/zend_language_scanner.l        (revision 313122)
+++ Zend/zend_language_scanner.l        (working copy)
@@ -1007,6 +1007,9 @@
 }
 
 <ST_IN_SCRIPTING>"function" {
+       if (CG(active_class_entry)) {
+               yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
+       }
        return T_FUNCTION;
 }
 
@@ -1163,6 +1166,14 @@
        return T_OBJECT_OPERATOR;
 }
 
+<ST_LOOKING_FOR_PROPERTY>{WHITESPACE} {
+       zendlval->value.str.val = yytext; /* no copying - intentional */
+       zendlval->value.str.len = yyleng;
+       zendlval->type = IS_STRING;
+       HANDLE_NEWLINES(yytext, yyleng);
+       return T_WHITESPACE;
+}
+
 <ST_LOOKING_FOR_PROPERTY>{LABEL} {
        yy_pop_state(TSRMLS_C);
        zend_copy_value(zendlval, yytext, yyleng);
@@ -1177,6 +1188,7 @@
 }
 
 <ST_IN_SCRIPTING>"::" {
+       yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
        return T_PAAMAYIM_NEKUDOTAYIM;
 }
 
Index: Zend/tests/bug28261.phpt
===================================================================
--- Zend/tests/bug28261.phpt    (revision 0)
+++ Zend/tests/bug28261.phpt    (revision 0)
@@ -0,0 +1,57 @@
+--TEST--
+Bug #28261: Lifting reserved keyword restriction for method names
+--FILE--
+<?php
+class Test
+{
+       public function eval()
+       {
+               return __METHOD__;
+       }
+
+       public function include()
+       {
+               return __METHOD__;
+       }
+
+       public function print()
+       {
+               return __METHOD__;
+       }
+}
+
+class Test2
+{
+       public function EVAL()
+       {
+               return __METHOD__;
+       }
+       public function INCLUDE()
+       {
+               return __METHOD__;
+       }
+       public function PRINT()
+       {
+               return __METHOD__;
+       }
+}
+
+$o = new Test();
+printf("%s\n", $o->eval());
+printf("%s\n", $o->include());
+printf("%s\n", $o->print());
+
+$o = new Test2();
+printf("%s\n", $o->EVAL());
+printf("%s\n", $o->INCLUDE());
+printf("%s\n", $o->PRINT());
+?>
+=DONE=
+--EXPECT--
+Test::eval
+Test::include
+Test::print
+Test2::EVAL
+Test2::INCLUDE
+Test2::PRINT
+=DONE=
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to