Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93576 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76387 invoked from network); 26 May 2016 16:57:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2016 16:57:41 -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 212.232.28.125 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.28.125 mx204.easyname.com Received: from [212.232.28.125] ([212.232.28.125:33811] helo=mx204.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/3B-17600-30B27475 for ; Thu, 26 May 2016 12:57:39 -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 1b5ybI-0002JY-Jf; Thu, 26 May 2016 16:57:36 +0000 Reply-To: internals@lists.php.net References: <20160525215208.034FC1A801B3@dd1730.kasserver.com> <5fd54aa0-4fdf-c1e7-eae8-765aa89c8498@fleshgrinder.com> To: Rowan Collins , internals@lists.php.net, Stanislav Malyshev Message-ID: <08963b03-8394-6d62-4e5b-393f3fcb5647@fleshgrinder.com> Date: Thu, 26 May 2016 18:57:21 +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="PUuUWBfjDlO8T4ToFiB2TNN2Vkk86DNXs" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: php@fleshgrinder.com (Fleshgrinder) --PUuUWBfjDlO8T4ToFiB2TNN2Vkk86DNXs Content-Type: multipart/mixed; boundary="6DPT1l1LNKRs9VrJn02rjT0sRS8PeiRgu" From: Fleshgrinder Reply-To: internals@lists.php.net To: Rowan Collins , internals@lists.php.net, Stanislav Malyshev Message-ID: <08963b03-8394-6d62-4e5b-393f3fcb5647@fleshgrinder.com> Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties References: <20160525215208.034FC1A801B3@dd1730.kasserver.com> <5fd54aa0-4fdf-c1e7-eae8-765aa89c8498@fleshgrinder.com> In-Reply-To: --6DPT1l1LNKRs9VrJn02rjT0sRS8PeiRgu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 5/26/2016 6:50 PM, Rowan Collins wrote: > As I'm sure has already been pointed out (I haven't followed the whole > thread) this defeats a large advantage of typed properties - I now can'= t > read from the property without checking if it's null, so I can't do thi= s: >=20 > class O { > public \DateTimeImmutable $d; > } > echo (new O)->d->format('Y-m-d H:i:s'); >=20 > There's no ? on the type def, so I ought to be able to trust the type. = A > TypeError makes more sense here, because it is a programming error for > it to be in this state. >=20 That is exactly what Stanislav raised too. I really have no idea how we should prevent this from happening and honestly think we shouldn't. Your construct will result in a fatal error (also known as NullPointerException to some, *evil-laughter*) anyways preceded by an E_NOTICE that tells you that your property is not defined. I am of course open for ideas but emitting another kind of fatal error does not really make things better imho. --=20 Richard "Fleshgrinder" Fussenegger --6DPT1l1LNKRs9VrJn02rjT0sRS8PeiRgu-- --PUuUWBfjDlO8T4ToFiB2TNN2Vkk86DNXs 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 iQIcBAEBCAAGBQJXRyr2AAoJEOKkKcqFPVVrVuYP/A30rtIKWCqrTI2YNLX8jXf8 78Ss1SpeqCzfiqUrtO+0teZd+AhGDhy03qO5Gmm4SeABqKMh2GiRXwg+1jtDGruD L9pfOpU5YJNX3Xa6jS/eA5j66F43ExxwrTNlYNzwZ4zXsaMSf/GSJuqA2IDB9S1N xBv2T2cXWr1ZX5iGa94M5IduOlYV+LHrmQhFVRRVZ5Lk9+fyfJl+++OeQC+ufscL IZNBOAx+53nv2AOUZDtdFvQZE8cVJmb0xUwjgf6qheNWoVdsYyzadanzJ7embGCF P0OoY96uWxT4z3d2cvhb6mlIvnHEKH/rLNPnWKWdQ81t+GYaJksEFhXZ4N1Ds8mA 3Y7ybCbXndLSM9hgLAa3/H2MVUR9qWAFsEi/IkirdAN3dY9czNdIa6NXMvQUbrP6 fL5mNLHl38gLpYCvwjgEEEgcz4+srT3G0lQopi58otgK0TjOinziRKij4NdKivyY pJib8fTR1cLMzFZVuVLGukb+2rTfTLp+VfntnDdLV5qkkrp+W1RQDHjdGuFBE4cp BSYb8JA9AzGV7Dn3oY/hX4rHLeOKX+Mk7+zGYRemR/3bm1HGrERoI9UJmlu9tAwg Q5GDo73Vtrj3gd9kHrazQKXqiCz6qOUH1UCxa/dsMJYvDV1NhkfpiKl9axepWbO4 lQoNdkKcq1TFBKfDqgO+ =NWMS -----END PGP SIGNATURE----- --PUuUWBfjDlO8T4ToFiB2TNN2Vkk86DNXs--