Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93526 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28848 invoked from network); 25 May 2016 19:40:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 May 2016 19:40: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 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:44938] helo=mx204.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/79-14311-EBFF5475 for ; Wed, 25 May 2016 15:40: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 1b5efb-0000gp-Gd; Wed, 25 May 2016 19:40:43 +0000 Reply-To: internals@lists.php.net References: <80.72.63510.DAFA5475@pb1.pair.com> <68fd73e7-ad19-3758-7b7a-6013cc26385f@gmail.com> <11.87.14311.EC5E5475@pb1.pair.com> <46620281-18af-094f-d484-8fc69bd7dc11@gmail.com> To: Niklas Keller , PHP Internals Cc: Stanislav Malyshev , Andrea Faulds Message-ID: <557bd7db-b400-73b8-835d-6a03396f7fb5@fleshgrinder.com> Date: Wed, 25 May 2016 21:40: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: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="F0035O3CRrIDmbWEhP3JJTnvcRk1kwTES" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: php@fleshgrinder.com (Fleshgrinder) --F0035O3CRrIDmbWEhP3JJTnvcRk1kwTES Content-Type: multipart/mixed; boundary="cWXqvx2sLwIiNnNFEjcbH1jVh3cxuQL1p" From: Fleshgrinder Reply-To: internals@lists.php.net To: Niklas Keller , PHP Internals Cc: Stanislav Malyshev , Andrea Faulds Message-ID: <557bd7db-b400-73b8-835d-6a03396f7fb5@fleshgrinder.com> Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties References: <80.72.63510.DAFA5475@pb1.pair.com> <68fd73e7-ad19-3758-7b7a-6013cc26385f@gmail.com> <11.87.14311.EC5E5475@pb1.pair.com> <46620281-18af-094f-d484-8fc69bd7dc11@gmail.com> In-Reply-To: --cWXqvx2sLwIiNnNFEjcbH1jVh3cxuQL1p Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 5/25/2016 9:13 PM, Niklas Keller wrote: > 2016-05-25 20:39 GMT+02:00 Fleshgrinder : >=20 >> In my opinion it should simply vanish along with its definition. I mea= n, >> >=20 > Usually, yes. But suddenly `private Type $foo` isn't reliable anymore i= f > unset is supported for typed properties, because the following would ju= st > remove all type info / enforcement: >=20 > $backup =3D $this->foo; > unset($this->foo); > $this->foo =3D $backup; >=20 > Unset can reset it to the default value, but wiping type information is= > probably > not an option here. >=20 > Regards, Niklas >=20 I had to check because I never tried this once in my life (why would one need it anyways) ... class A { private $foo =3D "foo"; function get() { return $this->foo; } function unset() { unset($this->foo); } } $a =3D new A; echo $a->get(); // foo $a->unset(); echo $a->get(); // Notice: Undefined property: A::$foo $a->foo =3D "foo"; // Fatal error: Uncaught Error: Cannot access private property A::$foo In other words, unset is not really unset already! QED: Preserving *all* attributes of a property is the only consistent way. However, preserving its value is not. I do not think that there is a problem together with the typed properties, nullability, and unset simply because the property is not explicitly assigned null by unset, it is being undefined. I think internally null is actually assigned and it's not IS_UNDEF, right? However, from a userland perspective it is definitely not defined anymore and access should (as it does) result in an error (in our case E_INFO) plus null is being returned but only because undefined does not exist in PHP userland. I did not read up on all the history yet but I am on it ... --=20 Richard "Fleshgrinder" Fussenegger --cWXqvx2sLwIiNnNFEjcbH1jVh3cxuQL1p-- --F0035O3CRrIDmbWEhP3JJTnvcRk1kwTES 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 iQIcBAEBCAAGBQJXRf+wAAoJEOKkKcqFPVVrknIP/ibvamvd5i9NY8JsmHj1cZ4n hlapOL5f9WZ8mfFCd457f8rXho+2ggoOeezQ1TA/WIc90wQQliHdsDDk5gOmfmmy uYDylkVBt7Okn564Ca4D80EH4BqFj/jpXXmljj/RAah4OCXPQJgb7F1ih3qn/Qiw BAklmMZxok1heRqHup4PQdTW2LIC0+jLDu93decjqCjgchSfqZFhXNPwjsNd1nxe DROk3tFtmqWH/rq/71BMJrNab9wUMs4HNjiTlciKZBO6Az39HxXqjGI5HbdEkXsz MRoHdS2JZ88OGrp8trz+8qOMXafLRtwUNZ3xl+9AOLTOPymERhmx4pjJD3CRU7Yj RgwpDsgek+YBcnleNau9uoRt9DYY84NeCoGOqErMxtnl76JyiVvFnfasRwSadmN2 ejVfqehUCvAeAzI2n843qJkzfiokAczmZdzYCV6jEMHhlMqumTfiNkYgEyCUY+o+ aYU61xDZ4dV4Z6HY0np37DPCEbOthvJU+1N+ArZ3ShCUstMrCCsMIZyLOhp3xQC/ CopQ56qC+VL7zPugh7JmqV7P2SzJzl5Ro2mFv6/7KV/YQpe5A1qzhAq4ofY/QpTN Nu6y+1rbuu3D83nrCjnthu43Op5Nby5pONV1v5N4krCzONzbGry50x1j4q+GZzwF jT3/6whUs0zgEaKNfFcV =uE45 -----END PGP SIGNATURE----- --F0035O3CRrIDmbWEhP3JJTnvcRk1kwTES--