Note that there are some explanatory texts on larger screens.

plurals
  1. POcall_user_func_array error parsing objects
    primarykey
    data
    text
    <p>Hello i have the following piece of code and i'm having the following error: Any ideas how to do it?</p> <pre><code>Argument 1 passed to Invoice\Invoice::__construct() must be an instance of Invoice\Data, none given, called in /Template.php on line 55 and defined if(!empty($this-&gt;class1) &amp;&amp; !empty($this-&gt;class2)) { if(!empty($this-&gt;params)) call_user_func_array(array(new $this-&gt;class(new $this-&gt;class1, new $this-&gt;class2), $this-&gt;method), $this-&gt;params); else call_user_func(new $this-&gt;class(new $this-&gt;class1, new $this-&gt;class2), $this-&gt;method); // line 55 } else { if(!empty($this-&gt;params)) call_user_func_array(array(new $this-&gt;class, $this-&gt;method), $this-&gt;params); else call_user_func(array(new $this-&gt;class, $this-&gt;method)); } </code></pre> <p>New Update On Code:</p> <pre><code>if(!empty($this-&gt;model) &amp;&amp; !empty($this-&gt;view)) { if(!empty($this-&gt;params)) { call_user_func_array(array(new $this-&gt;view(new $this-&gt;controller, new $this-&gt;model), $this-&gt;action), $this-&gt;params); } else { call_user_func(new $this-&gt;view(new $this-&gt;controller(new $this-&gt;model), new $this-&gt;model), $this-&gt;action); } } else { if(!empty($this-&gt;params)) { call_user_func_array(array(new $this-&gt;controller, $this-&gt;action), $this-&gt;params); } else { call_user_func(array(new $this-&gt;controller, $this-&gt;action)); } } </code></pre> <p>I'm using <a href="http://php.net/manual/en/language.oop5.typehinting.php" rel="nofollow">Type Hinting</a> insde of controller model and view and parsing the right args to each of the vars in the above code and defined the right type hints in each of the classes. What i want to achieve with the above code is:</p> <pre><code>$model = new Model(); $controller = new Controller($model); $view = new View($controller, $model); </code></pre> <p>Error I'm Having:</p> <pre><code>call_user_func() expects parameter 1 to be a valid callback, no array or string given </code></pre> <p>Update Forgot to post the exact line where i'm having that error</p> <pre><code>call_user_func(new $this-&gt;view(new $this-&gt;controller(new $this-&gt;model), new $this-&gt;model), $this-&gt;action); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload