Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98554 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90436 invoked from network); 15 Mar 2017 22:57:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2017 22:57:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.179 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 74.125.82.179 mail-ot0-f179.google.com Received: from [74.125.82.179] ([74.125.82.179:33719] helo=mail-ot0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 36/35-38004-2D6C9C85 for ; Wed, 15 Mar 2017 17:57:22 -0500 Received: by mail-ot0-f179.google.com with SMTP id 19so36617919oti.0 for ; Wed, 15 Mar 2017 15:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6wwZgBETXS0WyijNRHYbnB8TxUEUdcMJxO7KEDPlzNg=; b=obl/5BwQ9Gr6L7rt4ZP7u0dzKul03jyVt8c+OvrtJYou9SsyTl73zWnYSWPTGc8TQg 8+tGZPbX+cDnrCzzGuHTTCdFfqXEf/eg9A/jUK8KMk3ZbDbcqXwWESh8qZtVu9i0Hm7A 1ebnAqW2+catsxcsQYxAPwwxPG8QRgTCJMGMJv4W79Xc44mYXyatmPdPfRrvoC5t2hey s5RJXI8KZTrxhrFC5RoGsHjB1VLdCVJ2mBEovbjXaaRTdKL/MzFZvCdT/t0lGTBJ2PvR vLPWIBo3S4aeY0g2+Dqe2nzDaKXuqbrqPq2mFtAj6MLbmIRI84oRMz+bQO+blXuSOnWS Vbfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6wwZgBETXS0WyijNRHYbnB8TxUEUdcMJxO7KEDPlzNg=; b=GKOH8Wx+nCuJkWfWg/seUYpBequ/Gh8vRZ6bd9MAIXelG3OqICNwmfBEv7QYxk8vNX RxIDtsuIl4JeZo3Y4q2IyPuWLhFZ8mlYh1OgpQwND459GTXeKgXH78nL3c0ARERw6cBT 0uhMv643pPoSTYZdlb8N0X2zOYVIxjtwvsPAkPeJEe5Fp08KINnbHRz3i4YjgULuhcFG +2rVp5j3rCfjq1hOSbCGV1CSIp1To+YTEwo2ifzcW2k3MbXqWfEJlXxOEc1Kt5dICbZb JK25WU+pyUsb/F8mq+ue7MOc8PPQYDvtHQX7IDzCs50dZC5DCEoDEXF+ujwl6BlJYq2F I21A== X-Gm-Message-State: AFeK/H2giHxlHq+AOnfdqfpUC9/TpakRAtMKs/a825ALXm4RTdXsVgDShQ5RgJ1wBpXLS6MhLeDzjGS8Jc0ZLw== X-Received: by 10.202.204.86 with SMTP id c83mr3204212oig.146.1489618639008; Wed, 15 Mar 2017 15:57:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.11.227 with HTTP; Wed, 15 Mar 2017 15:57:18 -0700 (PDT) Received: by 10.157.11.227 with HTTP; Wed, 15 Mar 2017 15:57:18 -0700 (PDT) In-Reply-To: References: Date: Wed, 15 Mar 2017 16:57:18 -0600 Message-ID: To: Marco Pivetta Cc: internals@lists.php.net, Kalle Sommer Nielsen , =?UTF-8?Q?Beno=C3=AEt_Burnichon?= Content-Type: multipart/alternative; boundary=001a1134feccd43b81054accdd06 Subject: Re: [PHP-DEV] Add __toArray() method to objects that would be called on cast to array From: derokorian@gmail.com (Ryan Pallas) --001a1134feccd43b81054accdd06 Content-Type: text/plain; charset=UTF-8 On Mar 15, 2017 16:40, "Marco Pivetta" wrote: Which is precisely the BC break: such a library would now throw an exception "unsupported class X" when `__toString` is implemented. Also, such a library would break silently when this feature is implemented. Much like the already very broken `__debugInfo()`, this automatic type-cast is a giga-Joule footgun. First please stop top posting. Second bc means that if no code changes no functionality is changed. That's exactly what we're talking about. If the class doesn't change neither does the functionality. So unless classes already have __toArray they will not change in behaviour. As pointed out in answer to my question earlier a class with no code change would see no change in casting behaviour. Only if new method is implemented will behaviour change. How does that not maintain bc? On 15 Mar 2017 11:36 p.m., "Ryan Pallas" wrote: > > > On Wed, Mar 15, 2017 at 4:33 PM, Marco Pivetta wrote: > >> It's the only way to distinguish between set and unset properties. Also >> the >> only way to get all properties from an instance of an inheritance tree. >> Also, it's covered by tests that were explicitly added to prevent >> regressions on this. >> >> Same as all similar discussions before this one: need an alternative way >> to >> do things before proposing a BC break. >> >> > As mentioned in previous mails - the intent isn't to change existing > behaviour, but to provide a way for a class to override the default > behaviour. As long as those classes you are casting to array don't > implement __toArray they will behave exactly as they always have. The only > concern then, is that you might be relying on a library to not implement > that function on a class you are casting. > > >> On 15 Mar 2017 11:27 p.m., "Kalle Sommer Nielsen" wrote: >> >> > Hi >> > >> > 2017-03-15 21:41 GMT+01:00 Marco Pivetta : >> > > This is a BC break due to the fact that the `(array)` cast is used to >> > > extract property information from private properties in library code. >> > >> > Yep, but then again that is more of an >> > undocumented-not-really-supported case afair, if anything then >> > Reflection should have the APIs to officially allow that, although I >> > am still skeptic of this. >> > >> > >> > -- >> > regards, >> > >> > Kalle Sommer Nielsen >> > kalle@php.net >> > >> > > --001a1134feccd43b81054accdd06--