Skip to content

Commit 25626a4

Browse files
committed
minor #24613 Remove redundant sprintf argument. (Aliance)
This PR was merged into the 2.7 branch. Discussion ---------- Remove redundant sprintf argument. | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22820 | License | MIT | Doc PR | – cc @fabpot @ogizanagi Commits ------- c8012f0448 Remove redundant sprintf arguments.
2 parents d658242 + 05ba350 commit 25626a4

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

Extension/CodeExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function abbrMethod($method)
6868
list($class, $method) = explode('::', $method, 2);
6969
$result = sprintf('%s::%s()', $this->abbrClass($class), $method);
7070
} elseif ('Closure' === $method) {
71-
$result = sprintf('<abbr title="%s">%s</abbr>', $method, $method);
71+
$result = sprintf('<abbr title="%s">%1$s</abbr>', $method);
7272
} else {
73-
$result = sprintf('<abbr title="%s">%s</abbr>()', $method, $method);
73+
$result = sprintf('<abbr title="%s">%1$s</abbr>()', $method);
7474
}
7575

7676
return $result;

Tests/Node/FormThemeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public function testCompile()
7474
protected function getVariableGetter($name)
7575
{
7676
if (\PHP_VERSION_ID >= 70000) {
77-
return sprintf('($context["%s"] ?? null)', $name, $name);
77+
return sprintf('($context["%s"] ?? null)', $name);
7878
}
7979

8080
if (\PHP_VERSION_ID >= 50400) {
81-
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
81+
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name);
8282
}
8383

8484
return sprintf('$this->getContext($context, "%s")', $name);

Tests/Node/SearchAndRenderBlockNodeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
272272
protected function getVariableGetter($name)
273273
{
274274
if (\PHP_VERSION_ID >= 70000) {
275-
return sprintf('($context["%s"] ?? null)', $name, $name);
275+
return sprintf('($context["%s"] ?? null)', $name);
276276
}
277277

278278
if (\PHP_VERSION_ID >= 50400) {
279-
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
279+
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name);
280280
}
281281

282282
return sprintf('$this->getContext($context, "%s")', $name);

Tests/Node/TransNodeTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public function testCompileStrict()
4545
protected function getVariableGetterWithoutStrictCheck($name)
4646
{
4747
if (\PHP_VERSION_ID >= 70000) {
48-
return sprintf('($context["%s"] ?? null)', $name, $name);
48+
return sprintf('($context["%s"] ?? null)', $name);
4949
}
5050

5151
if (\PHP_VERSION_ID >= 50400) {
52-
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
52+
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name);
5353
}
5454

5555
return sprintf('$this->getContext($context, "%s", true)', $name);
@@ -58,15 +58,15 @@ protected function getVariableGetterWithoutStrictCheck($name)
5858
protected function getVariableGetterWithStrictCheck($name)
5959
{
6060
if (Environment::MAJOR_VERSION >= 2) {
61-
return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%s" does not exist.\', 0, $this->getSourceContext()); })())', $name, $name, $name, $name);
61+
return sprintf('(isset($context["%s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%1$s" does not exist.\', 0, $this->getSourceContext()); })())', $name);
6262
}
6363

6464
if (\PHP_VERSION_ID >= 70000) {
65-
return sprintf('($context["%s"] ?? $this->getContext($context, "%s"))', $name, $name, $name);
65+
return sprintf('($context["%s"] ?? $this->getContext($context, "%1$s"))', $name);
6666
}
6767

6868
if (\PHP_VERSION_ID >= 50400) {
69-
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
69+
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : $this->getContext($context, "%1$s"))', $name);
7070
}
7171

7272
return sprintf('$this->getContext($context, "%s")', $name);

0 commit comments

Comments
 (0)