From 3de9e4aaea616f21f38421a0a9d09ca76f883438 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Thu, 10 Jul 2014 11:48:45 +1000 Subject: [PATCH] Allow the `ArcanistPhutilLibraryLinter` to recover from PHP syntax errors Summary: Fixes T5577. If the `ArcanistPhutilLibraryLinter` lints a PHP file that contains a syntax error, it will die horribly. Instead, force it to continue as if nothing was wrong. Test Plan: Introduced a PHP syntax error. Ran `arc lint` and made sure the output looked reasonable. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T5577 Differential Revision: https://secure.phabricator.com/D9865 --- src/lint/linter/ArcanistPhutilLibraryLinter.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lint/linter/ArcanistPhutilLibraryLinter.php b/src/lint/linter/ArcanistPhutilLibraryLinter.php index f0ea99d6..c127eee5 100644 --- a/src/lint/linter/ArcanistPhutilLibraryLinter.php +++ b/src/lint/linter/ArcanistPhutilLibraryLinter.php @@ -64,7 +64,14 @@ final class ArcanistPhutilLibraryLinter extends ArcanistLinter { $symbols = array(); foreach ($libs as $lib) { $root = phutil_get_library_root($lib); - $symbols[$lib] = id(new PhutilLibraryMapBuilder($root))->buildMap(); + + try { + $symbols[$lib] = id(new PhutilLibraryMapBuilder($root))->buildMap(); + } catch (XHPASTSyntaxErrorException $ex) { + // If the library contains a syntax error then there isn't much that we + // can do. + continue; + } } $all_symbols = array();