Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98551 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85876 invoked from network); 15 Mar 2017 22:40:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2017 22:40:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.171 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.216.171 mail-qt0-f171.google.com Received: from [209.85.216.171] ([209.85.216.171:34238] helo=mail-qt0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/34-38004-2F2C9C85 for ; Wed, 15 Mar 2017 17:40:50 -0500 Received: by mail-qt0-f171.google.com with SMTP id n21so24714986qta.1 for ; Wed, 15 Mar 2017 15:40:50 -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=nxxzObBb39IvDPsbMLJcxTHV2oCdHW98DMNu1EMQkOg=; b=G9F9A0TsYgJ31iNA6/4DoJ8VE38AIScS4EQwA5CFw05zdjJd4Ryj58YUyMuwBwXVwP JFE4+HbPTRIEjeBNwdaoILJByMk6ot4Po5xfXcUy5xbCqh7OZ4/FpwmD9h/OA48J05B/ E1oiPBhVhjwPxwNsJNcoaM1qziFgqh1JxNJrH0AI0t1sFOchO9TM9y9Z+DiDE4EOQurj RXSWAljjy6oD3eI/Tdq5kguxn1ghfwfXvBELP9fSamk961kam1A9hKbQTkvk9a79ig0c 6Y9AX/ud7Ie/4Kfpx/i8zxMewFwReEjDySjYwQWDNTMlWJXCSkWtSeRjfhgUxRJ8nU8f sn4g== 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=nxxzObBb39IvDPsbMLJcxTHV2oCdHW98DMNu1EMQkOg=; b=qmD9Z6lfRcxcSdBkBc1zaO0OIMi8+7gEBdsIA50XWcQN5qd9qqlEXDokVI2qdYQhuX K1d3CQZUX7HtzKxkQaQrekXG3iZqwoER4Ijs1uMDXfe5vsKe252YlQb3xYrKgklYxhiQ hVypNiMRUpo8b3KEKxjoC7PzIwq43WoL1aDiwQvSFld+Xdq8+WMHeTSvhn99VynTIJM4 sNYkgn9T6n8h3w6tYmOPBCbDePpBMj7GThcstBRvFn7DVUTlpIfDsgKjGyxV1PFSLMab ToV0/5xcM8n+4inpop4Mx7GrMkjRYl/r6rvIrp+6t+TOXnwzCHBRRJm11yffke6R3t2T i3QQ== X-Gm-Message-State: AFeK/H2gFt1SIhjTipH9v5GTula9poZgQQWUCAn4j03M/9dkAEtrOrZm8QUxkzLKyJTseIVmIYDWDzNydgpa0g== X-Received: by 10.237.33.143 with SMTP id l15mr5259442qtc.222.1489617648044; Wed, 15 Mar 2017 15:40:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.44.70 with HTTP; Wed, 15 Mar 2017 15:40:47 -0700 (PDT) Received: by 10.237.44.70 with HTTP; Wed, 15 Mar 2017 15:40:47 -0700 (PDT) In-Reply-To: References: Date: Wed, 15 Mar 2017 23:40:47 +0100 Message-ID: To: Ryan Pallas Cc: PHP Internals List , =?UTF-8?Q?Beno=C3=AEt_Burnichon?= , Kalle Sommer Nielsen Content-Type: multipart/alternative; boundary=001a113d0ce6c34efc054acca2f3 Subject: Re: [PHP-DEV] Add __toArray() method to objects that would be called on cast to array From: ocramius@gmail.com (Marco Pivetta) --001a113d0ce6c34efc054acca2f3 Content-Type: text/plain; charset=UTF-8 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. 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 >> > >> > > --001a113d0ce6c34efc054acca2f3--