Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video 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 95

Definition

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

    
$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(), debug_stringify($value));
        }
    
$args_str rtrim($args_str", ");

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

This article was last updated 15th June 2021 14:05 Europe/London time based on the source file dated 10th May 2021 17:30 Europe/London time.