You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BCFile::getDeclarationName(): sync with PHPCS 4.0 / stop accepting tokens for non-named structures
The `[BC]File::getDeclarationName()` method - for historic reasons - accepted the `T_CLOSURE` and `T_ANON_CLASS` tokens, even though these structures will never have a name, and returned `null` for those tokens.
This commit changes the `BCFile::getDeclarationName()` method to no longer accept those tokens and throw an exception if they are passed to the method instead.
As a secondary change, when the name of a valid structure cannot be determined, the method will now no longer return `null`, but will return an empty string.
This normalizes the return type of the method to always return a string (or throw an exception).
Includes updated unit tests to match.
This change mirrors the upstream change made to the `File::getDeclarationName()` method in PHPCS 4.0.
Note: this change is NOT mirrored in the `ObjectDeclarations::getName()` method, as changing it there would constitute a breaking change for PHPCSUtils, so that change needs to wait until PHPCSUtils 2.0.
Ref: PHPCSStandards/PHP_CodeSniffer 1007
0 commit comments