Bug #77966 [PATCH]: Cannot alias a method named "namespace"

From: Date: Fri, 05 Jun 2020 17:11:34 +0000
Subject: Bug #77966 [PATCH]: Cannot alias a method named "namespace"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227334@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77966&edit=1 ID: 77966 Patch added by: nikic@php.net Reported by: mattacosta at gmail dot com Summary: Cannot alias a method named "namespace" Status: Verified Type: Bug Package: Scripting Engine problem PHP Version: 7.3.5 Block user comment: N Private report: N New Comment: The following pull request has been associated: Patch Name: Fix bug #77966: Cannot alias a method named "namespace" On GitHub: https://github.com/php/php-src/pull/5668 Patch: https://github.com/php/php-src/pull/5668.patch Previous Comments: ------------------------------------------------------------------------ [2019-05-07 15:23:50] nikic@php.net I think the problem here is that we'll only reduce T_NAMESPACE as a semi-reserved identifier after already fetching T_AS as the next lookahead token, at which point zend_lex_tstring() will use the contents of "as" rather than "namespace". ------------------------------------------------------------------------ [2019-05-04 01:42:06] mattacosta at gmail dot com Description: ------------ Methods may use semi-reserved keywords, however it is not possible to alias a method named "namespace". According to the error, the alias statement somehow becomes equivalent to 'as as bar'. Test script: --------------- <?php trait A { function namespace() {} } class C { use A { namespace as bar; } } Expected result: ---------------- No error. This should be no different than if the method were named 'foo' and then using 'foo as bar'. Actual result: -------------- Fatal error: An alias (bar) was defined for method as(), but this method does not exist in /in/DmNne on line 7 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77966&edit=1

« previous php.bugs (#227334) next »