Page MenuHomePhabricator

D13895.id33641.diff
No OneTemporary

D13895.id33641.diff

diff --git a/src/lint/linter/__tests__/xhpast/array-formatting.lint-test b/src/lint/linter/__tests__/xhpast/array-formatting.lint-test
--- a/src/lint/linter/__tests__/xhpast/array-formatting.lint-test
+++ b/src/lint/linter/__tests__/xhpast/array-formatting.lint-test
@@ -2,6 +2,7 @@
array ( 1, 2, 3 );
list ( $x, $y ) = array();
+[ 1, 2 , 3 ];
~~~~~~~~~~
warning:3:6
warning:3:8
@@ -9,8 +10,11 @@
warning:4:5
warning:4:7
warning:4:14
+warning:5:2
+warning:5:11
~~~~~~~~~~
<?php
array(1, 2, 3);
list($x, $y) = array();
+[1, 2 , 3];
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
@@ -24,6 +24,11 @@
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;
@@ -44,6 +49,7 @@
$tokens = $params->getTokens();
$first = head($tokens);
+
$leading = $first->getNonsemanticTokensBefore();
$leading_text = implode('', mpull($leading, 'getValue'));
if (preg_match('/^\s+$/', $leading_text)) {
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
@@ -29,12 +29,6 @@
$token_o = array_shift($tokens);
$token_c = array_pop($tokens);
- if ($token_o->getTypeName() !== '(') {
- throw new Exception(pht('Expected open parentheses.'));
- }
- if ($token_c->getTypeName() !== ')') {
- throw new Exception(pht('Expected close parentheses.'));
- }
$nonsem_o = $token_o->getNonsemanticTokensAfter();
$nonsem_c = $token_c->getNonsemanticTokensBefore();

File Metadata

Mime Type
text/plain
Expires
Fri, Oct 11, 5:09 PM (21 h, 49 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6695033
Default Alt Text
D13895.id33641.diff (2 KB)

Event Timeline