From 699f3b3c05e2e49745a9a258c67414f65fe01b6b Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 10 Sep 2013 15:10:34 -0700 Subject: [PATCH] Fix an issue with PHPCS output formatting Summary: See . PHPCS changed its output format sometime between 1.4.6 (stable) and 1.5.0RC3. Add a "no errors" test and make the linter work on both versions. Test Plan: Ran `arc unit` on PHPCS 1.5.0RC3. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D6926 --- src/lint/linter/ArcanistPhpcsLinter.php | 7 +++++ .../__tests__/phpcs/no-errors.lint-test | 26 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/lint/linter/__tests__/phpcs/no-errors.lint-test diff --git a/src/lint/linter/ArcanistPhpcsLinter.php b/src/lint/linter/ArcanistPhpcsLinter.php index ace53f07..ff34a185 100644 --- a/src/lint/linter/ArcanistPhpcsLinter.php +++ b/src/lint/linter/ArcanistPhpcsLinter.php @@ -62,6 +62,13 @@ final class ArcanistPhpcsLinter extends ArcanistExternalLinter { } protected function parseLinterOutput($path, $err, $stdout, $stderr) { + // NOTE: Some version of PHPCS after 1.4.6 stopped printing a valid, empty + // XML document to stdout in the case of no errors. If PHPCS exits with + // error 0, just ignore output. + if (!$err) { + return array(); + } + $report_dom = new DOMDocument(); $ok = @$report_dom->loadXML($stdout); if (!$ok) { diff --git a/src/lint/linter/__tests__/phpcs/no-errors.lint-test b/src/lint/linter/__tests__/phpcs/no-errors.lint-test new file mode 100644 index 00000000..784acd68 --- /dev/null +++ b/src/lint/linter/__tests__/phpcs/no-errors.lint-test @@ -0,0 +1,26 @@ + + * @license Imaginary License http://www.example.com/LICENSE + * @version GIT: HEAD + * @link http://www.derp.com/ + */ + +/** + * A function. + * + * @return void + */ +function f() +{ + +} +~~~~~~~~~~ -- 2.43.0