Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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(__FUNCTION__, 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 62 to 94

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()];
            }
        elseif(
$param->isOptional() && isset($args[$param->getPosition()]))
            {
            
$value $args[$param->getPosition()];
            }
        elseif(
$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 19th March 2024 05:35 Europe/London time based on the source file dated 20th February 2024 17:10 Europe/London time.