Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108384 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 11205 invoked from network); 4 Feb 2020 16:01:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Feb 2020 16:01:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 220141804DA for ; Tue, 4 Feb 2020 06:13:30 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE 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-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) (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 06:13:29 -0800 (PST) Received: by mail-wr1-f66.google.com with SMTP id z3so23290009wru.3 for ; Tue, 04 Feb 2020 06:13:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=++yE7hfBHFRfs2y2tFY1007rzLKKq/uQ4d9JTl36s7c=; b=J/5GgQ/1B17aDEdhJOJVqhosq5SLYyYdxBmyfcQncOafXMwyftwOGaZlSCsjusOXpn yONX9ioTXO8mvnL8SEnKUYEIKJnQMieoCnv/21WJ4MOrYCkioB0KpSlqelPAYHkx8vut 7EO57C3/1bC0a77aULINNR0za7qgDlqQCimWdA4rHtKJAps/Q9B8O+6xUhb2QAye+VAy /6NuKNWBvg/dMq9GUnWMfBOlC4ea+hp7eobS6Bnh06Pc7lhpTtKw/bkj1VBX4SFJxZB8 RW8/CCyQQ4ZMGSsCDkuSECqPjcYGlFJxQFEVBrB7S0IjZPE4YR0rUgSFUGmFjKsaDCcA D/OQ== 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=++yE7hfBHFRfs2y2tFY1007rzLKKq/uQ4d9JTl36s7c=; b=afMztzzW684RHRocK3bKlOmKqNfwJ6LVmFaa7wuu0zJYeO0DygxFyjcH0iZml4627h viPAT7ZLZWWluLirN4SkUryQz0LCKowjawzBDTce6EWGPKwV3bIXIfXwpekrSCZRuT1p FvEjW7ZVY0IOfhMVe4d/LT5Z4CKVx6g9rqib8WpUoOZ2phub0KOzxBjsgIWe189hvOqE qPpOeT5npKAiTfj8Q3Aorlh3jrQJOquBIefvB+HiVWVmI5XdZJUdsZ1ZEa0bD1tPiTo5 sCzKWE6qENcn1ZQtb5Neie8I30XGUadYSZCsnc6/RoAv9Va7rHpiLRJY4z/6kqjsdw+L NOdw== X-Gm-Message-State: APjAAAWEibPBDrK4p9SeNSx1nmDmRMiu5f51ZcgehPn8DQSMMtd91nGK VzLsQ55sqbHAl0PFl1ePM/LihpyZRzvvWBiBzhqr2w== X-Google-Smtp-Source: APXvYqwcDrw0SrPiIjEuhMt8oVl6AOHdZnLH87pD0e17DGxMeuOxGTxtuwt/CFr0yzj2KF0/WiNiyz9SVZGFqE/O10I= X-Received: by 2002:a05:6000:128a:: with SMTP id f10mr18200319wrx.116.1580825606859; Tue, 04 Feb 2020 06:13:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 4 Feb 2020 15:13:15 +0100 Message-ID: To: Marco Pivetta Cc: Steven Wade , PHP Internals Content-Type: multipart/alternative; boundary="000000000000bfc444059dc0a45f" Subject: Re: [PHP-DEV] [RFC - discussion] __toArray() From: kontakt@beberlei.de (Benjamin Eberlei) --000000000000bfc444059dc0a45f Content-Type: text/plain; charset="UTF-8" On Tue, Feb 4, 2020 at 2:43 PM Marco Pivetta wrote: > > > 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. > I believe the definition of BC break is "can an existing code-base run on the new PHP version without changes" and here the answer is yes, since __toArray fn's are not used by any existing code bases. What you refer to is, can existing code work with new code using this feature, and then the answer is indeed no. But the same was true for example for typed properties, which also requires additional handling in most meta programming libraries, and many other new features that existing libraries needed to adapt to: namespaces, scalar type hints, return types, ... --000000000000bfc444059dc0a45f--