Bad PHP code. Please help to improve
<p>Clearly this is really poor code, but I can't think how to improve it. The 'test' function can't be changed at all, but all the rest can.</p>

<p>I want to pass an array of values to one function that actions the test function. The key thing is I need to make use of all pre-defined function variable values in the test function without redeclaring them.</p>

<p>I can't action the test function directly, it must go through another function.</p>

<p>This is just a demo of a much bigger problem, but solving this will definitely solve my problem. If it can't be done I need to completely re-think many things.</p>

<pre><code>function test($p1, $p2="hello", $p3=5, $p4=true) {

}
</code></pre>

<p>--</p>

<pre><code>function action($vars = array()) {

    $count = count($vars);

    switch($count) {

        case 1:
            $result = test($vars[0]);
            break;
        case 2:
            $result = test($vars[0], $vars[1]);
            break;
        case 3:
            $result = test($vars[0], $vars[1], $vars[2]);
            break;
        case 4:
            $result = test($vars[0], $vars[1], $vars[2], $vars[3]);
            break;

    }

    return $result;

}
</code></pre>

<p>--</p>

<pre><code>action(array(1, "test"));
</code></pre>
