From 21ccdefc4aea4c2439f7d41ece7d8216d8ba8b40 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 3 Feb 2021 10:30:22 +0100 Subject: Code cleanup: Switch to new style varargs --- auto_prepend.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'auto_prepend.php') diff --git a/auto_prepend.php b/auto_prepend.php index 0aa70ef..f05a4c2 100644 --- a/auto_prepend.php +++ b/auto_prepend.php @@ -5,18 +5,16 @@ /** * Return string containing names and values of all arguments */ -function D() +function D(...$args) { - $args = func_get_args(); return it_debug::dump($args); } /** * Echo string containing names and values of all arguments */ -function ED() +function ED(...$args) { - $args = func_get_args(); if (ob_get_level() == 0 && $_SERVER['REMOTE_ADDR']) ob_start(); # prevent later 'headers already sent' error $GLOBALS['debug_noredir'] = 1; @@ -28,15 +26,12 @@ function ED() * Same as ED(), but if first argument is foo then $GLOBALS['debug_foo'] must be set for output * @return boolean indicating whether $GLOBALS['debug_foo'] was set */ -function EDC($var) +function EDC($var, ...$args) { $GLOBALS['ULTRADEBUGVARS'][$var] = 1; if (($result = $GLOBALS["debug_$var"])) { - $args = func_get_args(); - array_shift($args); # remove $var - if ($args) { if (ob_get_level() == 0 && $_SERVER['REMOTE_ADDR']) @@ -54,9 +49,8 @@ function EDC($var) /** * Echo string containing names and values of all arguments, then exit */ -function EDX() +function EDX(...$args) { - $args = func_get_args(); if ($_SERVER['REMOTE_ADDR'] && !headers_sent()) header("Content-Type: text/html"); # Not going to be e.g. a valid gif anyway @@ -155,10 +149,9 @@ function T_exists($label, $language = null) /** * Build an url */ -function U(/* ... */) +function U(...$args) { - $args = func_get_args(); - return call_user_func_array(array(is_a($o = $GLOBALS['it_html'], 'it_html') ? $o : 'it_html', 'U'), $args); + return is_a($obj = $GLOBALS['it_html'], 'it_html') ? $obj->U(...$args) : it_html::U(...$args); } -- cgit v1.2.3