-
Notifications
You must be signed in to change notification settings - Fork 73
fix: staticlookup inside call #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks
read_expr
is invalid here, what better call?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not so clear, here an extract from the grammar :
https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1175
and function_call is used by callable_variable, whic used by variable, used by expr, so that's the right place - I'll checkout and play with the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything is correct, but I see an extra statement. Here a sample error code :
Come from this L99 :
https://github.com/glayzzle/php-parser/pull/225/files/a284ac035ed8f7d57e97c46a94f6aa0cc7467f17#diff-bb9fff60e32f00c7312e3788510fe2acR99
As you can see from the specs, you have handled the
'{' expr '}'
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, after checking with PHP 7.2, here the result :
Need to digg more into this 👎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, just for information, in order to check what is wrong, I make a search on the zend parser language on the token that make static lookups
T_PAAMAYIM_NEKUDOTAYIM
and try to understand what can come next - Im' doing this to understand allowed syntax.Here the results :
We are in a
member_name
related expression, before your changemember_name
was either anidentifier
or asimple_variable
, so no mandatory argument_list.Now with the
expr
introduction, member_name has an differentiation, identier or simple_variable (previous code) can run just as before without a constraint on calling expression, but now, you need a call statement just after the expr, because ofmember_name argument_list
.So your expect
(
statement was a good way to force the parser to validate the syntax and continue the AST with a call node.Now in order to be sure if you don't introduce a miss-behavior you need to check the
read_static_getter
helper usage into the parser and also to check themember_name
from the php source.In php-parser, it's used by
read_class_name_reference
,read_scalar
,read_variable
In php yaccs file :
function_call
, which is itself called from callable_variable, which in turn is called from callable_expr, variable (equivalent of our read_variable)So I conclude that
read_class_name_reference
+read_scalar
may introduce problems, need to digg more.Checking the read_scallar function I found a comment about https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1151 pointing to nothing as I did not include the commit-id on links 👎 - so I need to digg with the opening token
T_CONSTANT_ENCAPSED_STRING
, used by dereferencable_scalar -> scallar, dereferencable, callable_expr. As callable_expr is used to trigger a function_call we are good with this one.The same for the other, the read_new_expr is the only reference to this one, so I go to the yaccs definition, and find that corresponds to the new_expr definition defined as :
Our block of code concerns onlye the
class_name_reference ctor_arguments
part, and here the definition of the class_name_referenceAs you can see here,
T_PAAMAYIM_NEKUDOTAYIM
must be handled in our case, but just followed withsimple_variable
which excludes anidentifier
or an'{' expr '}'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here our parser is just not enough strict and will parse these extra syntax, and PHP not :