Page MenuHomePhabricator

D20146.id.diff
No OneTemporary

D20146.id.diff

diff --git a/src/lint/linter/__tests__/jshint/jshint.lint-test b/src/lint/linter/__tests__/jshint/jshint.lint-test
--- a/src/lint/linter/__tests__/jshint/jshint.lint-test
+++ b/src/lint/linter/__tests__/jshint/jshint.lint-test
@@ -9,4 +9,4 @@
~~~~~~~~~~
warning:3:8
error:7:1
-error:9:
+error:9:1
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
@@ -26,6 +26,7 @@
$whitelist = array(
'class' => array(),
'function' => array(),
+ 'constant' => array(),
);
$conditionals = $root->selectDescendantsOfType('n_IF');
@@ -51,6 +52,7 @@
case 'class_exists':
case 'function_exists':
case 'interface_exists':
+ case 'defined':
$type = null;
switch ($function_name) {
case 'class_exists':
@@ -64,6 +66,10 @@
case 'interface_exists':
$type = 'interface';
break;
+
+ case 'defined':
+ $type = 'constant';
+ break;
}
$params = $function->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
@@ -98,7 +104,6 @@
$min = idx($version, 'php.min');
$max = idx($version, 'php.max');
- // Check if whitelisted.
$whitelisted = false;
foreach (idx($whitelist['function'], $name, array()) as $range) {
if (array_intersect($range, array_keys($node->getTokens()))) {
@@ -178,18 +183,18 @@
$version = idx($compat_info['classes'], $name, $version);
$min = idx($version, 'php.min');
$max = idx($version, 'php.max');
- // Check if whitelisted.
- $whitelisted = false;
- foreach (idx($whitelist['class'], $name, array()) as $range) {
- if (array_intersect($range, array_keys($node->getTokens()))) {
- $whitelisted = true;
- break;
- }
- }
- if ($whitelisted) {
- continue;
+ $whitelisted = false;
+ foreach (idx($whitelist['class'], $name, array()) as $range) {
+ if (array_intersect($range, array_keys($node->getTokens()))) {
+ $whitelisted = true;
+ break;
}
+ }
+
+ if ($whitelisted) {
+ continue;
+ }
if ($min && version_compare($min, $this->version, '>')) {
$this->raiseLintAtNode(
@@ -225,6 +230,18 @@
$min = idx($version, 'php.min');
$max = idx($version, 'php.max');
+ $whitelisted = false;
+ foreach (idx($whitelist['constant'], $name, array()) as $range) {
+ if (array_intersect($range, array_keys($node->getTokens()))) {
+ $whitelisted = true;
+ break;
+ }
+ }
+
+ if ($whitelisted) {
+ continue;
+ }
+
if ($min && version_compare($min, $this->version, '>')) {
$this->raiseLintAtNode(
$node,

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 21, 11:12 PM (2 d, 4 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7716799
Default Alt Text
D20146.id.diff (3 KB)

Event Timeline