[dev] Re: [cvs] commit: horde/lib Category.php

Mike Cochrane mike@graftonhall.co.nz
Mon, 30 Sep 2002 22:02:35 +1200


> ----- Message from jan@horde.org ---------
>     Date: Mon, 30 Sep 2002 11:39:38 +0200
>     From: Jan Schneider <jan@horde.org>
> Reply-To: Jan Schneider <jan@horde.org>
>  Subject: Re: [dev] Re: [cvs] commit: horde/lib Category.php
>       To: dev@lists.horde.org
> 
> Zitat von Chuck Hagenbuch <chuck@horde.org>:
> 
> > Quoting Jan Schneider <jan@ammma.de>:
> >
> > >   I guess this is more readable.
> >
> > Why? Also possibly more expensive, though I haven't tested yet. Please
> > revert this...
> 
> Because we use isError() everywhere in our code, it isn't (much) more
> expensive and it also catches subclasses of PEAR_Error:

I'm not sure why Chuck choose to do it differently here... from a consistancy
point of view, it's not good... from an effiency point of view it's good.

is_a catches the subclasses too...

bool is_a ( object object, string class_name)

This function returns TRUE if the object is of this class or has this class as
one of its parents, FALSE otherwise. 

- Mike :-)

> 
>     function isError($data) {
>         return (bool)(is_object($data) &&
>                       (get_class($data) == 'pear_error' ||
>                       is_subclass_of($data, 'pear_error')));
>     }
> 
> Jan.
> 
> --
> http://www.horde.org - The Horde Project
> http://www.ammma.de - discover your knowledge
> http://www.tip4all.de - Deine private Tippgemeinschaft
> 
> --
> Horde developers mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: dev-unsubscribe@lists.horde.org
> 
> ----- End message from jan@horde.org -----