31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-06-25 23:52:34 +00:00

change unknown children and attribute to just an info-level message

This commit is contained in:
Denis Ryabov 2021-04-04 14:19:14 +03:00
parent ae251b5d5b
commit 49b383514e

View File

@ -58,6 +58,13 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
*/ */
protected $warnings; protected $warnings;
/**
* List of infos.
*
* @var string[]
*/
protected $infos;
/** /**
* Rules for XML nodes * Rules for XML nodes
* ? - single, optional * ? - single, optional
@ -153,6 +160,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
$this->errors = array(); $this->errors = array();
$this->warnings = array(); $this->warnings = array();
$this->infos = array();
// Validate manifest // Validate manifest
$this->validateXml($xml, 'extension'); $this->validateXml($xml, 'extension');
@ -167,6 +175,11 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
$this->report->addWarning($file, implode('<br />', $this->warnings)); $this->report->addWarning($file, implode('<br />', $this->warnings));
} }
if (count($this->infos))
{
$this->report->addInfo($file, implode('<br />', $this->infos));
}
// All checks passed. Return true // All checks passed. Return true
return true; return true;
} }
@ -186,12 +199,12 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
{ {
foreach ($node->attributes() as $attr) foreach ($node->attributes() as $attr)
{ {
$attrName = (string)$attr->getName(); $attrName = (string) $attr->getName();
if (!in_array($attrName, $DTDattributes, true)) if (!in_array($attrName, $DTDattributes, true))
{ {
// The node has unknown attribute // The node has unknown attribute
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attrName); $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attrName);
} }
} }
} }
@ -202,7 +215,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
// No children // No children
if ($node->count() > 0) if ($node->count() > 0)
{ {
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name); $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name);
} }
} }
elseif (!isset($this->DTDNodeRules[$name]['*'])) elseif (!isset($this->DTDNodeRules[$name]['*']))
@ -248,13 +261,14 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
{ {
$childNames[$child->getName()] = 1; $childNames[$child->getName()] = 1;
} }
$childNames = array_keys($childNames); $childNames = array_keys($childNames);
foreach ($childNames as $child) foreach ($childNames as $child)
{ {
if (!isset($DTDchildren[$child])) if (!isset($DTDchildren[$child]))
{ {
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD', $name, $child); $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD', $name, $child);
} }
else else
{ {
@ -287,6 +301,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
} }
/** /**
* Extra check for menu nodes
* @param SimpleXMLElement $node XML node * @param SimpleXMLElement $node XML node
* *
* @return void * @return void