|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77966 Cannot alias a method named "namespace"
Submitted: 2019-05-04 01:42 UTC Modified: 2019-05-07 15:23 UTC
From: mattacosta at gmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.3.5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mattacosta at gmail dot com
New email:
PHP Version: OS:


 [2019-05-04 01:42 UTC] mattacosta at gmail dot com
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:

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


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-07 15:23 UTC]
-Status: Open +Status: Verified
 [2019-05-07 15:23 UTC]
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".
 [2020-06-05 17:11 UTC]
The following pull request has been associated:

Patch Name: Fix bug #77966: Cannot alias a method named "namespace"
On GitHub:
 [2020-06-08 10:59 UTC]
Automatic comment on behalf of
Log: Fix bug #77966: Cannot alias a method named &quot;namespace&quot;
 [2020-06-08 10:59 UTC]
-Status: Verified +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Dec 07 01:01:28 2023 UTC