mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-18 21:37:29 +00:00
modified code to use variadics when possible
This commit is contained in:
@@ -103,9 +103,8 @@ class Twig_Compiler
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function write()
|
public function write(... $strings)
|
||||||
{
|
{
|
||||||
$strings = func_get_args();
|
|
||||||
foreach ($strings as $string) {
|
foreach ($strings as $string) {
|
||||||
$this->source .= str_repeat(' ', $this->indentation * 4).$string;
|
$this->source .= str_repeat(' ', $this->indentation * 4).$string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()) {
|
if (!$env->isDebug()) {
|
||||||
return;
|
return;
|
||||||
@@ -37,8 +37,7 @@ function twig_var_dump(Twig_Environment $env, $context)
|
|||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
$count = func_num_args();
|
if (!$vars) {
|
||||||
if (2 === $count) {
|
|
||||||
$vars = array();
|
$vars = array();
|
||||||
foreach ($context as $key => $value) {
|
foreach ($context as $key => $value) {
|
||||||
if (!$value instanceof Twig_Template) {
|
if (!$value instanceof Twig_Template) {
|
||||||
@@ -48,9 +47,7 @@ function twig_var_dump(Twig_Environment $env, $context)
|
|||||||
|
|
||||||
var_dump($vars);
|
var_dump($vars);
|
||||||
} else {
|
} else {
|
||||||
for ($i = 2; $i < $count; ++$i) {
|
var_dump(...$vars);
|
||||||
var_dump(func_get_arg($i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
|
|||||||
Reference in New Issue
Block a user