Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116014 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39859 invoked from network); 8 Sep 2021 16:32:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Sep 2021 16:32:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2CDD018053C for ; Wed, 8 Sep 2021 10:09:46 -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.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-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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, 8 Sep 2021 10:09:45 -0700 (PDT) Received: by mail-pg1-f172.google.com with SMTP id s11so3284943pgr.11 for ; Wed, 08 Sep 2021 10:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jwHdGiSCwCYVCe08ybpitrIfRjdNzag293icI5qR4lw=; b=KmVnh6PztGQDsTY7m18fC9D4uchiSvlU/3REUzvPLQGa5SLEhMnW6LR7C5hNt3UAjf cuU9lG0BJyMa/LRjTTiI5EbW5PhDEKVL9yxTWWuwKbhmMrpFH18xws4neRtzQO792eEN bAEvf/DSLmaEsRG9jdpDcGLvJ3p++1gyNKv5eHajSNn9VvEzMRUIAyGldKZo1yoQ/YDp vayl2+jpP0o+NHidZJR9SnSL8OoX5uKArSh9FeUFXiE4sKBen/x3BNaOf5OBjBuiMsMk c7BEIcWqD/eB+o2dJDJV6+tmqeJ6eRM8kujN7tYw4+pkifTVtqTY3Jthht/KTNq71fiN kEqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jwHdGiSCwCYVCe08ybpitrIfRjdNzag293icI5qR4lw=; b=oDfDnJoZrbxuzxQ1x1LEVZ5Bky1NbwWXkeEkBXTtqFAGT1lW34C6YW3h33JbGjoXLB vY4sAgwwXV48v+T3sX2E9/I1WfkMX5BVAXip7l8GVDfvHoDZ6GY/f4f6qGoN1VjHT5jK w8sg5Xww8KJHEdGMtOvW0z3LtDyiDtT/R94e7rc9yYGUPzcpeN4MXEGSIbNNuBx9YBLX d0BAYclR8Y9vHUfkb4CcjYnQ5rY7j/DJiDLEIVOAbzvgNibzESH6sXCmISN39kepHIuJ p5D0XnT/OxhZ2vQ63RMuhwGFE8jtK+D1zcHx9Ohj50bLMrI2Lp/K7n0V8oE7tcrkqi4G FoNA== X-Gm-Message-State: AOAM532CktHjOWokd7YsJuL1XNdOneveyIo6m1a0UFswJq9rgge6KfIo 4C3ujtwNotgovoYbAxi+uN7ehi3Sctv6+WnnUNtEK3Y/Rl4= X-Google-Smtp-Source: ABdhPJwASOjPX9287qzLuf01xW8o9FyqftVA4+XnyXYrejnUNtFbqynrgGe3hHXHcZ23zJJmuvQU55Uuna4T+kEY5Co= X-Received: by 2002:a6b:fc1a:: with SMTP id r26mr759948ioh.30.1631120529036; Wed, 08 Sep 2021 10:02:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 8 Sep 2021 19:01:43 +0200 Message-ID: To: Nikita Popov Cc: PHP internals , Rowan Collins Content-Type: multipart/alternative; boundary="000000000000b817f905cb7ed70f" Subject: Re: [PHP-DEV] Alias stdClass to DynamicObject? From: kjarli@gmail.com (Lynn) --000000000000b817f905cb7ed70f Content-Type: text/plain; charset="UTF-8" On Mon, Sep 6, 2021 at 5:28 PM Nikita Popov wrote: > What do people think about adding such an alias? Is this worthwhile? > What if `DynamicObject` becomes an interface instead of an alias? In the future `stdClass` could be deprecated and replaced by anonymous classes using the `DynamicObject` interface to prevent manual initialization. I feel like renaming (this seems to be the end-goal) will not solve some of the problems that `stdClass` brings to php. Hamza Ahmad brought the interface up in the other thread: https://externals.io/message/115800#115806 . ```php // core php interface DynamicObject { /* ... /*} // in case of removal, legacy support could be kept as class stdClass implements DynamicObject { use DynamicObjectTrait; // perhaps also core php? } // a library wants a DynamicObject for whatever reason? final class MyCustomDataObject implements DynamicObject { public function __get(string $name) : mixed { // as a developer I now have full control over where // this data comes from and is stored internally } /* ... */ } ``` To me it feels like making this an interface gives PHP more flexibility in dealing with this in the future. One intermediate step could be to turn `stdClass` into an interface that extends `DynamicObject`. 8.2 could deprecate manual instantiation of `stdClass`, meaning that in 9.0 it could be removed as class and turned into an interface, reducing the need to update code relying on the `stdClass` types. `get_class` would still return `stdClass` in 8.x and thus not break when using a `DynamicObject`. --000000000000b817f905cb7ed70f--