Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115997 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 23968 invoked from network); 7 Sep 2021 16:51:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Sep 2021 16:51:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DA6A11804AA for ; Tue, 7 Sep 2021 10:28: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=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, 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-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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, 7 Sep 2021 10:28:46 -0700 (PDT) Received: by mail-qt1-f181.google.com with SMTP id s15so8571858qta.10 for ; Tue, 07 Sep 2021 10:28:46 -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=7UVbAFJap9xMbDjo3n5SXXpV4Ry8iN8PGwTKsM7jBU0=; b=CbSkZHYRt8tvcYtL+SB6pqrBM8XqFRnJVPFVXo6T7gdJaPwEXikHAtjlv8wNN8S10q GBxizyriZl+Ozrv3vaIc81an/CTHjChfkV/g3y/VchYGNHZvV/pHGYHaQ9x0MEgRScsT 7By4M8Tu+76c80JRjQvWhASJpoMrpjesMezwY/01roYqpSNyjhRRIjRvU28kf2XvkaL/ T6KCQg0tjDwDhDD73q6R4T4jju1HUfb45HVaiYg0OIUztLNDeTnb6WhuEEeFvh3dusVA xdJ/V213j4QfhoWFt6cYu+oM9//Hfq9dh5Tqv74OVMj8eV2pejYCEcRfJUemXGz2E9mI +SoQ== 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=7UVbAFJap9xMbDjo3n5SXXpV4Ry8iN8PGwTKsM7jBU0=; b=sA2kDJZVSewbMAN/SWuLqFoL+1FvX8zdc+dkEB9VQwV6JpOx25TZF3R3AIrU2Fj9Ub SoHVTlHLx0d53nlJRCn8BD9arm18kJGLEQzu0R6Nj4L1Yo2rnFwm6R0netW6brJZ1OSu nMguDSvuI7PDC9eyZpaxd0DGubXdwypWN+wv73/Bt6cFhr1d5BFLKmKvGuthZAVlO9hQ 5b6GyTOk6ZgxvMJfpyQxjA/xOrW07HelLZVZTiM/gQGqcf2zcvsuIIPqxVmi3FVfxf3B NsHGQR81gQG7zoic/RWxx0ZKvaK/B/9krMQ4e4plrX7VkOF/A7rz2JelBQupx3k1AZYJ 62ng== X-Gm-Message-State: AOAM53256dCjZEU5Y7Wl3ZCJdr5uws3y6yY1X7tjYN8tl62NqikZ9vEG 7EQUogJOFSitdoagrMzdns/X6tbFE5pkZx4isovWPr5yrjCrwh3vPj0= X-Google-Smtp-Source: ABdhPJxGUO7nN07W/cJjs5VvMzmoPpSzD5KzPmdx/ZjkXM7/KDfJUeuEb5Rxm3k2Jp5KgYTwdSjgt6p8cX4/qR/4b58= X-Received: by 2002:ac8:57d2:: with SMTP id w18mr16689342qta.67.1631035725078; Tue, 07 Sep 2021 10:28:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 7 Sep 2021 18:28:34 +0100 Message-ID: To: Marc Bennewitz Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000000265e005cb6b198b" Subject: Re: [PHP-DEV] Alias stdClass to DynamicObject? From: tekiela246@gmail.com (Kamil Tekiela) --0000000000000265e005cb6b198b Content-Type: text/plain; charset="UTF-8" Hi Marc, The name seems to be ok IMHO. Even though it is a class, the main use case is to denote an object that was created dynamically rather than through an instantiation of a class. And I know that a lot of usage comes from people directly creating new instances of stdClass but if you do that then you can use proper classes also (with Nikita's proposal to deprecate dynamic properties one would have to use a class with defined properties to do the same). It's not unheard that a class has "object" in the name. e.g. https://docs.oracle.com/javaee/7/api/javax/json/JsonObject.html or https://docs.microsoft.com/en-us/dotnet/api/system.json.jsonobject?view=dotnet-plat-ext-5.0 The name DynamicObject is also used in other languages. https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.dynamicobject?view=net-5.0 The word "Dynamic" semantically explains the purpose of the instance of such class: it has no fixed structure. We could call it Map or Dictionary, which would also be fitting, but in doing so we are opening up the scope of this RFC. How much more functionality does PHP need? What would be the goal of it? PHP has tons of functions for working with arrays. If we introduce another type like Map then it would be expected that a set of methods be added to it. This sounds similar to scalar objects. And while it would be nice to have such kind of functionality in PHP, it would also be a lot of work to implement it. If we already have associative arrays, do we really need another structure to do the same thing? I think it would be prudent to first understand why people are using stdClass in the first place. From my experience, most of the time people who work with stdClass don't expect it to have any methods. It's just a container for data just like an array, but with a different syntax. It's not much more different than an anonymous class. The goal of Nikita's proposal is to retain the functionality of dynamically assigning properties to an object after deprecating dynamic properties on all other objects. The new class DynamicObject would be a special type of class that would retain this functionality. Thus, the name fits perfectly. A DynamicObject is a class whose properties can be created dynamically. Regards, Kamil --0000000000000265e005cb6b198b--