-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UseStatements::splitImportUseStatement(): improve handling of leading…
… backslash Import use statements should not be declared with a leading backslash and doing so is discouraged by PHP itself: > Note that for namespaced names (fully qualified namespace names containing namespace separator, such as `Foo\Bar` as opposed to global names that do not, such as `FooBar`), the leading backslash is unnecessary and not recommended, as import names must be fully qualified, and are not processed relative to the current namespace. Ref: https://www.php.net/manual/en/language.namespaces.importing.php However, it is not a parse error to declare an import with a leading backslash. Until now, the behaviour of this method in such a case was undefined, which, in practice, meant that the leading backslash would be included in the full name. For consistency, however, this is undesirable and makes the names found in the return value more awkward to handle by sniffs using the method. This commit now explicitly defines the behaviour around leading backslashes in import use statements and prevents these from being included in the names in the return value. Includes unit tests.
- Loading branch information
Showing
3 changed files
with
36 additions
and
7 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
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
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