Page MenuHomePhabricator

Add a linter rule for `use` statement namespace prefixes
ClosedPublic

Authored by joshuaspence on Nov 19 2015, 5:46 AM.
Tags
None
Referenced Files
F14029441: D14517.id35207.diff
Fri, Nov 8, 8:43 PM
F14029164: D14517.diff
Fri, Nov 8, 7:56 PM
F14000328: D14517.diff
Thu, Oct 24, 9:14 PM
F13992529: D14517.id35207.diff
Tue, Oct 22, 5:08 PM
F13988023: D14517.id35134.diff
Mon, Oct 21, 12:41 PM
F13979857: D14517.diff
Sat, Oct 19, 6:56 AM
F13979846: D14517.id.diff
Sat, Oct 19, 6:53 AM
F13979843: D14517.id35117.diff
Sat, Oct 19, 6:52 AM
Subscribers

Details

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.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

joshuaspence retitled this revision from to Add a linter rule for `use` statement namespace prefixes.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
epriestley edited edge metadata.
This revision is now accepted and ready to land.Nov 23 2015, 3:28 PM
This revision was automatically updated to reflect the committed changes.