Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

debug_function_call()

Description

Debug called function and its arguments

The best way to use this function is to call it on the first line of a function definition:

function some_test($required, $num, $optional_bool = false)
{
debug_function_call("some_test", func_get_args());

echo "called some_test" . PHP_EOL;

return;
}

Parameters

ColumnTypeDefaultDescription
$name string The function name
$args array The "runtime" args

Return

boolean|void @see debug()

Location

include/debug_functions.php lines 63 to 105

Definition

 
function debug_function_call($name, array $args)
    {
    global 
$debug_log$debug_log_override;
    if(!
$debug_log && !$debug_log_override)
        {
        return 
false;
        }

    
$stringify = function($value)
        {
        if(
is_bool($value))
            {
            return (
$value "true" "false");
            }

        return 
str_replace(PHP_EOL""print_r($valuetrue));;
        };

    
$args_str "";
    
$fct = new ReflectionFunction($name);
    foreach(
$fct->getParameters() as $param)
        {
        
$value null;

        if(!
$param->isOptional() && isset($args[$param->getPosition()]))
            {
            
$value $args[$param->getPosition()];
            }
        else if(
$param->isOptional() && isset($args[$param->getPosition()]))
            {
            
$value $args[$param->getPosition()];
            }
        else if(
$param->isOptional() && $param->isDefaultValueAvailable())
            {
            
$value $param->getDefaultValue();
            }

        
$args_str .= sprintf("\$%s = %s, "$param->getName(), $stringify($value));
        }
    
$args_str rtrim($args_str", ");

    return 
debug("{$name}{$args_str} );");
    }

This article was last updated 15th July 2020 05:35 Europe/London time based on the source file dated 13th May 2020 09:11 Europe/London time.