/** * This method parses the rule-set definition in the given file. * * @param string $fileName The filename of a rule-set definition. * * @return PHP_PMD_RuleSet */ private function parseRuleSetNode($fileName) { // Hide error messages $libxml = libxml_use_internal_errors(true); $xml = simplexml_load_file($fileName); if ($xml === false) { // Reset error handling to previous setting libxml_use_internal_errors($libxml); throw new RuntimeException(trim(libxml_get_last_error()->message)); } $ruleSet = new PHP_PMD_RuleSet(); $ruleSet->setFileName($fileName); $ruleSet->setName((string) $xml['name']); if ($this->strict) { $ruleSet->setStrict(); } foreach ($xml->children() as $node) { if ($node->getName() === 'description') { $ruleSet->setDescription((string) $node); } else { if ($node->getName() === 'rule') { $this->parseRuleNode($ruleSet, $node); } } } return $ruleSet; }