Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62174 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8447 invoked from network); 15 Aug 2012 09:06:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 09:06:43 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.133 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.133 smtp133.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.133] ([67.192.241.133:42006] helo=smtp133.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3D/92-30529-1A66B205 for ; Wed, 15 Aug 2012 05:06:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp13.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 51BBF3D0499; Wed, 15 Aug 2012 05:06:39 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp13.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 06E533D0427; Wed, 15 Aug 2012 05:06:38 -0400 (EDT) Message-ID: <502B669E.7040702@sugarcrm.com> Date: Wed, 15 Aug 2012 02:06:38 -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> <502B57AE.4070801@sugarcrm.com> <502B5C7F.1070708@sugarcrm.com> <6D84602D0F514FA3B82C11DBAF58AA53@pc> <502B5F8A.5000500@sugarcrm.com> <6281E4639C7248488268ACED88B86B7D@pc> In-Reply-To: <6281E4639C7248488268ACED88B86B7D@pc> 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! > All right, your method accepts an array of objects, instances of Foo. How do > you enforce this contract? You are trying to re-invent generics/parametrized types and bolt it onto PHP. I still don't think it is a good idea - PHP is not a statically typed language. Just check you array elements if you need. > What's your proposal? From the discussion so far, I'd guess it's peppering > out code with if-s with the same error written everywhere everytime we check > the item in an array. By "peppering" here you mean one if. Yes, this is my proposal - if you need to do a check - do a check. > The same applies to typehints, so make up your mind. No it does not. But this is exactly why I think one of the problems with strict typing in arguments is - because people take it and starting to use it as a legitimation of turning PHP into weird hybrid of dynamically typed language with random islands of static typing popping in random places. I still do not think it is a good idea. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227