Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108379 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 98699 invoked from network); 4 Feb 2020 15:31:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Feb 2020 15:31:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 22E11180210 for ; Tue, 4 Feb 2020 05:43:28 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 4 Feb 2020 05:43:27 -0800 (PST) Received: by mail-io1-f51.google.com with SMTP id m25so20911607ioo.8 for ; Tue, 04 Feb 2020 05:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qPmx5BmFxTG8ydDMnpdQpyuyAEafad7/KD+EIyL2cDI=; b=LKgkd2LxW4pe750op+i1QTRPw6La90cNiztlH5ypcRGgGewTzOyGdJP5/nV/gw2ymc qK/NQHW0KsI237e4fSH0YrPrOq60n6zuDlzvlBKzGSuhjKYwpXn3o21Zh+9bKOS10wDF WFY1CjoRc9UU2ZwBgRShnLgfhLXL5Ay/qtXsT0S8nvJu5hpB4/1SojLfC7hoyb3aXvIn UGiG8ylIJzjpnVBZXktF07CntKsPznoAZNjcZnorhWNXDgJ3WoEs4zVZKSECbIL2YhYg 653MgYfWHKtqcTfLVZHnYRHrgfhShGuGMLXNgtj5YGEtBg7eT6hR8vtCbFQ96/8aXUgK bIPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qPmx5BmFxTG8ydDMnpdQpyuyAEafad7/KD+EIyL2cDI=; b=IvT3zViMBiKYHnTL1HYRysDNUOYFJ3C/1/krMLDrjp/cmu57tByhXxERkcqblDGg+w +PC0Udhb2ohcbR/WcWTobPSDExLTo4RWo8y7J7fc2ji9p8Ggu1F+7FEbvNj6gN2B21vi 7/ng0HVZs+DBLi50NMvIjdnCe9Zt2JLqzysR9CDrdXZ/zcFPFv8ygi05qb661KsG67/c fT9wcyS3DwkI+kKOozlH74vRkptHurs6XuiSqG1D7mBoqPlH2JeS9V8RW4HCUPxmBkmf vG+jgOKBHmvWGFlUanMWGeH4kJa7KHTH0WOGL+d1f3QVxfVwPeDxB8+BiJ2lcG70cNYr p/og== X-Gm-Message-State: APjAAAXVSTaVNi83AwUXw2bIX+leE90zPqIYs2JenIpFYIhD1t26Bz5Y fs1r/2ayCoAPLu6a9OMjSO6jU3SEJ4d0RI4KuAs= X-Google-Smtp-Source: APXvYqyIctRQQc1vQ4X+45Tfs+nhXM89UWxFnDAyF/GIXz4Nc1GEj5ICvl59Pgn/1GYRLI6WdOzp/mr2SyleByNDYCI= X-Received: by 2002:a02:cca9:: with SMTP id t9mr23116618jap.142.1580823806296; Tue, 04 Feb 2020 05:43:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 4 Feb 2020 14:43:14 +0100 Message-ID: To: Benjamin Eberlei Cc: Steven Wade , PHP Internals Content-Type: multipart/alternative; boundary="0000000000006d47cd059dc03918" Subject: Re: [PHP-DEV] [RFC - discussion] __toArray() From: ocramius@gmail.com (Marco Pivetta) --0000000000006d47cd059dc03918 Content-Type: text/plain; charset="UTF-8" On Tue, Feb 4, 2020, 14:36 Benjamin Eberlei wrote: > > > On Tue, Feb 4, 2020 at 2:10 PM Marco Pivetta wrote: > >> Linking (again) previous discussions: >> https://externals.io/message/98539#98539 >> >> `__toArray` as a magic function call when `(array)` cast happen is a bad >> idea: it is a BC break, and it removes one of the very few interactions >> (with objects) that didn't cause any side-effects ( >> https://externals.io/message/98539#98545, >> https://externals.io/message/98539#98567) >> > > I think we can't classify it as BC break, because no existing code > implements __toArray at the moment, and hence it will not fail when this > feature is introduced and code gets upgraded to newer versions. > It is a BC break because it changes the semantic of `(array) $object`: the operation is no longer stable between two versions of the language. Code relying on `(array)` behaviour (stable) requires additional reflection wrappers to check if `$object` is **not** implementing `__toArray`, and then the operation can be safely used (or an exception is to be thrown). You can most certainly make a new operation, such as `(toArray) $object`: the cast operator is new and isn't changing any existing behaviour. --0000000000006d47cd059dc03918--