33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-12-28 12:30:44 +00:00

Mitigate error to a note for missed optional node

This commit is contained in:
Denis Ryabov 2021-04-04 14:29:53 +03:00
parent f914e438c5
commit 03f22df7d9
2 changed files with 24 additions and 15 deletions

View File

@ -85,6 +85,7 @@ COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED="Extension type '%s' is not accepted b
COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE="Node <%1$s> has unknown attribute '%2$s'"
COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN="Node <%s> has unknown child element"
COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED="Node <%1$s> doesn't contain required <%2$s> element"
COM_JEDCHECKER_MANIFEST_MISSED_OPTIONAL="Node <%1$s> doesn't contain optional <%2$s> element"
COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND="Node <%1$s> contains multiple <%2$s> elements"
COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node <%1$s> contains unknown <%2$s> element"
COM_JEDCHECKER_MANIFEST_EMPTY_CHILD="Found empty <%s> element"

View File

@ -289,25 +289,33 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
switch ($mode)
{
case '!':
$errors =& $this->errors;
if ($count === 0)
{
// The node doesn't contain required child element
$this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED', $name, $child);
}
elseif ($count > 1)
{
// The node contains multiple child elements when single only is expected
$this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
}
break;
case '=':
$errors =& $this->warnings;
if ($count === 0)
{
// The node doesn't contain optional child element
$this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_OPTIONAL', $name, $child);
}
elseif ($count > 1)
{
// The node contains multiple child elements when single only is expected
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
}
break;
default:
continue 2;
}
if ($count === 0)
{
$errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED', $name, $child);
}
elseif ($count > 1)
{
$errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
}
unset($errors);
}
// 2) check unknown/multiple elements