]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Merge PHT into dynamic string linter
authorvrana <jakubv@fb.com>
Tue, 12 Feb 2013 02:46:02 +0000 (18:46 -0800)
committervrana <jakubv@fb.com>
Tue, 12 Feb 2013 02:59:53 +0000 (18:59 -0800)
Test Plan: Existing unit test.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D4914

src/lint/linter/ArcanistPhutilXHPASTLinter.php
src/lint/linter/__tests__/phlxhp/pht.lint-test

index 636c836c719a773f6c8bb2de3d14015ca65fc215..bd98b3da2d730e04a268e435e8fdfaeb708b77a0 100644 (file)
@@ -5,7 +5,6 @@
  */
 final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
 
-  const LINT_PHT_WITH_DYNAMIC_STRING = 1;
   const LINT_ARRAY_COMBINE           = 2;
   const LINT_DEPRECATED_FUNCTION     = 3;
   const LINT_UNSAFE_DYNAMIC_STRING   = 4;
@@ -46,7 +45,6 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
 
   public function getLintNameMap() {
     return array(
-      self::LINT_PHT_WITH_DYNAMIC_STRING => 'Use of pht() on Dynamic String',
       self::LINT_ARRAY_COMBINE           => 'array_combine() Unreliable',
       self::LINT_DEPRECATED_FUNCTION     => 'Use of Deprecated Function',
       self::LINT_UNSAFE_DYNAMIC_STRING   => 'Unsafe Usage of Dynamic String',
@@ -82,42 +80,16 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
 
     $root = $tree->getRootNode();
 
-    $this->lintPHT($root);
     $this->lintArrayCombine($root);
     $this->lintUnsafeDynamicString($root);
     $this->lintDeprecatedFunctions($root);
   }
 
 
-  private function lintPHT($root) {
-    $calls = $root->selectDescendantsOfType('n_FUNCTION_CALL');
-    foreach ($calls as $call) {
-      $name = $call->getChildByIndex(0)->getConcreteString();
-      if (strcasecmp($name, 'pht') != 0) {
-        continue;
-      }
-
-      $parameters = $call->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
-      if (!$parameters->getChildren()) {
-        continue;
-      }
-
-      $identifier = $parameters->getChildByIndex(0);
-      if ($identifier->isConstantString()) {
-        continue;
-      }
-
-      $this->raiseLintAtNode(
-        $call,
-        self::LINT_PHT_WITH_DYNAMIC_STRING,
-        "The first parameter of pht() can be only a scalar string, ".
-          "otherwise it can't be extracted.");
-    }
-  }
-
-
   private function lintUnsafeDynamicString($root) {
     $safe = $this->dynamicStringFunctions + array(
+      'pht' => 0,
+
       'hsprintf' => 0,
 
       'csprintf' => 0,
index 31b1c45be6a0a7305ca17f10690106407df54c75..e1b85e5a99e08df27a86cfca9ab94d4a1facaa2b 100644 (file)
@@ -20,8 +20,8 @@ $a
 EOT
 );
 ~~~~~~~~~~
-error:5:1
-error:7:1
-error:8:1
-error:10:1
-error:18:1
+warning:5:1
+warning:7:1
+warning:8:1
+warning:10:1
+warning:18:1