DB_DataObject Overload for PHP5.x

From: Date: Thu, 24 Mar 2005 00:45:57 +0000
Subject: DB_DataObject Overload for PHP5.x
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-18296@lists.php.net to get a copy of this message
I'm using DB_DataObject 1.7.12 with PHP 5.0.3 and am wondering about the DB_DATAOBJECT_NO_OVERLOAD constant as it relates to PHP5. I understand that there has been a lot of email centered around using this option for PHP4 but it appears that there is no way to disable overloading when using PHP5. The automatic getter/setter methods are nice (although I'm not actually using them at the moment) but as far as I can tell they come at the price of keeping PHP from throwing errors when you make calls to non-existent methods from a DB_DataObject class. If you call a non-existent method in your DataObject class it simply returns 'false' (DataObject.php line #3259) instead of throwing a fatal PHP error as I would expect. This recently caused me some nasty debugging problems. For instance, what if you have a method that you expect to return false and you are making calls to it and getting 'false' back but only later realize that you accidentally left that method commented out (or didn't inherit it properly or whatever else caused it to not be available) so that the method was never actually being called? The DB_DataObject::_call() method dutifully returns false and never gives you any indication that a "real" method by that name was never actually called. Am I completely missing something here? Am I the only one who is running into this as a problem? For the moment I have commented out DB/DataObject.php lines 177-182 so that the __call() function in class DB_DataObject_Overload doesn't exist. With this I give up the getter/setter methods but get fatal errors when I do stupid things. Ultimately, I suppose this message is targeted at Alan Knowles - any objection to a patch that allows PHP5 folks to utilize the DB_DATAOBJECT_NO_OVERLOAD option to disable the __call() method? Or even better, a way to throw a PHP error for methods that don't exist? That would be the best of both worlds in that you'd get getter/setter methods AND get fatal errors when expected. Any thoughts? - Jamie

« previous php.pear.general (#18296) next »