Skip to content

Commit 83505e3

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into 2.4-develop-pr32
2 parents c57bfd2 + 9fa16c7 commit 83505e3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,20 @@ private function checkArgumentMismatch($phrase, &$incorrectNumberOfArgumentsErro
9999
{
100100
if (preg_match_all('/%(\w+)/', $phrase['phrase'], $matches) || $phrase['arguments']) {
101101
$placeholderCount = count(array_unique($matches[1]));
102+
// count all occurrences of sprintf placeholders
103+
preg_match_all('/%\b([sducoxXbgGeEfF])\b/', $phrase['phrase'], $sprintfMatches);
104+
if (count($sprintfMatches[0]) > count(array_unique($sprintfMatches[0]))) {
105+
$placeholderCount = $placeholderCount +
106+
count($sprintfMatches[0]) - count(array_unique($sprintfMatches[0]));
107+
}
102108

103-
// Check for zend placeholders %placeholder% and sprintf placeholder %s
104-
if (preg_match_all('/%((s)|([A-Za-z]+)%)/', $phrase['phrase'], $placeHolders, PREG_OFFSET_CAPTURE)) {
109+
// Check for zend placeholders %placeholder% and sprintf placeholders and remove from the count
110+
if (preg_match_all(
111+
'/%\b(([sducoxXbgGeEfF])\b|([A-Za-z]+)%)/',
112+
$phrase['phrase'],
113+
$placeHolders,
114+
PREG_OFFSET_CAPTURE
115+
)) {
105116
foreach ($placeHolders[0] as $ph) {
106117
// Check if char after placeholder is not a digit or letter
107118
$charAfterPh = $phrase['phrase'][$ph[1] + strlen($ph[0])];

0 commit comments

Comments
 (0)