Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15422905
D16357.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D16357.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D16357: Add a lint error about use of PHP short array syntax ('[...]')
Attached
Detach File
Event Timeline
Log In to Comment