Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108382 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 3250 invoked from network); 4 Feb 2020 15:35:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Feb 2020 15:35:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3218B180210 for ; Tue, 4 Feb 2020 05:47:17 -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_H3,RCVD_IN_MSPIKE_WL,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-yw1-f47.google.com (mail-yw1-f47.google.com [209.85.161.47]) (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:47:16 -0800 (PST) Received: by mail-yw1-f47.google.com with SMTP id z141so17138653ywd.13 for ; Tue, 04 Feb 2020 05:47:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=pPHF0LpY40EuqYMcozmbqr/cgpv7l2hRgXg8y5/+nD0=; b=QNokUQ3KVjhbl26fRHZMxIQBKMrmIK6SwxBzN3cxyTEObZyv4RxpzWD74M5rJZohUH e/ciJ4+oaSmWuZGlK420n70H1xF891NVTx7X96m/B9OqZUV7hZqBU1FXnrJYl5ymWStp GQUVzu5RXzBczN+m9kiC50iofDMuZhuAWyMs0tMzXiMy6oK3yxe8OTa6U3IGfLO+GOqT 9CWQ86xF5XOw+AMxhAnnHanHkdVBXsCgft69J4qmarl0cYAypPQl46QSq6rBLeKdkJRq RzVOVGRjjdB89bOpPcyh7hmlHXFUGsabEmZPlZakgx09NIULeO06x3dYS/F1GWVHcr8b aixA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=pPHF0LpY40EuqYMcozmbqr/cgpv7l2hRgXg8y5/+nD0=; b=A+jAoYdR4qnrukA97EW782zdH4CCNWzv0pKusNG3sLiwgZtHzShW09M2mnrlkreBcU 2rPgG9KaOHAPDK6sGwPwZsJwT1uW0+1XloUmXV4cZYcb/uCi+CTgtVkRpumtOUJLY8kZ cukIteQ3Ub5YFZESo+Ff/xG5b0d8yqJOdUh0p5rQ6UOAma3/FwzwPGXYYtG4RUWtFksF OaEZYTUELTgqZK09pcsVDcCc7ymeNW4t9D6TdxpAAG+9cIY5hIJ6/eSs4pIuI+TtQrNJ FZekMHrvV7p935tmkfwMPbg39AHr+pMjIskZOwWcdZk1UqUq7hSwSYF4tK8iToBNiRXu j4mw== X-Gm-Message-State: APjAAAU7WR2vJ+ZT+/kp2gc6nfpt5nLZKdXq1vukklnHGb6ennsPzWM6 RKMQmWplGQUSokEcoA0T3pQ= X-Google-Smtp-Source: APXvYqx0OYnoAdcSN16szKDpmm2AIdhP8IgcLiaXyuSnqjOf2J69ssQmphVd7bUOViShMcpOYu1ZNg== X-Received: by 2002:a81:7c7:: with SMTP id 190mr5694187ywh.45.1580824034789; Tue, 04 Feb 2020 05:47:14 -0800 (PST) Received: from stevensbbookpro.lan (97-95-205-109.dhcp.sffl.va.charter.com. [97.95.205.109]) by smtp.gmail.com with ESMTPSA id h193sm9718148ywc.88.2020.02.04.05.47.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Feb 2020 05:47:14 -0800 (PST) Message-ID: <283F90B7-2B84-4D24-B157-05B828369E26@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_284CE183-3618-4A28-A09A-54B735DB20DA" Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3601.0.10\)) Date: Tue, 4 Feb 2020 08:47:13 -0500 In-Reply-To: Cc: PHP Internals To: Benjamin Eberlei References: <516080A1-D777-49BD-A4A1-9978C2D558CB@gmail.com> X-Mailer: Apple Mail (2.3601.0.10) Subject: Re: [PHP-DEV] [RFC - discussion] __toArray() From: stevenwadejr@gmail.com (Steven Wade) --Apple-Mail=_284CE183-3618-4A28-A09A-54B735DB20DA Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >> 3. The weak point of this proposal is the by reference handling for = sort et al. Counterpoint: if you pass a variable to preg_match, then = matches gets converted from anything to array, so i believe by reference = casting should change the original value (https://3v4l.org/XUJ5m = ). This is weird, but consistent. >=20 > The proposal states that =E2=80=9Carray functions that operate on an = array by reference such as sort or shuffle will not work on an object = implementing __toArray() under this proposal=E2=80=9D, and IMO that is = consistent with other magical casting behaviors and I wouldn=E2=80=99t = expect a class implementing __toArray() to be able to be written or = referenced like a traditional array. >=20 > Passing an object with toString by reference will change the original = variable: https://3v4l.org/77lov Ah, I think I see what you mean. PHP=E2=80=99s making a copy of the = string variable once it=E2=80=99s cast, so it=E2=80=99s no longer = referencing the original object that implemented the __toString() = method. I imagined the __toArray() would function the same. Once the = cast is called on the object, it=E2=80=99s a new array variable and can = be acted upon as such. What I was trying to get at was that the magic = method does not give the ability to write to the original object. If = that=E2=80=99s not clear then I need to update the RFC.= --Apple-Mail=_284CE183-3618-4A28-A09A-54B735DB20DA--