Skip to content
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

Incorrect reporting of endTokenPos attribute in recent versions of nikic/php-parser library. #104

Closed
lisachenko opened this issue Aug 13, 2020 · 7 comments
Labels
Milestone

Comments

@lisachenko
Copy link
Member

There are several bug reports in goaop framework itself about breaks in code:

goaop/framework#451,
goaop/framework#452.

Need to release a hotfix patch version to prevent installation of broken versions.
@nikic, ping

@lisachenko lisachenko added the Bug label Aug 13, 2020
@nikic
Copy link

nikic commented Aug 13, 2020

PHP-Parser 4.7.0 canonicalizes token_get_all() output to the PHP 8 format, using T_NAME_* tokens. Does that sound like something that could affect you? E.g. are you using token positions from PHP-Parser, but doing your own token_get_all call?

lisachenko added a commit that referenced this issue Aug 13, 2020
* origin/2.x:
  Temporary resrict installation of broken parser versions, resolves #104
@lisachenko
Copy link
Member Author

@nikic From what I can see, php-parser reports incorrect position of tokens for nodes. And I'm heavily use this information to adjust original source code (eg to find position where code should be changed). I'm using plain token_get_all() and information from php-parser to find correct position for node in token stream.

Am I right that indexes reported by php-parser can be used to specify an index for array returned by the token_get_all() for the same file?

@lisachenko lisachenko added this to the 2.1.3 milestone Aug 13, 2020
@nikic
Copy link

nikic commented Aug 13, 2020

@lisachenko The token positions returned by php-parser refer to positions into the tokens returned by $lexer->getTokens(), which are based on token_get_all(), but not exactly the same, due to some normalization of PHP version differences. Probably the 4.7 release was the first one where the difference became visible for your usage.

@lisachenko
Copy link
Member Author

Ok, @nikic! Thanks for the quick response, I should update my code to follow new logic.

@xfuturomax
Copy link
Contributor

xfuturomax commented Sep 18, 2020

@lisachenko are there any news or plans about using new version of php-parser? I want to upgrade my phpunit to version 9, and it requires "nikic/php-parser": "^4.8"

@lisachenko
Copy link
Member Author

lisachenko commented Sep 20, 2020

@xfuturomax unfortunately, I’m busy with my new job, thus no time for open-source now. If you want - you can contribute this, it shouldn’t be very hard to adopt new version, need only to use proper methods instead of get_tokens_all() function call.

@xfuturomax
Copy link
Contributor

goaop/framework#454
#106

I've tested with nikic/php-parser v4.10, and all code was generated correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants