]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Move `isConstantString()` to base class
authorvrana <jakubv@fb.com>
Wed, 30 Jan 2013 20:24:41 +0000 (12:24 -0800)
committervrana <jakubv@fb.com>
Wed, 30 Jan 2013 20:56:59 +0000 (12:56 -0800)
Summary: This can be useful by itself, we want to use it in FB linter.

Test Plan: This diff.

Reviewers: epriestley

Reviewed By: epriestley

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

src/lint/linter/ArcanistPhutilXHPASTLinter.php

index 49cffbc15cce267518a533c3b9974b71b761925d..09ff2249c074f33e1729b99cadc9f59f392929f4 100644 (file)
@@ -72,7 +72,7 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
       }
 
       $identifier = $parameters->getChildByIndex(0);
-      if ($this->isConstantString($identifier)) {
+      if ($identifier->isConstantString()) {
         continue;
       }
 
@@ -84,42 +84,6 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
     }
   }
 
-  private function isConstantString(XHPASTNode $node) {
-    $value = $node->getConcreteString();
-
-    switch ($node->getTypeName()) {
-      case 'n_HEREDOC':
-        if ($value[3] == "'") { // Nowdoc: <<<'EOT'
-          return true;
-        }
-        $value = preg_replace('/^.+\n|\n.*$/', '', $value);
-        break;
-
-      case 'n_STRING_SCALAR':
-        if ($value[0] == "'") {
-          return true;
-        }
-        $value = substr($value, 1, -1);
-        break;
-
-      case 'n_CONCATENATION_LIST':
-        foreach ($node->getChildren() as $child) {
-          if ($child->getTypeName() == 'n_OPERATOR') {
-            continue;
-          }
-          if (!$this->isConstantString($child)) {
-            return false;
-          }
-        }
-        return true;
-
-      default:
-        return false;
-    }
-
-    return preg_match('/^((?>[^$\\\\]*)|\\\\.)*$/s', $value);
-  }
-
 
   private function lintArrayCombine($root) {
     $function_calls = $root->selectDescendantsOfType('n_FUNCTION_CALL');