Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93570 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67127 invoked from network); 26 May 2016 16:30:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2016 16:30:45 -0000 Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.82 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.82 mx101.easyname.com Received: from [77.244.243.82] ([77.244.243.82:55071] helo=mx205.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F9/29-17600-3B427475 for ; Thu, 26 May 2016 12:30:44 -0400 Received: from cable-81-173-133-15.netcologne.de ([81.173.133.15] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1b5yBE-00016c-It; Thu, 26 May 2016 16:30:40 +0000 Reply-To: internals@lists.php.net References: <20160525215208.034FC1A801B3@dd1730.kasserver.com> To: Tom Worster , James Gilliland , Thomas Bley , ajf@ajf.me, PHP Internals Message-ID: <5fd54aa0-4fdf-c1e7-eae8-765aa89c8498@fleshgrinder.com> Date: Thu, 26 May 2016 18:30:24 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MtIFcCOhN6KUunjrrTH5MMQb1pPwgUkNt" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: php@fleshgrinder.com (Fleshgrinder) --MtIFcCOhN6KUunjrrTH5MMQb1pPwgUkNt Content-Type: multipart/mixed; boundary="JqixUrRJ6M1TJ8RWnXwQfgGxn2Ma96QuU" From: Fleshgrinder Reply-To: internals@lists.php.net To: Tom Worster , James Gilliland , Thomas Bley , ajf@ajf.me, PHP Internals Message-ID: <5fd54aa0-4fdf-c1e7-eae8-765aa89c8498@fleshgrinder.com> Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties References: <20160525215208.034FC1A801B3@dd1730.kasserver.com> In-Reply-To: --JqixUrRJ6M1TJ8RWnXwQfgGxn2Ma96QuU Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. Option 0. is out the window because it creates endless edge cases. Option 1. is extremely brutal and not necessarily what we want (lazy, anyone?). Option 2. has a huge problem with objects because it cannot initialize e.g. a \Fleshgrinder\Custom\SuperClass nor a \DateTime. Option 3. is the current behavior but silently doing so results in a type hint violation. Emitting an E_NOTICE at this point is the most sensible thing that we can do at this point in my opinion. Extending this logic to all kind of properties is just logical to keep conditionals in the internals low and have a consistent behavior across all of the userland functionality. After all, aren't the following things equal? $a; echo $a; // null + E_NOTICE class O { public int $x; } echo (new O)->x; // null + E_NOTICE One could even argue that an E_NOTICE is required for void routines too. function f() {} echo f(); // null + E_NOTICE But that's another story. :) --=20 Richard "Fleshgrinder" Fussenegger --JqixUrRJ6M1TJ8RWnXwQfgGxn2Ma96QuU-- --MtIFcCOhN6KUunjrrTH5MMQb1pPwgUkNt Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXRySlAAoJEOKkKcqFPVVrN10P/1H6OfNpGKszci9lVra5C7rp J1+PXYuj6lNkJHkIYYEbltQeEA3ZaxNdljsYFoAeWqbyCDv0BHAfNFI99NuU3P4F IW2x9posTc5tvKHaed+CDDItYb2/qP9RoSXkejfZ4WOdax3jutZdVUIFfNFQ6a2z M7Ju5uz/Ejgb1V10CImIuWcg32vkDxgNAXGFhxi3TWqzmMTfGq8WjAvMSOItD8zE x7WZL18463U6fEn1UIhDWuI4G7b/uLOc4eCAqwp8kpF2eL1Aqx2czVjXvOpnfU5f aJnxDjdKVVaWIxtszN57IJ7ORhLprvA4IezK5zWK/iId0vJpbfOGC/MTt/eAfeEF RSlBSnZQYrqg/AWOYGCVoDoxMDCdcaeAVuxitKEuXeQd+HPdQIL/7zvNg5Q12Za8 pyQMGjw2LhhYp4mWtq04QYpXV03d5bksUh5PD4rnptc2XGXMjVpYos4K00W3BT/M 4Lj1FjAYuoPXES6QHeeRGD2NEEqgeE4WHr9yqpfRf8tcUEuyjlMgXg1IG4wBBKqp yMxEA4kJpM49rzvdJI0DInM+FqxlGbheF2UYBWbJqtVSX+RjxuB0ibhSGlIAbyZP 8mQyXeO9fL/kwfBS5k3MPtF/lYPP+nWEBsHQVnpHqF8Z0MxHAc9EMLr4z7UN0nDv YkKIraZ+Jm6P4DTATvgI =ZGKI -----END PGP SIGNATURE----- --MtIFcCOhN6KUunjrrTH5MMQb1pPwgUkNt--