Skip to content

Commit

Permalink
Merge pull request #5644 from magento-obsessive-owls/B2B-582
Browse files Browse the repository at this point in the history
[Owls] B2B-582
  • Loading branch information
cspruiell authored May 12, 2020
2 parents 0423eae + c578524 commit 9fa16c7
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,20 @@ private function checkArgumentMismatch($phrase, &$incorrectNumberOfArgumentsErro
{
if (preg_match_all('/%(\w+)/', $phrase['phrase'], $matches) || $phrase['arguments']) {
$placeholderCount = count(array_unique($matches[1]));
// count all occurrences of sprintf placeholders
preg_match_all('/%\b([sducoxXbgGeEfF])\b/', $phrase['phrase'], $sprintfMatches);
if (count($sprintfMatches[0]) > count(array_unique($sprintfMatches[0]))) {
$placeholderCount = $placeholderCount +
count($sprintfMatches[0]) - count(array_unique($sprintfMatches[0]));
}

// Check for zend placeholders %placeholder% and sprintf placeholder %s
if (preg_match_all('/%((s)|([A-Za-z]+)%)/', $phrase['phrase'], $placeHolders, PREG_OFFSET_CAPTURE)) {
// Check for zend placeholders %placeholder% and sprintf placeholders and remove from the count
if (preg_match_all(
'/%\b(([sducoxXbgGeEfF])\b|([A-Za-z]+)%)/',
$phrase['phrase'],
$placeHolders,
PREG_OFFSET_CAPTURE
)) {
foreach ($placeHolders[0] as $ph) {
// Check if char after placeholder is not a digit or letter
$charAfterPh = $phrase['phrase'][$ph[1] + strlen($ph[0])];
Expand Down

0 comments on commit 9fa16c7

Please sign in to comment.