Bug #77966 [Ver->Csd]: Cannot alias a method named "namespace"
| From: | nikic@php.net | Date: | Mon, 08 Jun 2020 10:59:12 +0000 |
| Subject: | Bug #77966 [Ver->Csd]: Cannot alias a method named "namespace" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227354@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: Verified
+Status: Closed
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.3.5
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b03cafd19c01db57b89727ce77cc89a7d816077c
Log: Fix bug #77966: Cannot alias a method named "namespace"
Previous Comments:
------------------------------------------------------------------------
[2020-06-05 17:11:34] nikic@php.net
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
------------------------------------------------------------------------
[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