What I want to achieve: when test() is called without any argument, I want that nested() function is called with default arguments.
UPD: Requirements:
- no copy-pasting default argument value from
nested()function - possibility to override
$arrargument value - UPD: function
test()have more than one argument (in this case, ...func_get_args() won't work) - actually, this is simplified problem. Imagine that there are several classes that have something like
test()method with default$arrparameter that callsnested()method of other class. I want to achieve thatnested()method is called with default parameters whentest()method is called with default parameters.
Is that possible?
<?php
function test(int $i = 0, array $arr = null)
{
nested($arr);
}
function nested(array $arr = [1,2,3])
{
var_dump($arr);
}
test();
test(5, [4,5,6]);
$arris NULL, and if so, callnested();…?