Re: use PEAR::isError()
| From: | Lukas Smith | Date: | Sun, 06 Feb 2005 12:01:33 +0000 |
| Subject: | Re: use PEAR::isError() | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-35972@lists.php.net to get a copy of this message | ||
Bertrand Mansion wrote:
Lukas Smith wrote:Yeah. There were several such stupid moves. Like removing the automatic type cast in several array methods. Its kinda wierd how these guys decide what is worth breaking BC over.Alan Knowles wrote:or doing this is an option. if (is_a($foo,'PEAR_Error')) { which is faster, and doesnt require PEAR to be loaded..Especially since is_a() is deprecated already for PHP5.This is indeed a stupid move. I see is_a() everywhere today, both in my code and in other's code. Marking it deprecated for no valid reason, is stupid and makes everyone unhappy. Especially since it is replaced by a PHP5 only syntax.
Yeah well. I think they look very elegant and once I move to PHP5 I will probably beging to use them too. But only in very specfic cases. Pretty similar to when I do an ugly hack :-) This blog links to pretty much all places where I have recently posted on the topic: http://www.digitalsandwich.com/archives/34-What-did-exceptions-ever-do-to-you.html Anyways aside from Alan's suggestion of throwing out encapsulation for a minimal performance gain and buying into the belief that including PEAR.php, thereby eleminating the power of PEAR_Error, is a significant performance loss in anything but synthetic benchmarks, are there any actual objections to my post? BTW: PEAR::isError() can also check if th error code matches a specific value. regards, LukasI have used exceptions recently in my code and they really make my life easier. I think you will change your mind too :) They are also much more appropriate than PEAR_Errors and should replace them IMO.....roll on exceptions....Thats a different topic entirely and fairly unrelated to my post. Aside from that people are severely kidding themselves about the benefits of exceptions. When things boil down to it they safe you a few if's while sacrificing alot of flexibility.