modified code to use variadics when possible

This commit is contained in:
Fabien Potencier
2016-12-23 08:53:30 +01:00
parent 0f398a3463
commit a002d591f7
2 changed files with 4 additions and 8 deletions
+1 -2
View File
@@ -103,9 +103,8 @@ class Twig_Compiler
*
* @return $this
*/
public function write()
public function write(... $strings)
{
$strings = func_get_args();
foreach ($strings as $string) {
$this->source .= str_repeat(' ', $this->indentation * 4).$string;
}
+3 -6
View File
@@ -29,7 +29,7 @@ final class Twig_Extension_Debug extends Twig_Extension
}
}
function twig_var_dump(Twig_Environment $env, $context)
function twig_var_dump(Twig_Environment $env, $context, ...$vars)
{
if (!$env->isDebug()) {
return;
@@ -37,8 +37,7 @@ function twig_var_dump(Twig_Environment $env, $context)
ob_start();
$count = func_num_args();
if (2 === $count) {
if (!$vars) {
$vars = array();
foreach ($context as $key => $value) {
if (!$value instanceof Twig_Template) {
@@ -48,9 +47,7 @@ function twig_var_dump(Twig_Environment $env, $context)
var_dump($vars);
} else {
for ($i = 2; $i < $count; ++$i) {
var_dump(func_get_arg($i));
}
var_dump(...$vars);
}
return ob_get_clean();