diff --git a/src/Ruleset.php b/src/Ruleset.php index a50dde2a95..b20618686c 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -315,11 +315,21 @@ public function processRuleset($rulesetPath, $depth=0) echo 'Processing ruleset '.Util\Common::stripBasepath($rulesetPath, $this->config->basepath).PHP_EOL; } - $ruleset = @simplexml_load_string(file_get_contents($rulesetPath)); + libxml_use_internal_errors(true); + $ruleset = simplexml_load_string(file_get_contents($rulesetPath)); if ($ruleset === false) { - throw new RuntimeException("Ruleset $rulesetPath is not valid"); + $errorMsg = "Ruleset $rulesetPath is not valid".PHP_EOL; + $errors = libxml_get_errors(); + foreach ($errors as $error) { + $errorMsg .= '- On line '.$error->line.', column '.$error->column.': '.$error->message; + } + + libxml_clear_errors(); + throw new RuntimeException($errorMsg); } + libxml_use_internal_errors(false); + $ownSniffs = []; $includedSniffs = []; $excludedSniffs = []; diff --git a/src/Util/Standards.php b/src/Util/Standards.php index e38d0b327e..a5436c2594 100644 --- a/src/Util/Standards.php +++ b/src/Util/Standards.php @@ -116,7 +116,7 @@ public static function getInstalledStandardDetails( $installedStandards = []; foreach ($rulesets as $rulesetPath) { - $ruleset = simplexml_load_string(file_get_contents($rulesetPath)); + $ruleset = @simplexml_load_string(file_get_contents($rulesetPath)); if ($ruleset === false) { continue; }