Skip to content

Commit ace849c

Browse files
author
Enno Woortmann
committed
Fix sprintf arguments
1 parent 29d5956 commit ace849c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/Render.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -248,20 +248,22 @@ protected function indexControlStructure(
248248
return preg_replace_callback(
249249
'/\{%\s*(?<structure>' . $this->getControlStructureRegEx($structure, $additionalComponents) . ')/i',
250250
function (array $matches) use (&$structureDepthCounter, &$levelCounter, $additionalComponents): string {
251-
$index = sprintf('%s-%s-%s-', $matches[0]);
252-
253251
if (in_array($matches['structure'], $additionalComponents)) {
254-
return sprintf($index, $levelCounter[$structureDepthCounter - 1], ($structureDepthCounter - 1));
255-
}
256-
257-
if (!isset($levelCounter[$structureDepthCounter])) {
258-
$levelCounter[$structureDepthCounter] = 0;
252+
return sprintf(
253+
'%s-%s-%s-',
254+
$matches[0],
255+
$levelCounter[$structureDepthCounter - 1],
256+
($structureDepthCounter - 1)
257+
);
259258
}
260259

260+
$levelCounter[$structureDepthCounter] = $levelCounter[$structureDepthCounter] ?? 0;
261261
$isEndTag = strpos($matches['structure'], 'end') === 0;
262262
($isEndTag) ? --$structureDepthCounter : $levelCounter[$structureDepthCounter]++;
263+
263264
return sprintf(
264-
$index,
265+
'%s-%s-%s-',
266+
$matches[0],
265267
$levelCounter[$structureDepthCounter],
266268
($isEndTag ? $structureDepthCounter : $structureDepthCounter++)
267269
);

0 commit comments

Comments
 (0)