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

Find a workaround for the warning when using token_get_all #10

Open
alexander-schranz opened this issue Jul 22, 2020 · 1 comment
Open

Comments

@alexander-schranz
Copy link
Contributor

Currently in MigrationUtil class only the first 20 lines are read of the migration this can cause when cut unluckily into the following warning

PHP Warning: Unterminated comment starting line 1 in Command line code on line 1
Warning: Unterminated comment starting line 1 in Command line code on line 1

This warning is at current state suppressed using @. This sadly suppression can sadly not be detected by sentry (see following issue) and throws always a error there.

What is the case of just reading the first 20 lines, are there maybe today better ways? Should we just check if a comment was opened and close it manually before giving it to the function?

@dantleech
Copy link
Member

dantleech commented Jul 22, 2020

It's the same in phpbench and I basically stole it from Stackoverflow.

It's faster than parsing an AST - we read the first 20 lines, and if there is no class then we try the next 20. Probably it could be smarter - maybe there's already a library which does this? classy is one example, maybe - this library does essentially the same thing but tokenizes the entire source file - I guess there might not even be much performance penalty.

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

No branches or pull requests

2 participants