Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62165 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89487 invoked from network); 15 Aug 2012 08:03:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 08:03:00 -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 67.192.241.173 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.173 smtp173.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.173] ([67.192.241.173:55429] helo=smtp173.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E5/52-06007-2B75B205 for ; Wed, 15 Aug 2012 04:02:59 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp7.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 0E71125851E; Wed, 15 Aug 2012 04:02:55 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp7.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 864BD25825F; Wed, 15 Aug 2012 04:02:55 -0400 (EDT) Message-ID: <502B57AE.4070801@sugarcrm.com> Date: Wed, 15 Aug 2012 01:02:54 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Stan Vass CC: "internals@lists.php.net" References: <502A86AA.2030203@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Inline typecasting / typehinting for classes and interfaces From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > My proposal is simple: behave as an inline type hint. The same type hints > you have in arguments lists, but inline. The use case is "I want to make > sure this value is of this type" and a side benefit is the IDE can know the > variable is of this type too (for autocompletion purposes). What's wrong with instanceof? You can then throw fatal error if you want, it's just two lines: if(!($foo instanceof Bar)) { trigger_error(E_USER_ERROR, "Wrong foo!"); } -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227