|  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: Verified Package: Scripting Engine problem
PHP Version: 7.3.5 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

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".
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Feb 17 13:01:26 2020 UTC