Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115984 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77368 invoked from network); 7 Sep 2021 08:44:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Sep 2021 08:44:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6AFD5180505 for ; Tue, 7 Sep 2021 02:22:22 -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_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-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 02:22:21 -0700 (PDT) Received: by mail-ej1-f42.google.com with SMTP id x11so18455705ejv.0 for ; Tue, 07 Sep 2021 02:22:21 -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=gs1ut4dqKjS5V9KgNYDbpl4KW78Dh+z6MphM7OzQVas=; b=CGspRS9TFqkPxiTbPQQAJPqBUg06oYvgSpYFsyPCisJexIzdedTaVfBZaAS5PjFSet GMvEMQJr+p7AspRYFng8nScB9yReBD5WJVkAzdCI0qVg+0j19+mT7pq6Ol2FQVpKHbKA QL50IkmT8fVdwZimjaTDZY+Sd67K23zVho0a6pCoGNi7O296TZrMeSIPLwItQEGN12Gz QxxOg32gR1tkWTk0SxomaBQ82dErc+f4dDlbb3Qdqw/HIcJ9YLSOXqJQS2mXRMzwX6ZA 8u9/J3p9v2e56DZ7lK1pvayd3oo2SVHLHjCgUo9JcKLHRs3dw69UPDcKQFrvrgWaPAHv oUQQ== 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=gs1ut4dqKjS5V9KgNYDbpl4KW78Dh+z6MphM7OzQVas=; b=I8mlF8EaVFw1uOqc2wB087eWFd4q/crAAtQwBESdX0gr4S5tCG+WmaT0m7SJzMPrst eJOEiVHlM192sctJX2R4mUm2cIYh15pmq4ICfjhMBBDutSkW4uzDCAQHmWYOtC5ksaVa +iuLYa+Gpv075o5qx1t6Vh674cmWYFp/x90HlgmHhF+V1QP2IO46NkuwoFmHqrvc1fGw Te5TxgZ8Dd4FjI/JJOQ3BmzdX1Dyfbwjl1eKGcAjG7TJRSRQmoxLZcxjHTm3akJimvs+ U9OyM7OZGMs860TyZfMLjd0NdAni7utm+y4bAqSERfNRXQ9ZZr+AE2RXNN+ufBMonx8r OGoQ== X-Gm-Message-State: AOAM532W2cnYt43UpQsRVeRiZNsUMFNrV0Ml4nEy4DdmVwnq0ph97LAL gi+xQ1LTnLYdpkZqrA9jCA/GQLyC9sc0N2d+ZNTAFEMV+pw= X-Google-Smtp-Source: ABdhPJxRZ2KqE1fXJ3hjtsVnAJQWMjgs2urMUIkybjI5PmjxwrKCPLmr8+CIJSU8pdouuhqB/pYCuvS9qZNZJNEoMYw= X-Received: by 2002:a17:906:a012:: with SMTP id p18mr17907513ejy.331.1631006540454; Tue, 07 Sep 2021 02:22:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 7 Sep 2021 11:22:04 +0200 Message-ID: To: Kamil Tekiela Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000078607605cb644da1" Subject: Re: [PHP-DEV] Alias stdClass to DynamicObject? From: nikita.ppv@gmail.com (Nikita Popov) --00000000000078607605cb644da1 Content-Type: text/plain; charset="UTF-8" On Mon, Sep 6, 2021 at 6:50 PM Kamil Tekiela wrote: > Hi Nikita, > > I think this might be a good idea, but I would like to propose yet another > variant. > Replace stdClass with DynamicObject and keep stdClass as an alias. It can > be deprecated in 8.3. > If we only add an alias, I am afraid that it will not catch on quickly > enough. What I am proposing is that the cast to object will create > DynamicObject by default. > > $arr = [1,2]; > var_dump((object) $arr); > Output: > object(DynamicObject)#1 (2) { > ["0"]=> > int(1) > ["1"]=> > int(2) > } > > It will break unit tests and it might break some code (e.g. `if ('stdClass' > === $class)`), but it will help people understand what is the preferred > name going forward without deprecating it right now. > My only apprehension with making stdClass rather than DynamicObject the alias is the widespread impact this will have on extension testing code. https://github.com/php/php-src/pull/7475 shows the approximate impact on php-src. We need to update references to stdClass in var_dump() output in more than 300 tests. We can do this easily, but it will be an inconvenience for 3rd party extension tests that need to deal with more than one PHP version. Apart from that I agree that making DynamicObject the actual name and stdClass the alias would be better. Regards, Nikita --00000000000078607605cb644da1--