From 7c3c1e88bd7e1040bbe951e4f670e5f0be1561f6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 17 Jun 2012 09:01:47 -0700 Subject: [PATCH] Add test for "static::" to the PHP 5.3 linter Summary: See https://github.com/facebook/phabricator/issues/133. Test Plan: Unit tests. Reviewers: vrana Reviewed By: vrana CC: aran Maniphest Tasks: T1158 Differential Revision: https://secure.phabricator.com/D2778 --- src/lint/linter/ArcanistXHPASTLinter.php | 13 +++++++++++++ src/lint/linter/__tests__/xhpast/php53.lint-test | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index 6d211a72..9a490997 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -249,6 +249,19 @@ final class ArcanistXHPASTLinter extends ArcanistLinter { 'This codebase targets PHP 5.2, but namespaces were not introduced '. 'until PHP 5.3.'); } + + $statics = $root->selectDescendantsOfType('n_CLASS_STATIC_ACCESS'); + foreach ($statics as $static) { + $name = $static->getChildOfType(0, 'n_CLASS_NAME'); + if ($name->getConcreteString() == 'static') { + $this->raiseLintAtNode( + $name, + self::LINT_PHP_53_FEATURES, + 'This codebase targets PHP 5.2, but `static::` was not introduced '. + 'until PHP 5.3.'); + } + } + } private function lintImplicitFallthrough($root) { diff --git a/src/lint/linter/__tests__/xhpast/php53.lint-test b/src/lint/linter/__tests__/xhpast/php53.lint-test index 8622b9ac..cfe8254a 100644 --- a/src/lint/linter/__tests__/xhpast/php53.lint-test +++ b/src/lint/linter/__tests__/xhpast/php53.lint-test @@ -5,9 +5,11 @@ use b, c; f(function() {}); g(function() use ($c) {}); h(function /* ! */ () use ($c) {}); +static::m(); ~~~~~~~~~~ disabled:3:1 disabled:4:5 disabled:5:3 disabled:6:3 disabled:7:3 +disabled:8:1 \ No newline at end of file