note 40790 added to ref.overload

From: Date: Mon, 15 Mar 2004 04:11:15 +0000
Subject: note 40790 added to ref.overload
Groups: php.notes 
Request: Send a blank email to php-notes+get-66839@lists.php.net to get a copy of this message
Overload and Inheritance. After wasting a few hours trying to get it to work, it seems appropriate to put a warning here. Short Version: DON'T ever subclass an overloaded class. EVER. Corollary: If an overloaded class simply must be subclassed, rewrite the parent class to get rid of the overloading. It can be as simple as commenting out the overload() statement and calling the get/set/call methods explicitely. This was the road I ended up taking. Long Version: While it is, in theory, possible to end up with a working subclass, it requires much mucking and OO-principles compromise. There is a great post that details the problem at great length. For those with the stomach, the URL is: http://www.zend.com/lists/engine2/200201/msg00140.html If you're still thinking about mixing inheritance and overloading, at least read the "Best Practices for the overload functions" in the URL above. If that doesn't change your mind, at least you'll be able to avoid most of the pitfalls. ---- Manual Page -- http://www.php.net/manual/en/ref.overload.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40790 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40790&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40790&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66839) next »