31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-06-04 22:40:48 +00:00

parse multiline values

This commit is contained in:
Denis Ryabov 2021-02-23 23:41:30 +03:00
parent ab4acc2bba
commit 2e54c9fc7e
2 changed files with 14 additions and 0 deletions

View File

@ -87,6 +87,7 @@ COM_JEDCHECKER_LANG_KEY_EMPTY="Empty key name"
COM_JEDCHECKER_LANG_KEY_WHITESPACE="Whitespace in the key is not allowed"
COM_JEDCHECKER_LANG_KEY_INVALID_CHARACTER="Incorrect character in the key name"
COM_JEDCHECKER_LANG_KEY_RESERVED="Reserved keyword in the key name"
COM_JEDCHECKER_LANG_TRANSLATION_ERROR="Incorrect translation string"
COM_JEDCHECKER_LANG_TRANSLATION_QUOTES="All translation strings should be in double quotation marks"
COM_JEDCHECKER_LANG_TRANSLATION_EMPTY="Empty translation string"
COM_JEDCHECKER_LANG_QQ_DEPRECATED="Usage of \"_QQ_\" is deprecated since Joomla! 3.9. Use escaped double quotes (\\\") instead"

View File

@ -145,6 +145,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
continue;
}
$value = trim($matches[1]);
// Check for empty value
if ($value === '""')
{
@ -152,6 +153,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
continue;
}
if (strlen($value) < 2 || $value[0] !== '"' || substr($value, -1) !== '"')
// Remove quotes around
$value = substr($value, 1, -1);
@ -160,6 +162,17 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
{
$this->report->addInfo($file, JText::_('COM_JEDCHECKER_LANG_QQ_DEPRECATED'), $lineno, $line);
}
// Count %... formats in the string
$count1 = preg_match_all('/(?<=^|[^%])%(?=[-+0 ]?\w)/', $value);
// Count %n$... (argnum) formats in the string
$count2 = preg_match_all('/(?<=^|[^%])%\d+\$/', $value);
if ($count1 > 1 && $count2 < $count1) {
// @todo It's not mentioned in docs
$this->report->addInfo($file, JText::_('COM_JEDCHECKER_LANG_RECOMMEND_ARGNUM'), $startLineno, $line);
}
}
// All checks passed. Return true