Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14095478
D12368.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D12368.diff
View Options
diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php
--- a/src/lint/linter/ArcanistXHPASTLinter.php
+++ b/src/lint/linter/ArcanistXHPASTLinter.php
@@ -2806,6 +2806,29 @@
}
}
}
+
+ $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
--- a/src/lint/linter/__tests__/xhpast/keyword-casing.lint-test
+++ b/src/lint/linter/__tests__/xhpast/keyword-casing.lint-test
@@ -14,6 +14,8 @@
new C();
NeW C();
+
+echo __file__;
~~~~~~~~~~
warning:6:1
warning:7:1
@@ -22,6 +24,7 @@
warning:11:1
warning:13:22
warning:16:1
+warning:18:6
~~~~~~~~~~
<?php
@@ -39,3 +42,5 @@
new C();
new C();
+
+echo __FILE__;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 9:33 PM (20 h, 53 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6790970
Default Alt Text
D12368.diff (1 KB)
Attached To
Mode
D12368: Further improvements to keyword casing linter rule
Attached
Detach File
Event Timeline
Log In to Comment