From 78017033bd8e470a931847062d8ce7a5236c7715 Mon Sep 17 00:00:00 2001 From: vrana Date: Sat, 19 Jan 2013 09:19:21 -0800 Subject: [PATCH] Warn against usage of nowdoc 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 | 15 +++++++++++++++ src/lint/linter/__tests__/xhpast/nowdoc.lint-test | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 src/lint/linter/__tests__/xhpast/nowdoc.lint-test diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index a65fdbe7..b845f55e 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -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 index 00000000..de8f8878 --- /dev/null +++ b/src/lint/linter/__tests__/xhpast/nowdoc.lint-test @@ -0,0 +1,6 @@ +