-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ New ObjectDeclarations::getDeclared*() utility methods
This commit adds a new set of utility methods to the `ObjectDeclarations` class: * `getDeclaredConstants(File $phpcsFile, int $stackPtr): array` * `getDeclaredEnumCases(File $phpcsFile, int $stackPtr): array` * `getDeclaredProperties(File $phpcsFile, int $stackPtr): array` * `getDeclaredMethods(File $phpcsFile, int $stackPtr): array` * (`private`) `analyzeOOStructure(File $phpcsFile, int $stackPtr): array` These methods allow for retrieving an array with the names of all constants, enum cases, properties and methods as the keys and the stack pointer to the relevant `T_CONST`, `T_ENUM_CASE`, `T_VARIABLE` or `T_FUNCTION` token as the value. As these methods all used the same `analyzeOOStructure()` method under the hood and the results of that method are cached, the method are highly optimized for performance. If a sniff needs to search for a named constant/enum case/property/method in an OO structure, in most cases, these methods should be the recommended way for finding the declaration, instead of the sniff attempting to do this itself. Includes extensive unit tests.
- Loading branch information
Showing
21 changed files
with
1,828 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.