Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115809 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 73619 invoked from network); 25 Aug 2021 12:01:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Aug 2021 12:01:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1D38F180504 for ; Wed, 25 Aug 2021 05:36:02 -0700 (PDT) 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.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (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 ; Wed, 25 Aug 2021 05:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1629894960; bh=TMp+TagPI8N3N0YinEhpIprp5wCnefdaxuZ86D+eFlc=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=SyhiADl/uKNDqVG4usF2vxoEXeQFRrL/T2hElXj3YY0i/ojQxyrtJHpfUP3mmCPUT 1cnxSNV4g/mtToNdeBEn2ZyZ9jQy3U1+6k5TVIOivdQqBRuM7qN40Knhryzp+UAMsP rZvXdVdclLnLUSsHUIQTSH5Dh6zvhM5c9eid34LA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.120] ([24.134.51.41]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MkYbu-1mjvDS026o-00m2PI for ; Wed, 25 Aug 2021 14:36:00 +0200 To: internals@lists.php.net References: Message-ID: <20c3c14b-8132-1114-641c-d07e3cb54b4b@gmx.net> Date: Wed, 25 Aug 2021 14:35:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Provags-ID: V03:K1:e3RYEOAN9nG0dk0pFE5T49ocdhsxY2qS7ralYsTfN/w/O+jd3Ll kWDwl3bGwddovfpj2V87EJEIi36PbmlVfH2GzPsynRywRLoD4bw5xIXnphM2xfVao4hhyRM yFpyUf4S0tA1sKtB+AZwc+4TsI7zoOf2IMp1sgYbRCphWKjhsJMvlWHE/fxHYWiHs6RZTtW ybvtxmQUPqYpMBnX+1FDw== X-UI-Out-Filterresults: notjunk:1;V03:K0:73DQRwUGFhY=:MyjHUTTWjY13EDRkBktuC1 /aAuO8c7YAYS/zYi944eRcjgl4hJfuR52OT5znkTwHrIe4P/b6Py2rtaXWuOeRGcRv6rKX5NV misAHA13YgzbuXYBnR6TL+PXvXJFu4dLVpDTGYwWytqBFERNbPzCNuUaaQXQf5VgxX/AYjSIp ZbD24vxY20w732yZ8uMh91t/Zl8Eaz02XwdpgLSrIllXI9FH5AAYpJTQt7koNL5NjsLkxM0Px ypLmqQpiGZ3FLCOTaUgmW9pxmxXI9KCS5Vui/zNgvj+kzzDL/WSNSMz7p1a31vuRiM/izk/Ln 8/Ltg3GRhg43fJssDZeMi2gbhNUyYDmtLQti8kACT5eVdeWp54+fT8BaWjNQyrtKotHXpAMbc GJ+y+u+5f2bm9eoPS5ZBK1D+MZgZ+EmExhxbXLOBOE3NEa7/SAYIwkc5MjEkYUegSq6iD9n0Q bHVIybHuRFeyrhy2THMcJe9qCaYwAHJPYVzCLfNCcYEb46wD8QusIpSpVUMG6yFPGsFVsKdP3 v359qa92Xh2LbufrsId20evsPkDba4GusuHzgry2CRDp7zvmqZ+mYwcqiJITZAf8EyRhQmhBz 7NOwsRmK8DovfQfsVjksej8A1SonBQh80Iw6pNRFK/AqONINK7Y+YW57pINPTtwIiVucQ6hN4 3XQzd2hdJL0+fGn8meaL/ivziCABqnEl/gRZa+NE3CaIxwWcsKrpmKiPVbBMLxYXYEt2PB9GG 7uQYMU9PDcjf6T0Hs9+FppZP4ukQNDiL+yv8KDstIz8HqHvsugafNApETWr1CW0trzw38wM2e Lyf8QvwT7+igN/mGiSSitytrzBSjay53yopjgU6gSN+cLISBBowhku5gqX96Fv4B3hjd2cx8m zLFnEGQqdutmkBU/IBfeqzHGiWkzNhiSEqJbBxt32nSScKrRGb6tT2X70UX90e2GePpwUDghD v5JvCSNKMDTHzsRn6hD4fBFNYgeRguvizVyZM9s70QYOu+HhR9rPk7adY2G390+NYGnhYEq8y wAtJTQInJPpcye8V1vWRWxhD+OpGux0sn0ed6r275BfjwVI3aIAg0WENAoe0JIq6MmOk5pNHz kxcGRCnvK5MwqXsgFPPfqAaYgrsCPRmD46CX222xYVGfR5hYHLKhqCm6Q== Subject: Re: [PHP-DEV] [RFC] Deprecate dynamic properties From: a.leathley@gmx.net (Andreas Leathley) On 25.08.21 12:45, Rowan Tommins wrote: > * Adding a parent to an existing class isn't always possible, if it > already inherits from something else. Perhaps the behaviour could also > be available as a trait, which defined stub __get and __set methods, > allowing for the replacement of the internal implementation as you've > described? > Couldn't this be easily done in userland with the ArrayLikeObject (an example in the RFC) or something similar, just done as a trait? Maybe having an example trait implementation that basically "imitates" stdClass in terms of dynamic properties would be helpful to show in the RFC, to highlight a possible resolution path for legacy code with this problem. This could be an example implementation: trait DynamicPropertiesTrait { =C2=A0=C2=A0=C2=A0 private array $dynamicProperties =3D []; =C2=A0=C2=A0=C2=A0 public function &__get(string $name): mixed { return $this->dynamicProperties[$name]; } =C2=A0=C2=A0=C2=A0 public function __isset(string $name): bool { return isset($this->dynamicProperties[$name]); } =C2=A0=C2=A0=C2=A0 public function __set(string $name, mixed $value): voi= d { $this->dynamicProperties[$name] =3D $value; } =C2=A0=C2=A0=C2=A0 public function __unset(string $name): void { unset($this->dynamicProperties[$name]); } }