Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93572 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70374 invoked from network); 26 May 2016 16:44:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2016 16:44:27 -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 67.192.241.147 as permitted sender) X-PHP-List-Original-Sender: fsb@thefsb.org X-Host-Fingerprint: 67.192.241.147 smtp147.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.147] ([67.192.241.147:34722] helo=smtp147.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/D9-17600-BE727475 for ; Thu, 26 May 2016 12:44:27 -0400 Received: from smtp23.relay.dfw1a.emailsrvr.com (localhost.localdomain [127.0.0.1]) by smtp23.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 29E09380162; Thu, 26 May 2016 12:44:23 -0400 (EDT) X-Auth-ID: fsb@thefsb.org Received: by smtp23.relay.dfw1a.emailsrvr.com (Authenticated sender: fsb-AT-thefsb.org) with ESMTPSA id 0E490380139; Thu, 26 May 2016 12:44:21 -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:44:23 -0400 User-Agent: Microsoft-MacOutlook/14.6.4.160422 Date: Thu, 26 May 2016 12:44:19 -0400 To: Thomas Bley , , Message-ID: Thread-Topic: [PHP-DEV] [RFC][Vote] Typed Properties References: <20160525215208.034FC1A801B3@dd1730.kasserver.com> <20160526144023.2A2A11A800A7@dd1730.kasserver.com> In-Reply-To: <20160526144023.2A2A11A800A7@dd1730.kasserver.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) Hi Thomas, On the face of it, I'm not enthusiastic to introduce new magic numbers (which would be false, 0, 0.0, "", and [], right?) that PHP assigns when coercing a typed, uninitialized property read by a file in liberal mode. This is like taking the most confusing thing about 7.0's dual-mode, scalar type declaration of function arguments and boosting the confusion power. I would want a new name for this complement-of-strict mode. "Weak" and "liberal" don't quite do it. Promiscuous mode? ;) Tom On 5/26/16, 10:40 AM, "Thomas Bley" wrote: >I think strict_types=1 should give a fatal error for accessing >non-initialized typed properties, instead of notice. >Example: > >declare(strict_types=1); > >class A { > public int $x; > public ?int $y = null; > public int $z = 42; > public ?int $u; > public ?datetime $v; > public datetime $w; >} > >$a = new A; >var_dump($a->x); // Fatal error, uninitialized... >var_dump($a->y); // null >var_dump($a->z); // 42 >var_dump(isset($a->z)); // true >unset($a->z); >var_dump(isset($a->z)); // false >var_dump($a->z); // Fatal error, uninitialized... >var_dump($a->u); // Fatal error, uninitialized... >var_dump($a->v); // Fatal error, uninitialized... >var_dump($a->w); // Fatal error, uninitialized... > >var_dump(isset($a->x)); // false >var_dump(isset($a->y)); // false >var_dump(isset($a->u)); // false >var_dump(isset($a->v)); // false >var_dump(isset($a->w)); // false > >Regards >Thomas > >Tom Worster wrote on 26.05.2016 15:53: > >> On 5/25/16 5:52 PM, Thomas Bley wrote: >>> I'm not seeing a problem here: >>> >>> class A { >>> public int $x; >>> public ?int $y = null; >>> public int $z = 42; >>> public ?int $u; >>> public ?datetime $v; >>> public datetime $w; >>> } >>> >>> $a = new A; >>> var_dump($a->x); // 0 + notice >>> var_dump($a->y); // null >>> var_dump($a->z); // 42 >>> var_dump(isset($a->z)); // true >>> unset($a->z); >>> var_dump(isset($a->z)); // false >>> var_dump($a->z); // 0 + notice >>> var_dump($a->u); // null + notice >>> var_dump($a->v); // null + notice >>> var_dump($a->w); // Fatal error, uninitialized... >>> >>> var_dump(isset($a->x)); // false >>> var_dump(isset($a->y)); // false >>> var_dump(isset($a->u)); // false >>> var_dump(isset($a->v)); // false >>> var_dump(isset($a->w)); // false >> >> Is the file containing these examples in liberal mode? >> >> What changes if declare(strict_types=1) precedes $a = new A;? >> >> Tom >> >