-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
File::contains*() #122
Comments
I think I can guess your use-case for this question: checking if functions used as filters in WP have a I'm not keen on those kind of methods as they would always be highly inefficient. Those kind of things would be better handled by setting up an (abstract) sniff which listens to the right tokens. Note: and would still not handle cross-file sniffing. |
As highlighted by that use case, the focus of the sniff may not be just about "Does this file contain X or not?", so an abstract sniff is not suitable, but it is one of the parts of the logic needed for a deeper look at whether, in this case, "Does a function have a
Maybe, but that's all the more reason for PHPCSUtils to find what is the most efficient way, and explain the types of guard clauses that could be used, rather than everyone struggling to come up with their own version that is even more inefficient. |
I'll have a think about this. Let me sleep on it. It may be a while before I get to these. |
Side-note: something like |
Idea: a way to check if the current file contains a class, interface, trait, function, assignment to a global constant and perhaps other items.
These would be stepping stones to then having other code which could then analyse them - for instance:
Maybe some of these utility methods take stack pointers rather than strings for classes, methods, etc., but the idea is that those less familiar with writing standards can think in terms of the PHP structures that they are familiar with, rather than tokens - PHPCSUtils can handle that layer between PHP structures and tokens.
The text was updated successfully, but these errors were encountered: