From: Joshua Spence Date: Wed, 7 Jan 2015 12:55:34 +0000 (+1100) Subject: Simplify version parsing for `ArcanistPhpLinter` X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=2ad2c04774e2ea28aacbfd81a0323362471b30bf;p=arcanist.git Simplify version parsing for `ArcanistPhpLinter` 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 --- diff --git a/src/lint/linter/ArcanistPhpLinter.php b/src/lint/linter/ArcanistPhpLinter.php index 5a0e4dc5..789e2e8d 100644 --- a/src/lint/linter/ArcanistPhpLinter.php +++ b/src/lint/linter/ArcanistPhpLinter.php @@ -39,15 +39,11 @@ final class ArcanistPhpLinter extends ArcanistExternalLinter { } public function getVersion() { - list($stdout) = execx('%C --version', $this->getExecutableCommand()); - - $matches = array(); - $regex = '/^PHP (?P\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() {