{"id":1117,"date":"2022-08-30T15:12:40","date_gmt":"2022-08-30T15:12:40","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/what-is-an-alternative-method-__call-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:12:40","modified_gmt":"2022-08-30T15:12:40","slug":"what-is-an-alternative-method-__call-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/what-is-an-alternative-method-__call-collection-of-common-programming-errors\/","title":{"rendered":"What is an alternative method `__call`-Collection of common programming errors"},"content":{"rendered":"<p>Method <code>__call<\/code> is running when come call to <em>undefined<\/em> method. I need to trigger when calling any existing method in class, something like <code>__callAll<\/code>.<\/p>\n<p>The simpliest approach would be calling the method in every method, but I don&#8217;t like this approach. The uses Zend framework.<\/p>\n<p>Please advise me how to do it?<\/p>\n<ol>\n<li>\n<p>What you want isn&#8217;t possible. The only solution I can think of is the following:<\/p>\n<ol>\n<li>Name all your functions, instead of myfunction, _myfunction.<\/li>\n<li>Implement a __call method that wraps each of the function calls of the class to _myfunction.<\/li>\n<li>Before executing the function, run your own code.<\/li>\n<\/ol>\n<p>There&#8217;s simply no other way to do this. I also wouldn&#8217;t recommend using my way either but rather looking into some good code-design books because I bet what you want to do isn&#8217;t necessary if you&#8217;d just have the right class design approach.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:30:05. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Method __call is running when come call to undefined method. I need to trigger when calling any existing method in class, something like __callAll. The simpliest approach would be calling the method in every method, but I don&#8217;t like this approach. The uses Zend framework. Please advise me how to do it? What you want [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,8],"tags":[],"class_list":["post-1117","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-zend-framework"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1117"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1117\/revisions"}],"predecessor-version":[{"id":8914,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1117\/revisions\/8914"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}