From 2ad2c04774e2ea28aacbfd81a0323362471b30bf Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Wed, 7 Jan 2015 23:55:34 +1100 Subject: [PATCH] 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 --- src/lint/linter/ArcanistPhpLinter.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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() { -- 2.43.0