Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55866 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30021 invoked from network); 19 Oct 2011 01:18:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Oct 2011 01:18:57 -0000 Authentication-Results: pb1.pair.com header.from=alan@akbkhome.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=alan@akbkhome.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain akbkhome.com designates 202.81.246.113 as permitted sender) X-PHP-List-Original-Sender: alan@akbkhome.com X-Host-Fingerprint: 202.81.246.113 246-113.netfront.net Received: from [202.81.246.113] ([202.81.246.113:44565] helo=246-113.netfront.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BD/9A-46813-B752E9E4 for ; Tue, 18 Oct 2011 21:18:55 -0400 Received: from wideboyhd.local ([192.168.0.28]) by akbkhome.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Mailfort v1.2) (envelope-from ) id 1RGKnv-0000An-DD for internals@lists.php.net; Wed, 19 Oct 2011 09:18:47 +0800 Message-ID: <4E9E2571.7010803@akbkhome.com> Date: Wed, 19 Oct 2011 09:18:41 +0800 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13 MIME-Version: 1.0 To: internals@lists.php.net References: <4E969596.4090704@akbkhome.com> <4E970257.2010906@sugarcrm.com> <4E977A4B.4020609@akbkhome.com> <4E977D07.4010503@lerdorf.com> <4E9A1E93.6050804@sugarcrm.com> <4E9B2D02.2080206@sugarcrm.com> <4E9B61EC.3090604@sugarcrm.com> <008101cc8ccf$d6dc9140$8495b3c0$@com> In-Reply-To: <008101cc8ccf$d6dc9140$8495b3c0$@com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-mailfort-sig: 87b48e8f0e993e4448a9423c037231bb Subject: Re: [PHP-DEV] is_a fix for 5.4 and HEAD From: alan@akbkhome.com (Alan Knowles) Supporting strings 'by default' in is_a() has the downside that it produces slightly unpredictable results. If you are accepting 'mixed' arguments, some of which may be strings, there is a slim chance that the string you accept will match the class or it's parent by accident. Personally if I did not believe that the barrier for a BC change has to be alot higher than 'prettier or consistent API', i would have suggested that is_subclass_of should be changed to be 'consistent', and safer. While the old justification for using is_a() over instanceof, has almost gone (it was the only way to write code that was portable to PHP4 & PHP5.*, except for the annoying depreciation message). I still consider is_a(), especially with negative testing slightly clearer to read than instanceof. Regards Alan On Monday, October 17, 2011 09:22 PM, Jonathan Bond-Caron wrote: > On Sun Oct 16 06:59 PM, Stas Malyshev wrote: >> It definitely makes PHP worse by propagating inconsistent APIs. > I created a patch against 5.4: > https://bugs.php.net/patch-display.php?bug_id=55475&patch=is_a_5.4_alternati > ve&revision=latest > > The patch changes the behavior to: > is_a("ab", "b") // false > is_a("ab", "b", true) // autoload "ab", autoload "b" -- false > > is_subclass_of("ab", "b") // false > is_subclass_of("ab", "b", true) // autoload "ab", autoload "b" -- false > > Both class names can be "autoloaded" but not by default > > Thoughts? > > >