Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18085385
D14616.id35359.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D14616.id35359.diff
View Options
diff --git a/src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistCallParenthesesXHPASTLinterRule.php
@@ -15,36 +15,12 @@
public function process(XHPASTNode $root) {
$nodes = $root->selectDescendantsOfTypes(array(
- 'n_ARRAY_LITERAL',
'n_FUNCTION_CALL',
'n_METHOD_CALL',
- 'n_LIST',
));
foreach ($nodes as $node) {
- switch ($node->getTypeName()) {
- case 'n_ARRAY_LITERAL':
- if (head($node->getTokens())->getTypeName() == '[') {
- // Short array syntax.
- continue 2;
- }
-
- $params = $node->getChildOfType(0, 'n_ARRAY_VALUE_LIST');
- break;
-
- case 'n_FUNCTION_CALL':
- case 'n_METHOD_CALL':
- $params = $node->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
- break;
-
- case 'n_LIST':
- $params = $node->getChildOfType(0, 'n_ASSIGNMENT_LIST');
- break;
-
- default:
- throw new Exception(
- pht("Unexpected node of type '%s'!", $node->getTypeName()));
- }
+ $params = $node->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
$tokens = $params->getTokens();
$first = head($tokens);
diff --git a/src/lint/linter/xhpast/rules/ArcanistParenthesesSpacingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistParenthesesSpacingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistParenthesesSpacingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistParenthesesSpacingXHPASTLinterRule.php
@@ -34,10 +34,6 @@
$nonsem_o = $token_o->getNonsemanticTokensAfter();
$nonsem_c = $token_c->getNonsemanticTokensBefore();
- if (!$nonsem_o) {
- continue;
- }
-
$raise = array();
$string_o = implode('', mpull($nonsem_o, 'getValue'));
diff --git a/src/lint/linter/xhpast/rules/__tests__/call-parentheses/array.lint-test b/src/lint/linter/xhpast/rules/__tests__/call-parentheses/array.lint-test
deleted file mode 100644
--- a/src/lint/linter/xhpast/rules/__tests__/call-parentheses/array.lint-test
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-array ( 1, 2, 3 );
-list ( $x, $y ) = array();
-[ 1, 2 , 3 ];
-~~~~~~~~~~
-warning:3:6
-warning:4:5
-warning:4:14
-~~~~~~~~~~
-<?php
-
-array( 1, 2, 3 );
-list( $x, $y) = array();
-[ 1, 2 , 3 ];
diff --git a/src/lint/linter/xhpast/rules/__tests__/parentheses-spacing/closure.lint-test b/src/lint/linter/xhpast/rules/__tests__/parentheses-spacing/closure.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/parentheses-spacing/closure.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/parentheses-spacing/closure.lint-test
@@ -1,12 +1,16 @@
<?php
-$x = function ( $y) use ( $z) {
+$x = function ( $y ) use ( $z ) {
return $y + $z;
};
~~~~~~~~~~
warning:3:16
-warning:3:26
+warning:3:19
+warning:3:27
+warning:3:30
~~~~~~~~~~
-$x = function ($y ) use ($z ) {
+<?php
+
+$x = function ($y) use ($z) {
return $y + $z;
};
diff --git a/src/lint/linter/xhpast/rules/__tests__/parentheses-spacing/function-call.lint-test b/src/lint/linter/xhpast/rules/__tests__/parentheses-spacing/function-call.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/parentheses-spacing/function-call.lint-test
@@ -0,0 +1,26 @@
+<?php
+
+some_func( $x, $y );
+some_other_func($x, $y);
+
+some_func(
+ $x,
+ <<<EOF
+This is a heredoc.
+EOF
+);
+~~~~~~~~~~
+warning:3:11
+warning:3:18
+~~~~~~~~~~
+<?php
+
+some_func($x, $y);
+some_other_func($x, $y);
+
+some_func(
+ $x,
+ <<<EOF
+This is a heredoc.
+EOF
+);
diff --git a/src/lint/linter/xhpast/rules/__tests__/parentheses-spacing/function.lint-test b/src/lint/linter/xhpast/rules/__tests__/parentheses-spacing/function.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/parentheses-spacing/function.lint-test
@@ -0,0 +1,12 @@
+<?php
+
+function some_func( $x, $y ) {}
+function some_other_func($x, $y) {}
+~~~~~~~~~~
+warning:3:20
+warning:3:27
+~~~~~~~~~~
+<?php
+
+function some_func($x, $y) {}
+function some_other_func($x, $y) {}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 6, 7:11 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8731529
Default Alt Text
D14616.id35359.diff (4 KB)
Attached To
Mode
D14616: Consolidate two linter rules
Attached
Detach File
Event Timeline
Log In to Comment