Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 84 to 116

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 13th December 2024 20:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.