]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Update xhpast linter rules for new function AST format
authorRichard van Velzen <rvanvelzen@experty.com>
Thu, 28 Apr 2016 14:59:50 +0000 (16:59 +0200)
committerRichard van Velzen <rvanvelzen@experty.com>
Fri, 29 Apr 2016 12:38:10 +0000 (14:38 +0200)
Summary: See D15678. A node containing a return type hint is added right before the statement body node. This updates all relevant linter rules to now retrieve the body from the correct index.

Test Plan: Ran `arc unit --everything`, inspected every single message to make sure all xhpast test cases succeeded. Also grepped for `getChildByIndex(5` and `getChildOfType(5`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15814

src/lint/linter/xhpast/rules/ArcanistAbstractMethodBodyXHPASTLinterRule.php
src/lint/linter/xhpast/rules/ArcanistInterfaceMethodBodyXHPASTLinterRule.php
src/lint/linter/xhpast/rules/ArcanistReusedAsIteratorXHPASTLinterRule.php
src/lint/linter/xhpast/rules/ArcanistReusedIteratorReferenceXHPASTLinterRule.php
src/lint/linter/xhpast/rules/ArcanistStaticThisXHPASTLinterRule.php
src/lint/linter/xhpast/rules/ArcanistToStringExceptionXHPASTLinterRule.php
src/lint/linter/xhpast/rules/ArcanistUndeclaredVariableXHPASTLinterRule.php
src/lint/linter/xhpast/rules/ArcanistUselessOverridingMethodXHPASTLinterRule.php

index 277e15e0757e03aef9832a7783e3f6dce51bda81..8c37ab43d38f25ec3744b6009012a3dc508fdae5 100644 (file)
@@ -14,7 +14,7 @@ final class ArcanistAbstractMethodBodyXHPASTLinterRule
 
     foreach ($methods as $method) {
       $modifiers = $this->getModifiers($method);
-      $body = $method->getChildByIndex(5);
+      $body = $method->getChildByIndex(6);
 
       if (idx($modifiers, 'abstract') && $body->getTypeName() != 'n_EMPTY') {
         $this->raiseLintAtNode(
index f4835d0b0ce6cd794f9c7da1cf39d13708c9f0bd..bf230be0bda751fe344f9ab262aa1d44309c7b82 100644 (file)
@@ -16,7 +16,7 @@ final class ArcanistInterfaceMethodBodyXHPASTLinterRule
       $methods = $interface->selectDescendantsOfType('n_METHOD_DECLARATION');
 
       foreach ($methods as $method) {
-        $body = $method->getChildByIndex(5);
+        $body = $method->getChildByIndex(6);
 
         if ($body->getTypeName() != 'n_EMPTY') {
           $this->raiseLintAtNode(
index 182edc69d08a48163810e67d971a8a5aea40e726..a1a4cc5247916bbcc4eb9b67b73a7e7d4a0ab771 100644 (file)
@@ -46,7 +46,7 @@ final class ArcanistReusedAsIteratorXHPASTLinterRule
         $vars[] = $var;
       }
 
-      $body = $def->getChildByIndex(5);
+      $body = $def->getChildByIndex(6);
       if ($body->getTypeName() === 'n_EMPTY') {
         // Abstract method declaration.
         continue;
index 6585143502e7e7302b3e095d6ea330031cd41a6f..fc6b8a6b4feb5c7c2b647bfd21dd23f86baa40ec 100644 (file)
@@ -31,7 +31,7 @@ final class ArcanistReusedIteratorReferenceXHPASTLinterRule
     ));
 
     foreach ($defs as $def) {
-      $body = $def->getChildByIndex(5);
+      $body = $def->getChildByIndex(6);
       if ($body->getTypeName() === 'n_EMPTY') {
         // Abstract method declaration.
         continue;
index 695d085857848aafe4aca3155065dacdcd0cfa18..e18c513515cdddf449d7d74e7653800a9e89867c 100644 (file)
@@ -40,7 +40,7 @@ final class ArcanistStaticThisXHPASTLinterRule
           continue;
         }
 
-        $body = $method->getChildOfType(5, 'n_STATEMENT_LIST');
+        $body = $method->getChildOfType(6, 'n_STATEMENT_LIST');
         $variables = $body->selectDescendantsOfType('n_VARIABLE');
 
         foreach ($variables as $variable) {
index ab0eba56bfd954f582ff6602fdea355e843923f7..315331ee97cb22244443d4ded252b84be2bdb07f 100644 (file)
@@ -21,7 +21,7 @@ final class ArcanistToStringExceptionXHPASTLinterRule
         continue;
       }
 
-      $statements = $method->getChildByIndex(5);
+      $statements = $method->getChildByIndex(6);
 
       if ($statements->getTypeName() != 'n_STATEMENT_LIST') {
         continue;
index 2a389e3407f317c138d4698584e922e028773c0f..b1f997e9f4a97c4dd2607f71839e2cc5dab05f73 100644 (file)
@@ -88,7 +88,7 @@ final class ArcanistUndeclaredVariableXHPASTLinterRule
         $vars[] = $var;
       }
 
-      $body = $def->getChildByIndex(5);
+      $body = $def->getChildByIndex(6);
       if ($body->getTypeName() === 'n_EMPTY') {
         // Abstract method declaration.
         continue;
index 475ed25f0c5c8d41c94d6a7c9ffe3dc9d17c2b33..add72ca8906ffb6d69108b06820500b0b97a1d56 100644 (file)
@@ -40,7 +40,7 @@ final class ArcanistUselessOverridingMethodXHPASTLinterRule
         $parameters[] = $parameter->getConcreteString();
       }
 
-      $statements = $method->getChildByIndex(5);
+      $statements = $method->getChildByIndex(6);
 
       if ($statements->getTypeName() != 'n_STATEMENT_LIST') {
         continue;