Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53847 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19821 invoked from network); 11 Jul 2011 09:13:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jul 2011 09:13:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.199.177.89 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 212.199.177.89 il-mr1.zend.com Received: from [212.199.177.89] ([212.199.177.89:48846] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/3E-41672-EAEBA1E4 for ; Mon, 11 Jul 2011 05:13:19 -0400 Received: from il-gw1.zend.com (unknown [10.1.1.22]) by il-mr1.zend.com (Postfix) with ESMTP id 003F860717; Mon, 11 Jul 2011 12:12:08 +0300 (IDT) Received: from tpl2.home (10.1.10.4) by il-ex2.zend.net (10.1.1.22) with Microsoft SMTP Server id 14.1.255.0; Mon, 11 Jul 2011 12:13:04 +0300 Message-ID: <4E1ABEA8.1000009@zend.com> Date: Mon, 11 Jul 2011 13:13:12 +0400 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc15 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: Stas Malyshev CC: Ralph Schindler , "internals@lists.php.net" , =?UTF-8?B?Sm9oYW5uZXMgU2NobMO8dGVy?= References: <1310072926.3298.32.camel@guybrush> <4E171A47.9010609@smashlabs.com> <4E1AA3B7.7050907@zend.com> <4E1AA582.1070201@sugarcrm.com> <4E1AAC49.50102@zend.com> <4E1AB1C8.1020809@sugarcrm.com> In-Reply-To: <4E1AB1C8.1020809@sugarcrm.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.1.10.4] Subject: Re: [PHP-DEV] Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/Zend/tests/bug53727.phpt branches/PHP_5_3/Zend/tests/is_a.phpt branches/PHP_5_3/Zend/zend_builtin_functions.c branches/PHP_5_3/ext/standard/tests/class_object/is_a_ From: dmitry@zend.com (Dmitry Stogov) OK. As I said I don't have strong opinion about this. So fell free to remove the warning. Thanks. Dmitry. On 07/11/2011 12:18 PM, Stas Malyshev wrote: > Hi! > >> That warning might be only emitted if the first operand is a name of non >> existing class. >> >> is_a("NonExistingClass", "MyClass"); > > I think you've missed my point. The point was people use this to check > if first argument is an instance of a certain class or something else - > and "something else" may not be a class name at all, just random string > that they'll use later. > >> I think this warning may make sense. :) > > I disagree, if you look at how people are using is_a on Google's > codesearch, you'll see that many use it in the same manner as > instanceof. In this case, the warning is useless since the first > argument is not meant to be class name, so it's no use to warn that it > is not - it does not add any information and does not expose any bug. > Here's an example of PEAR code: > > function isError($data, $code = null) > { > if (!is_a($data, 'PEAR_Error')) { > return false; > } > > if (is_null($code)) { > return true; > } elseif (is_string($code)) { > return $data->getMessage() == $code; > } > > return $data->getCode() == $code; > } > } > > I'm sure there is more code like that out there. And in such code, > producing a warning has no other result but make people to add useless > checks that have no other purpose but avoid warnings and annoy them.