Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78807 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27038 invoked from network); 6 Nov 2014 11:36:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Nov 2014 11:36:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.208 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.208 imap2-3.ox.privateemail.com Received: from [192.64.116.208] ([192.64.116.208:36829] helo=imap2-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/F1-28384-D4D5B545 for ; Thu, 06 Nov 2014 06:36:46 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id B6AAA8C0080; Thu, 6 Nov 2014 06:36:42 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GDW0bwbHLJCJ; Thu, 6 Nov 2014 06:36:42 -0500 (EST) Received: from oa-res-26-28.wireless.abdn.ac.uk (oa-res-26-28.wireless.abdn.ac.uk [137.50.26.28]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 4EE2A8C007B; Thu, 6 Nov 2014 06:36:41 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: Date: Thu, 6 Nov 2014 11:36:39 +0000 Cc: Stas Malyshev , PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <6FB6D82E-CF77-462D-8420-A1E37915EA13@ajf.me> References: <545B3900.6070208@sugarcrm.com> To: Daniel Ribeiro X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator From: ajf@ajf.me (Andrea Faulds) > On 6 Nov 2014, at 09:29, Daniel Ribeiro wrote: >=20 > On Thu, Nov 6, 2014 at 1:01 PM, Stas Malyshev > wrote: >=20 >> You could of course require the expression to always be enclosed in = (), >> but that produces weird syntax where some forms of instanceof work >> without () and some only with (). Given that you can easily assign = your >> value to a variable, is it worth it? >>=20 >> Also, you can always use is_a($foo, $bar->getClassName()). >>=20 >=20 > This is exactly what I'm doing right now, requiring the expression to > always be enclosed in parenthesis. I think it's way better to be able = to do > this instead of creating temporary variables just to assign a class = name. > Also, is_a, since it's a function, is significantly slower than = instanceof, > which is a construct (but of course you already now that). This is still pretty weird, $foo instanceof Bar and $foo instanceof = (Bar) shouldn=E2=80=99t be different. Perhaps, dare I say it, we should merge the constant and class = namespaces in PHP7? Those are perhaps the least likely to conflict. = It=E2=80=99d mean we could handle instanceof expressions, and we = wouldn=E2=80=99t need to use ::class. -- Andrea Faulds http://ajf.me/