Bug #77966 [Opn->Ver]: Cannot alias a method named "namespace"

From: Date: Tue, 07 May 2019 15:23:50 +0000
Subject: Bug #77966 [Opn->Ver]: Cannot alias a method named "namespace"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220745@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 Updated by: nikic@php.net Reported by: mattacosta at gmail dot com Summary: Cannot alias a method named "namespace" -Status: Open +Status: Verified Type: Bug Package: Scripting Engine problem PHP Version: 7.3.5 Block user comment: N Private report: N New Comment: 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". Previous Comments: ------------------------------------------------------------------------ [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 (#220745) next »