Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12115 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13982 invoked by uid 1010); 12 Aug 2004 08:58:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 13949 invoked from network); 12 Aug 2004 08:58:59 -0000 Received: from unknown (HELO sccrmhc11.comcast.net) (204.127.202.55) by pb1.pair.com with SMTP; 12 Aug 2004 08:58:59 -0000 Received: from [192.168.1.102] (pcp09278536pcs.eatntn01.nj.comcast.net[69.141.229.108]) by comcast.net (sccrmhc11) with SMTP id <20040812085858011004kqr1e> (Authid: ajb732@comcast.net); Thu, 12 Aug 2004 08:58:59 +0000 To: Hans Lellelid Cc: Dan Ostrowski , internals@lists.php.net In-Reply-To: <411AE970.2080908@velum.net> References: <41196A1D.6060808@velum.net> <200408112219.55268.dan@ostrowski.cc> <411AE454.4060808@akbkhome.com> <411AE970.2080908@velum.net> Content-Type: text/plain Date: Thu, 12 Aug 2004 04:58:54 -0500 Message-ID: <1092304734.6882.2.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 1.5.92 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] is_a() vs. instanceof From: ajb732@comcast.net (Al Baker) I agree, that's the exact behavior I would like as well and what most people would expect. Al On Wed, 2004-08-11 at 23:52 -0400, Hans Lellelid wrote: > Alan Knowles wrote: > > > I think he's referening to something like this (which is common in pear): > > > > $x = $someobj->somemethod(); > > if ($x instanceOf PEAR_Error) { > > ....... > > } > > > > while that code is redundant in the case of exceptions, it is still a > > valid situation.. that $x may be a valid return, and PEAR_Error was > > never loaded.. > > > Yup, that's exactly what I'm talking about. > > I want to be able to do this: > > if ($db instanceof DBPostgres) { > /// do something funky specific to Postgres > } > > If My DB adapter is DBMySQL, I don't want to load the DBPostgres adapter > just so I can test whether my object is of that type ... > > and checking first whether class_exists('DBPostgres') just seems kinda > kludgy & straying from the "problem domain" ... especially since $db > instanceof DBPostgres would *always* be false if DBPostgres isn't loaded. > > Hans >