PHP - Method with parameters as a parameter to other method <p>I am trying to get result from this method (1st param is the service name, 2nd is method with its own parameters):</p> <pre><code>$userFacade-&gt;getSet('users', 'findBy([], [\'id\' =&gt; \'DESC\'])') </code></pre> <p>This is the getSet method:</p> <pre><code>public function getSet($service, $function) { return new Set($this-&gt;$service-&gt;getRepository()-&gt;$function); } </code></pre> <p>All I want to achieve is to make writing of calls of the repository's functions easier. I haven't found anything useful yet because I don't know the proper term to search for (if there is one). I just wonder whether it's possible (how?) or not (ok...).</p> <p>Now I get an error:</p> <pre><code>Cannot read an undeclared property EntityRepository::$findBy([], ['id' =&gt; 'DESC']) </code></pre>