diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index 984690ce..927df241 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -2806,6 +2806,29 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { } } } + + $magic_constants = $root->selectTokensOfTypes(array( + 'T_CLASS_C', + 'T_METHOD_C', + 'T_FUNC_C', + 'T_LINE', + 'T_FILE', + 'T_NS_C', + 'T_DIR', + 'T_TRAIT_C', + )); + + foreach ($magic_constants as $magic_constant) { + $value = $magic_constant->getValue(); + + if ($value != strtoupper($value)) { + $this->raiseLintAtToken( + $magic_constant, + self::LINT_KEYWORD_CASING, + pht('Magic constants should be uppercase.'), + strtoupper($value)); + } + } } private function lintStrings(XHPASTNode $root) { diff --git a/src/lint/linter/__tests__/xhpast/keyword-casing.lint-test b/src/lint/linter/__tests__/xhpast/keyword-casing.lint-test index a3454b6e..e813ec40 100644 --- a/src/lint/linter/__tests__/xhpast/keyword-casing.lint-test +++ b/src/lint/linter/__tests__/xhpast/keyword-casing.lint-test @@ -14,6 +14,8 @@ function f(array $x, ArRaY $y) {} new C(); NeW C(); + +echo __file__; ~~~~~~~~~~ warning:6:1 warning:7:1 @@ -22,6 +24,7 @@ warning:9:1 warning:11:1 warning:13:22 warning:16:1 +warning:18:6 ~~~~~~~~~~