Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78799 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8713 invoked from network); 6 Nov 2014 09:01:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Nov 2014 09:01:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.99 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.99 smtp99.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.99] ([108.166.43.99:41707] helo=smtp99.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/CE-28384-4093B545 for ; Thu, 06 Nov 2014 04:01:57 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp21.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 294B43803EA; Thu, 6 Nov 2014 04:01:54 -0500 (EST) X-Virus-Scanned: OK Received: by smtp21.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 8434F3803EE; Thu, 6 Nov 2014 04:01:53 -0500 (EST) X-Sender-Id: smalyshev@sugarcrm.com Received: from Stass-MacBook-Pro.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net [108.66.6.48]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:465 (trex/5.3.2); Thu, 06 Nov 2014 09:01:54 GMT Message-ID: <545B3900.6070208@sugarcrm.com> Date: Thu, 06 Nov 2014 01:01:52 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Daniel Ribeiro , PHP internals References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Allow arbitrary expressions when using instanceof operator From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > What I want to implement is the ability to allow arbitrary expressions on > the second operand, so instead of having to write something like this: I'm afraid there's a problem with this. Arbitrary expressions include constants, right? So what this means: var_dump($foo instanceof Bar); is it checking $foo for being instance of class Bar (that's what is happening now) or is it taking the value of the constant Bar (whatever it is) - since constant is an expression - and using it as a class name and then checking if $foo is an instance of that class? 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? Also, you can always use is_a($foo, $bar->getClassName()). -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/