]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add test for "static::" to the PHP 5.3 linter
authorepriestley <git@epriestley.com>
Sun, 17 Jun 2012 16:01:47 +0000 (09:01 -0700)
committerepriestley <git@epriestley.com>
Sun, 17 Jun 2012 16:01:47 +0000 (09:01 -0700)
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
src/lint/linter/__tests__/xhpast/php53.lint-test

index 6d211a72a81560561953dd15111ef6acc439deb7..9a490997afdf66b48917eac487c68e9b8a01caae 100644 (file)
@@ -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) {
index 8622b9ac79fbd5e56f5516bc478ddb7eefd82fbf..cfe8254a80d747aa4a06c7ee4d2897af1b847f18 100644 (file)
@@ -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