Page MenuHomePhabricator

D13796.diff
No OneTemporary

D13796.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -32,6 +32,7 @@
'ArcanistCSSLintLinterTestCase' => 'lint/linter/__tests__/ArcanistCSSLintLinterTestCase.php',
'ArcanistCSharpLinter' => 'lint/linter/ArcanistCSharpLinter.php',
'ArcanistCallConduitWorkflow' => 'workflow/ArcanistCallConduitWorkflow.php',
+ 'ArcanistCallParenthesesXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php',
'ArcanistCallTimePassByReferenceXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistCallTimePassByReferenceXHPASTLinterRule.php',
'ArcanistCapabilityNotSupportedException' => 'workflow/exception/ArcanistCapabilityNotSupportedException.php',
'ArcanistCastSpacingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistCastSpacingXHPASTLinterRule.php',
@@ -42,7 +43,6 @@
'ArcanistClassNameLiteralXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistClassNameLiteralXHPASTLinterRule.php',
'ArcanistCloseRevisionWorkflow' => 'workflow/ArcanistCloseRevisionWorkflow.php',
'ArcanistCloseWorkflow' => 'workflow/ArcanistCloseWorkflow.php',
- 'ArcanistClosingCallParenthesesXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistClosingCallParenthesesXHPASTLinterRule.php',
'ArcanistClosureLinter' => 'lint/linter/ArcanistClosureLinter.php',
'ArcanistClosureLinterTestCase' => 'lint/linter/__tests__/ArcanistClosureLinterTestCase.php',
'ArcanistCoffeeLintLinter' => 'lint/linter/ArcanistCoffeeLintLinter.php',
@@ -305,6 +305,7 @@
'ArcanistCSSLintLinterTestCase' => 'ArcanistExternalLinterTestCase',
'ArcanistCSharpLinter' => 'ArcanistLinter',
'ArcanistCallConduitWorkflow' => 'ArcanistWorkflow',
+ 'ArcanistCallParenthesesXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistCallTimePassByReferenceXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistCapabilityNotSupportedException' => 'Exception',
'ArcanistCastSpacingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
@@ -315,7 +316,6 @@
'ArcanistClassNameLiteralXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistCloseRevisionWorkflow' => 'ArcanistWorkflow',
'ArcanistCloseWorkflow' => 'ArcanistWorkflow',
- 'ArcanistClosingCallParenthesesXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistClosureLinter' => 'ArcanistExternalLinter',
'ArcanistClosureLinterTestCase' => 'ArcanistExternalLinterTestCase',
'ArcanistCoffeeLintLinter' => 'ArcanistExternalLinter',
diff --git a/src/lint/linter/__tests__/xhpast/call-parens-hug-closing.lint-test b/src/lint/linter/__tests__/xhpast/call-parens-hug-closing.lint-test
--- a/src/lint/linter/__tests__/xhpast/call-parens-hug-closing.lint-test
+++ b/src/lint/linter/__tests__/xhpast/call-parens-hug-closing.lint-test
@@ -16,9 +16,11 @@
The robot says, "Beep beep boop boop!"
EODOC
);
+f (1);
~~~~~~~~~~
warning:4:4
warning:9:4
+warning:19:2
~~~~~~~~~~
<?php
@@ -37,3 +39,4 @@
The robot says, "Beep beep boop boop!"
EODOC
);
+f(1);
diff --git a/src/lint/linter/xhpast/rules/ArcanistClosingCallParenthesesXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php
rename from src/lint/linter/xhpast/rules/ArcanistClosingCallParenthesesXHPASTLinterRule.php
rename to src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistClosingCallParenthesesXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php
@@ -1,6 +1,6 @@
<?php
-final class ArcanistClosingCallParenthesesXHPASTLinterRule
+final class ArcanistCallParenthesesXHPASTLinterRule
extends ArcanistXHPASTLinterRule {
const ID = 37;
@@ -20,6 +20,22 @@
));
foreach ($calls as $call) {
+ $params = $call->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
+ $tokens = $params->getTokens();
+ $first = head($tokens);
+
+ $leading = $first->getNonsemanticTokensBefore();
+ $leading_text = implode('', mpull($leading, 'getValue'));
+ if (preg_match('/^\s+$/', $leading_text)) {
+ $this->raiseLintAtOffset(
+ $first->getOffset() - strlen($leading_text),
+ pht('Convention: no spaces before opening parenthesis in calls.'),
+ $leading_text,
+ '');
+ }
+ }
+
+ foreach ($calls as $call) {
// If the last parameter of a call is a HEREDOC, don't apply this rule.
$params = $call
->getChildOfType(1, 'n_CALL_PARAMETER_LIST')

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 6:13 PM (21 h, 22 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6790474
Default Alt Text
D13796.diff (4 KB)

Event Timeline