Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64587 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53476 invoked from network); 6 Jan 2013 01:05:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jan 2013 01:05:19 -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 173.203.6.147 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 173.203.6.147 smtp147.ord.emailsrvr.com Linux 2.6 Received: from [173.203.6.147] ([173.203.6.147:50071] helo=smtp147.ord.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 19/91-62408-ECDC8E05 for ; Sat, 05 Jan 2013 20:05:18 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp27.relay.ord1a.emailsrvr.com (SMTP Server) with ESMTP id 2D53E2A812F; Sat, 5 Jan 2013 20:05:15 -0500 (EST) X-Virus-Scanned: OK Received: by smtp27.relay.ord1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id D2EED2A812E; Sat, 5 Jan 2013 20:05:12 -0500 (EST) Message-ID: <50E8CDC8.6080809@sugarcrm.com> Date: Sat, 05 Jan 2013 17:05:12 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Nikita Popov CC: Anthony Ferrara , PHP internals References: <19D80B01-BE88-4119-8A15-B631A96060E5@mrclay.org> <50E8AA4D.5090207@sugarcrm.com> <50E8C2BA.9080309@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Alternative typehinting syntax for accessors From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > Again, same for function typehints. NULL is the only possible > initializer there, too. But still we don't take that as a reason to > always allow NULL for them. For function, non-optional parameters are always mandatory provided. For properties, it is not true - there are no "mandatory properties". I'm surprised how you do not see the different between function parameters explicitly provided and object properties which are never provided when object is constructed and always have to be set manually or use default. They work pretty much in opposite ways here - you can not call function without parameters, and you can not directly assign parameters when creating an object. > Not every property needs the ability to be unset(). Not being able to > unset it is a feature actually. It guarantees that it will always be > available (after the initial set) and does not have to be checked. You convinced me that this feature is actually harmful to PHP - dealing with unset() throwing fatal errors is much worse than occasional empty() check. This is a huge landmine - now any code that unsets object property can return fatal error, and there's, unlike is_null, not even any way to check it. > The timeframe in which it is NULL is usually contained to the constructor. So what? Objects are constructed all the time, and constructors can call any other code. Also, nothing really guarantees the constructor actually has initialized the variable - the constructor author could have forgotten it just as you could have forgotten to initialize it without "no NULL" requirement - so when you are using the API of the object, you can not know if the constructor initialized it or not. And if you're sure your code is right - you don't need null checks anyway, as you know your code never assigns null there. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227