]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Warn against usage of nowdoc
authorvrana <jakubv@fb.com>
Sat, 19 Jan 2013 17:19:21 +0000 (09:19 -0800)
committervrana <jakubv@fb.com>
Sat, 19 Jan 2013 17:23:17 +0000 (09:23 -0800)
Summary: Also include binary hash in the version.

Test Plan: New unit test.

Reviewers: epriestley

Reviewed By: epriestley

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

src/lint/linter/ArcanistXHPASTLinter.php
src/lint/linter/__tests__/xhpast/nowdoc.lint-test [new file with mode: 0644]

index a65fdbe7f382922db5e961812ac29192a546a10a..b845f55ed01b62a7f28cef0bd1f0392879a3531d 100644 (file)
@@ -155,6 +155,10 @@ final class ArcanistXHPASTLinter extends ArcanistLinter {
     return idx($this->trees, $path);
   }
 
+  public function getCacheVersion() {
+    return '1-'.md5_file(xhpast_get_binary_path());
+  }
+
   public function lintPath($path) {
     if (empty($this->trees[$path])) {
       return;
@@ -393,6 +397,17 @@ final class ArcanistXHPASTLinter extends ArcanistLinter {
       }
     }
 
+    $heredocs = $root->selectDescendantsOfType('n_HEREDOC');
+    foreach ($heredocs as $heredoc) {
+      if (preg_match('/^<<<[\'"]/', $heredoc->getConcreteString())) {
+        $this->raiseLintAtNode(
+          $heredoc,
+          self::LINT_PHP_53_FEATURES,
+          'This codebase targets PHP 5.2, but nowdoc was not introduced until '.
+          'PHP 5.3.');
+      }
+    }
+
     $this->lintPHP53Functions($root);
   }
 
diff --git a/src/lint/linter/__tests__/xhpast/nowdoc.lint-test b/src/lint/linter/__tests__/xhpast/nowdoc.lint-test
new file mode 100644 (file)
index 0000000..de8f887
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+echo <<<'EOT'
+Hello World!
+EOT;
+~~~~~~~~~~
+disabled:2:6