]> khamidou — GitHub mirrors - arcanist.git/commit
Add a linter rule for `use` statement namespace prefixes
authorJoshua Spence <josh@freelancer.com>
Mon, 23 Nov 2015 19:42:39 +0000 (06:42 +1100)
committerJoshua Spence <josh@freelancer.com>
Mon, 23 Nov 2015 19:42:39 +0000 (06:42 +1100)
commitae210fda9f4bb054ca606ac14e99e9a201130dd2
tree0813781d58829e0566a59bd50343e5e8484bdb4d
parentc71fe67ccbbe826d11a3f83174647de4eae6b30f
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 [[http://php.net/manual/en/language.namespaces.importing.php | 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
src/__phutil_library_map__.php
src/lint/linter/xhpast/rules/ArcanistUseStatementNamespacePrefixXHPASTLinterRule.php [new file with mode: 0644]
src/lint/linter/xhpast/rules/__tests__/ArcanistUseStatementNamespacePrefixXHPASTLinterRuleTestCase.php [new file with mode: 0644]
src/lint/linter/xhpast/rules/__tests__/use-statement-namespace-prefix/use.lint-test [new file with mode: 0644]