mirror of
https://github.com/php/php-src.git
synced 2024-12-19 06:50:17 +08:00
b03cafd19c
This is a bit tricky: In this cases we have "namespace as", which means that we will only recognize "namespace" as an identifier when the lookahead token is already at the "as". This means that zend_lex_tstring picks up the wrong identifier. We solve this by actually assigning the identifier as the semantic value on the parser stack -- as in almost all cases we will not actually need the identifier, this is just an (offset, size) reference, not a copy of the string. Additionally, we need to teach the lexer feedback mechanism used by tokenizer TOKEN_PARSE mode to apply feedback to something other than the very last token. To that purpose we pass through the token text and check the tokens in reverse order to find the right one. Closes GH-5668.
26 lines
274 B
PHP
26 lines
274 B
PHP
--TEST--
|
|
Bug #77966: Cannot alias a method named "namespace"
|
|
--FILE--
|
|
<?php
|
|
|
|
trait A {
|
|
function namespace() {
|
|
echo "Called\n";
|
|
}
|
|
}
|
|
|
|
class C {
|
|
use A {
|
|
namespace as bar;
|
|
}
|
|
}
|
|
|
|
$c = new C;
|
|
$c->bar();
|
|
$c->namespace();
|
|
|
|
?>
|
|
--EXPECT--
|
|
Called
|
|
Called
|