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

Generic/One*PerFile sniffs: efficiency tweak #3401

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Jul 25, 2021

Each of these sniffs would start walking the rest of the file from the token next to the OO keyword to the end of the file in search of the next (class/interface/trait) keyword.

As nested OO structure declarations (with the exception of anonymous classes, but those are outside the realm of these sniffs) are not supported in PHP, we can make these sniffs a lot faster by starting the search after the scope closer for the current OO structure.

@jrfnl
Copy link
Contributor Author

jrfnl commented Jul 29, 2021

Note: the build failure on PHP 8.1 is unrelated to this PR. PRs #3394 and #3400 need to be merged to solve the runtime issues, the tokenizer issues are a whole other matter.

Each of these sniffs would start walking the rest of the file from the token next to the OO keyword to the end of the file in search of the next (class/interface/trait) keyword.

As nested OO structure declarations (with the exception of anonymous classes, but those are outside the realm of these sniffs) are not supported in PHP, we can make these sniffs a lot faster by starting the search _after_ the scope closer for the current OO structure.
@jrfnl jrfnl force-pushed the feature/generic-one-oo-perfile-sniff-efficiency-tweak branch from b1f2f12 to e2bbbce Compare December 12, 2021 21:53
@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 12, 2021

Rebased to get a passing build on PHP 8.1.

@jrfnl
Copy link
Contributor Author

jrfnl commented May 31, 2022

@gsherwood Any chance this PR could get some love ?

@gsherwood gsherwood added this to the 3.7.0 milestone May 31, 2022
@gsherwood gsherwood merged commit 5e27199 into squizlabs:master May 31, 2022
@gsherwood
Copy link
Member

Sorry about missing this - was a nice easy merge and a good change.

@jrfnl jrfnl deleted the feature/generic-one-oo-perfile-sniff-efficiency-tweak branch May 31, 2022 23:15
@jrfnl
Copy link
Contributor Author

jrfnl commented May 31, 2022

No worries and thanks for getting it merged.

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

Successfully merging this pull request may close these issues.

2 participants