diff --git a/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php --- a/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php +++ b/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php @@ -369,6 +369,19 @@ } } + $literals = $root->selectDescendantsOftype('n_ARRAY_LITERAL'); + foreach ($literals as $literal) { + $open_token = head($literal->getTokens())->getValue(); + if ($open_token == '[') { + $this->raiseLintAtNode( + $literal, + pht( + 'The short array syntax ("[...]") was not introduced until '. + 'PHP 5.4, but this codebase targets an earlier version of PHP. '. + 'You can rewrite this expression using `array(...)` instead.')); + } + } + $closures = $this->getAnonymousClosures($root); foreach ($closures as $closure) { $static_accesses = $closure diff --git a/src/lint/linter/xhpast/rules/__tests__/php-compatibility/php54-features.lint-test b/src/lint/linter/xhpast/rules/__tests__/php-compatibility/php54-features.lint-test --- a/src/lint/linter/xhpast/rules/__tests__/php-compatibility/php54-features.lint-test +++ b/src/lint/linter/xhpast/rules/__tests__/php-compatibility/php54-features.lint-test @@ -22,12 +22,15 @@ 0b1; +[]; + ~~~~~~~~~~ error:3:5 error:4:9 error:12:7 error:18:7 error:23:1 +error:25:1 ~~~~~~~~~~ ~~~~~~~~~~ {