Page MenuHomePhabricator

D16357.diff
No OneTemporary

D16357.diff

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
~~~~~~~~~~
~~~~~~~~~~
{

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 23, 11:10 AM (2 d, 23 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7715704
Default Alt Text
D16357.diff (1 KB)

Event Timeline