Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93571 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68862 invoked from network); 26 May 2016 16:40:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2016 16:40:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=fsb@thefsb.org; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=fsb@thefsb.org; sender-id=pass Received-SPF: pass (pb1.pair.com: domain thefsb.org designates 173.203.187.107 as permitted sender) X-PHP-List-Original-Sender: fsb@thefsb.org X-Host-Fingerprint: 173.203.187.107 smtp107.iad3a.emailsrvr.com Linux 2.6 Received: from [173.203.187.107] ([173.203.187.107:57978] helo=smtp107.iad3a.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 24/89-17600-60727475 for ; Thu, 26 May 2016 12:40:38 -0400 Received: from smtp14.relay.iad3a.emailsrvr.com (localhost.localdomain [127.0.0.1]) by smtp14.relay.iad3a.emailsrvr.com (SMTP Server) with ESMTP id 7280928064B; Thu, 26 May 2016 12:40:35 -0400 (EDT) X-Auth-ID: fsb@thefsb.org Received: by smtp14.relay.iad3a.emailsrvr.com (Authenticated sender: fsb-AT-thefsb.org) with ESMTPSA id D2CC62805BD; Thu, 26 May 2016 12:40:32 -0400 (EDT) X-Sender-Id: fsb@thefsb.org Received: from [10.0.1.2] (c-66-30-62-12.hsd1.ma.comcast.net [66.30.62.12]) (using TLSv1 with cipher DES-CBC3-SHA) by 0.0.0.0:465 (trex/5.5.4); Thu, 26 May 2016 12:40:35 -0400 User-Agent: Microsoft-MacOutlook/14.6.4.160422 Date: Thu, 26 May 2016 12:40:29 -0400 To: php-internals , James Gilliland , Thomas Bley , Message-ID: Thread-Topic: [PHP-DEV] [RFC][Vote] Typed Properties References: <20160525215208.034FC1A801B3@dd1730.kasserver.com> <5fd54aa0-4fdf-c1e7-eae8-765aa89c8498@fleshgrinder.com> In-Reply-To: <5fd54aa0-4fdf-c1e7-eae8-765aa89c8498@fleshgrinder.com> Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: 7bit Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: fsb@thefsb.org (Tom Worster) On 5/26/16, 12:30 PM, "Fleshgrinder" wrote: >The problem is a completely different one, how should the following code >behave? > > class A { > > public int $x; > > } > > (new A)->x; > >The property has no value assigned but it is being accessed. The current >PHP behavior is to simply initialize it with null. But this is >impossible according to the type definition. > >There are not many ways to handle this. I think we already had all of >them proposed: > >0. Fatal error after __construct was called. >1. Fatal error and abort. >2. Initialize with appropriate type. >3. Initialize with null. Under another 5th option, the problem you state does not arise. Disallow "public int $x;". Under this option you may declare $x with type int and an initial value or you may declare $x without type but you may not declare $x with type (nullable or not) and undefined initial value. Tom