Fix bug #77966: Cannot alias a method named "namespace"#5668
Closed
nikic wants to merge 5 commits intophp:masterfrom
Closed
Fix bug #77966: Cannot alias a method named "namespace"#5668nikic wants to merge 5 commits intophp:masterfrom
nikic wants to merge 5 commits intophp:masterfrom
Conversation
And fix handling of on_event in object mode
Contributor
|
Oh boy. Are there more special cases like that? That one didn't come up during the RFC. |
Member
Author
|
@marcioAlmada This is the only one I'm aware of right now, but this will also be needed for named parameters (which is why I bothered to implement it now). |
TysonAndre
added a commit
to TysonAndre/php-src
that referenced
this pull request
Jan 18, 2021
Related to phpGH-5668 Also affects php 8.0 but this changes the datastructures in public header files. (binary ABI change) PHP 7.4 wouldn't even parse a class with the below example. 1. Fix parsing semi-reserved tokens such as `namespace` with an offset that's larger than 2**32 2. Fix parsing some tokens when their length is larger than 2**32 Offset is relative to yy_start(the start of the file?) Low priority because 4GB php files are extremely rare ``` php > ini_set('memory_limit', '12G'); php > eval(str_repeat(' ' , 2**32) . 'class MyClass{ public static function namespace() {}}'); php > MyClass::namespace(); Warning: Uncaught Error: Call to undefined method MyClass::namespace() in php shell code:1 Stack trace: thrown in php shell code on line 1 php > var_export((new ReflectionClass('MyClass'))->getMethods()); array ( 0 => ReflectionMethod::__set_state(array( 'name' => ' ', 'class' => 'MyClass', )), ) ```
TysonAndre
added a commit
to TysonAndre/php-src
that referenced
this pull request
Jan 18, 2021
Related to phpGH-5668 Also affects php 8.0 but this changes the datastructures in public header files. (binary ABI change) PHP 7.4 wouldn't even parse a class with the below example. 1. Fix parsing semi-reserved tokens such as `namespace` with an offset that's larger than 2**32 2. Fix parsing some tokens when their length is larger than 2**32 Offset is relative to yy_start(the start of the file?) Low priority because 4GB php files are extremely rare ``` php > ini_set('memory_limit', '12G'); php > eval(str_repeat(' ' , 2**32) . 'class MyClass{ public static function namespace() {}}'); php > MyClass::namespace(); Warning: Uncaught Error: Call to undefined method MyClass::namespace() in php shell code:1 Stack trace: thrown in php shell code on line 1 php > var_export((new ReflectionClass('MyClass'))->getMethods()); array ( 0 => ReflectionMethod::__set_state(array( 'name' => ' ', 'class' => 'MyClass', )), ) ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The basic problem is that the identifier is no longer the lookahead token in this case, which means we have to support the whole machinery for going back more than one token. This means we should remember the identifier on the parser stack and modify the on_event API to distinguish the token the feedback applies to.