]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Simplify version parsing for `ArcanistPhpLinter`
authorJoshua Spence <josh@joshuaspence.com>
Wed, 7 Jan 2015 12:55:34 +0000 (23:55 +1100)
committerJoshua Spence <josh@joshuaspence.com>
Wed, 7 Jan 2015 12:55:34 +0000 (23:55 +1100)
Summary: We can use `php --run "echo phpversion();"` to return a nice, compact representation of the PHP version.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11264

src/lint/linter/ArcanistPhpLinter.php

index 5a0e4dc535860816e59032c9a548952095de0a26..789e2e8db92cacbe2417256c0de676df0c672ba2 100644 (file)
@@ -39,15 +39,11 @@ final class ArcanistPhpLinter extends ArcanistExternalLinter {
   }
 
   public function getVersion() {
-    list($stdout) = execx('%C --version', $this->getExecutableCommand());
-
-    $matches = array();
-    $regex = '/^PHP (?P<version>\d+\.\d+\.\d+)\b/';
-    if (preg_match($regex, $stdout, $matches)) {
-      return $matches['version'];
-    } else {
-      return false;
-    }
+    list($stdout) = execx(
+      '%C --run %s',
+      $this->getExecutableCommand(),
+      'echo phpversion();');
+    return $stdout;
   }
 
   public function shouldExpectCommandErrors() {