Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93560 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28599 invoked from network); 26 May 2016 11:54:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2016 11:54:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.84 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.84 mx103.easyname.com Received: from [77.244.243.84] ([77.244.243.84:35489] helo=mx202.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1C/02-17600-504E6475 for ; Thu, 26 May 2016 07:54:47 -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 1b5tsB-0001uh-7R; Thu, 26 May 2016 11:54:43 +0000 Reply-To: internals@lists.php.net References: <7B.12.14311.F79C5475@pb1.pair.com> <1b12b09f-f190-dca0-51d9-468e9c571268@fleshgrinder.com> <4ec823c6-b039-fc91-7c78-60d67719cd81@gmail.com> <00482771-3a07-06cf-ee8d-cd83a301c7e7@fleshgrinder.com> <1ac579b7-6bf3-f362-c045-0261abcfa17c@fleshgrinder.com> <2f058fee-f230-739f-4ed5-ff7d0cabe924@fleshgrinder.com> <7c3f6b51-f93b-c69f-a592-7bb0a00586e6@gmail.com> <528dd5dc-0e17-d766-a83f-02e2429277fa@fleshgrinder.com> <5746E0D7.6020806@lsces.co.uk> To: Lester Caine , internals@lists.php.net Message-ID: <756f6e76-5a3f-2381-f9f2-cdbf8a23405e@fleshgrinder.com> Date: Thu, 26 May 2016 13:54:28 +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: <5746E0D7.6020806@lsces.co.uk> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="s4WAdohsM2VR3CD1wW3W2j7hdjPdl5s2E" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: php@fleshgrinder.com (Fleshgrinder) --s4WAdohsM2VR3CD1wW3W2j7hdjPdl5s2E Content-Type: multipart/mixed; boundary="GRidU94c1DKDpt0fGOjSP4ESmm29Bg9u4" From: Fleshgrinder Reply-To: internals@lists.php.net To: Lester Caine , internals@lists.php.net Message-ID: <756f6e76-5a3f-2381-f9f2-cdbf8a23405e@fleshgrinder.com> Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties References: <7B.12.14311.F79C5475@pb1.pair.com> <1b12b09f-f190-dca0-51d9-468e9c571268@fleshgrinder.com> <4ec823c6-b039-fc91-7c78-60d67719cd81@gmail.com> <00482771-3a07-06cf-ee8d-cd83a301c7e7@fleshgrinder.com> <1ac579b7-6bf3-f362-c045-0261abcfa17c@fleshgrinder.com> <2f058fee-f230-739f-4ed5-ff7d0cabe924@fleshgrinder.com> <7c3f6b51-f93b-c69f-a592-7bb0a00586e6@gmail.com> <528dd5dc-0e17-d766-a83f-02e2429277fa@fleshgrinder.com> <5746E0D7.6020806@lsces.co.uk> In-Reply-To: <5746E0D7.6020806@lsces.co.uk> --GRidU94c1DKDpt0fGOjSP4ESmm29Bg9u4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 5/26/2016 1:41 PM, Lester Caine wrote: >> var_dump(property_exists($g, 'x')); // true >=20 > or array_key_exists('x', $g) in our consistent style but as has been > pointed out we do not have a simple 'exists' ... > $g->exists('x') ? > along with $g->isinit('x') >=20 I like the exists() idea. :) But we might not need it. On 5/26/2016 1:41 PM, Lester Caine wrote: >> var_dump($g->x); // null + E_NOTICE Uninitialize= d >> var_dump(is_null($g->x)); // true + E_NOTICE Uninitialize= d >> var_dump($g->x =3D=3D null); // true + E_NOTICE Uninitia= lized >> var_dump($g->x =3D=3D=3D null); // true + E_NOTICE Uninit= ialized >=20 > Unless null IS the required initial value? Why should we have to > initialize a nullable typed property explicitly? >=20 You don't have to unless null *is* the required initial value. You are only punished with an E_NOTICE if you try to access a property that was never initialized with anything. This would be 100% consistent with old PHP behavior. $x; var_dump($x); // null + E_NOTICE Undefined $y =3D null; var_dump($y); // null class O { public $x; public $y =3D null; } $o =3D new O; var_dump($o->x); // null + E_NOTICE Undefined / Uninitialized var_dump($o->y); // null Only the E_NOTICE for $o->x would be new. On 5/26/2016 1:41 PM, Lester Caine wrote: > I'm still stuck in the simple model of things where 'x' is expandable s= o > we have the simple generic variable of old (PHP4 days) which now has > additional attributes such as accessibility (public etc) and a few > special cases of type filtering but is lacking a tidy way of adding the= > more useful filtering attributes such as constraints and yes typing. >=20 > properties and associative arrays are simply managed list of these > simple variables so why do we need different functions to access them. > Within a class isset($x) should mirror isset($this->x) and exists($x) > makes sense along with other 'object' related functions, but is there n= o > way to get back to a lot simpler consistent handling of variables ... > and a more constructive way to add flexible type constraints. >=20 With this proposal we would not go anywhere else. We would make it more consistent and allow the typed properties RFC to continue. Unless I missed something in the discussion or got something wrong again. Please correct me! --=20 Richard "Fleshgrinder" Fussenegger --GRidU94c1DKDpt0fGOjSP4ESmm29Bg9u4-- --s4WAdohsM2VR3CD1wW3W2j7hdjPdl5s2E 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 iQIcBAEBCAAGBQJXRuP4AAoJEOKkKcqFPVVrVVUP/3k0A3aoypHnk2zNTRjX8EUQ wjISjwdH3EYyPehI+AkuKzuDxvLHEASc7Xb+EafIjbObDt18RQuLrSobqRTxWSOM x0pNPmMgg1sGZSkL7hFKv+qZKxupOu/Eom0xIOzc2uTA/wXhpHbK5TEWoCjqDaKz Ho6OFmMdiGh/HofEYrOrOqC7ioF+5L9D59hduNz/fYOiiX2WrDruEYbr04mz8et7 gDvkrpfRbZGZnDKAVwt5XiBZF7Ol14p+c64cIGywhLc6nURTRI2IIGSkLBc9GPB4 xEZmqzGGo95yZZy+hhFuYNLLt+1VitR71BHl4H35elNqr53868ngma2lxvwPD2gs iSrqqMBwFZtceUtl7gfOJsYMIqX00Fqf+hm4U4j1+z7gxAyceAHc0I+2awzMT4Bc qgBgXczrtU59V5LfY/coYvPVIu9pPWV6qWf6YKlI34KbM3nhI/7Hd4W5PlarlX3v DN7X78+rvfz40N92FF5lbDT8iS1tF/9c8eZ/JC0lDUdqpWHPC8aS8E8CJj38aKei ONBlWHrese7Ip63o9bOiWLwctAsO7r6/ot+8o+78APJqMdHQAELrWvZ44b5jHFM/ rrE07Y0tAB6sr6Ts8IKfew+4vXwbE9rPyw4WhdVmYEczFhmz6RdiQUc1HRYTLvoK Rgy19GBnKNKcIaN6B8xr =YTG4 -----END PGP SIGNATURE----- --s4WAdohsM2VR3CD1wW3W2j7hdjPdl5s2E--