HomePhabricator

Add a linter rule for `use` statement namespace prefixes

Description

Add a linter rule for use statement namespace prefixes

Summary:
When importing or aliases a symbol with a use statement, the leading namespace separator is optional and does not modify the behavior. That is, use \X is equivalent to use X. As such, the latter syntax should be preferred because it is more concise.

According to the PHP documentation:

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.

Test Plan: Added test cases.

Reviewers: epriestley, Blessed Reviewers

Reviewed By: epriestley, Blessed Reviewers

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D14517

Details

Provenance
joshuaspenceAuthored on
joshuaspencePushed on Nov 23 2015, 7:42 PM
Reviewer
Blessed Reviewers
Differential Revision
D14517: Add a linter rule for `use` statement namespace prefixes
Parents
rARCc71fe67ccbbe: Address feedback from D14530
Branches
Unknown
Tags
Unknown
Build Status
Buildable 9019
Build 10597: Run Core Tests