using __call() to pass parameters to a method that takes more than one but not as an array
<p>I have created a __call() method to load methods dynamically. One problem I want to work around is the fact that the __call() makes an array of all the parameters passed from the call. this is my code</p>

<pre><code>public function __call($method, $params)
{
    if (count($params) &lt;= 1)
            $params = $params[0];

    foreach (get_object_vars($this) as $property =&gt; $value) {

        $class = '\\System\\' . ucfirst(str_replace('_', '', $property)) . '_Helper';

        if (strpos($method, str_replace('_', '', $property)) !== false) {

            if (!in_array($class, get_declared_classes()))
                $this-&gt;$property = new $class($params);

            $error = $method . ' doesn\'t exist in class ' . $class;

            return (method_exists($class, $method) ? $this-&gt;$property-&gt;$method($params) : $error);
        }
    }
}
</code></pre>

<p>the issue is that i can account for the array only having one parameter, but some of my methods take in more than one parameter which limits the dynamic nature of the __call() method.</p>

<p>how can I convert an array into a dynamically passed method parameter?</p>

<p>so</p>

<pre><code>array(0 =&gt; 'stuff1', 1 =&gt; 'stuff2');
</code></pre>

<p>can passed as</p>

<pre><code>$this-&gt;-&gt;helper-&gt;test($param1, $param2);
</code></pre>

<p>instead of</p>

<pre><code>$this-&gt;helper-&gt;test($params);
</code></pre>

<p>with the current design I need to access parameters like</p>

<pre><code>public function test($params)
{
    print_r($params);
    echo $param[0];
}
</code></pre>

<p>but I want the use it in a traditional manner like</p>

<pre><code>public function test($param1, $param2)
{
    echo $para1 . " " . $param2;
}
</code></pre>

<p>keeping in mind that some methods take more than 2 parameters, the reason being is that if i include traditional style class methods not created by me I would need to convert all the parameter calls into a array index pointer.</p>

<p>EDIT:</p>

<p>as per an answer</p>

<pre><code>return (method_exists($class, $method) ? call_user_func_array(array($this-&gt;$property, $method), $params) : $error);
</code></pre>

<p>will this work?</p>
