Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116008 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92726 invoked from network); 8 Sep 2021 11:23:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Sep 2021 11:23:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1BE2218053B for ; Wed, 8 Sep 2021 05:01:26 -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_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-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.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 ; Wed, 8 Sep 2021 05:01:25 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id 192-20020a1c04c9000000b002f7a4ab0a49so1106048wme.0 for ; Wed, 08 Sep 2021 05:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=eOBXD5R4+hxBGTAkXlR+m8B2LBSn9GoncFxg0HuzlcY=; b=W+vBF3gKgw2BdOPV+6QDeILuXzmgWgcQNy1YqSXOH9A7Po2JH9ADfDgiAPCA72vCxG LFMevkmpcRRaOgsytaPuO4pJvqIvcObU2HAQ4OWUDLNfwcGlgosOaPgI163JpLWgmHxR ZqhfTU2Kse5XAw2cPCw278OU8NoTIP5RMYpsqf0VT9aQ6nobpKOCCbv9a9o+x2z9DLPa mIhpB73/hmatJDaNrxXQdx9n2e+fx3N5H3Nl+Rmyikq4K65C0ECHuD9ZlYNHYgoHM9JV /wZT0+XA+XIF9lF6OCByPVBBXLoqP0uuLEWe4S/u4sXaIDyfjpEuu1Do7v1UYvAWfqTc 6UbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=eOBXD5R4+hxBGTAkXlR+m8B2LBSn9GoncFxg0HuzlcY=; b=pYiUoNtcsoFl9qUwuUCpdWzeICQLdAalOVr4mwLWhexw44X5aVRMq6hoYospsH7wed fceml63Ka7j0ELYNqlY3zHVUSiRcW0KJ/JF7L409RRWUd1GOBc/nEePI6VjpYzykagia Gf2FTF4Nty8umadvGDZyknJqQ4knHuYr5AhjHAjqoT66drU8iRXU38lAjUsLIU/6hmfZ USRLtaFj52Ru0Ip/ksgXxaYNeHCR/Sx5sF/84Pt4uekLklHCpgSDwfGhwXss49AmscMP BEHN1VjvuTEU6t55Ssg8c4Zb4NY1530K0ZBPEBlWiYMy6ZTifI3h8AJoWTMaBEOsXMPm eh9g== X-Gm-Message-State: AOAM531m1wQj86iVwNsEcw3TsaFTAT/v4/AI+t5dHXitCdi7+3qduFgL 9HG/xcfrgwu93tkppISSt6Wv7AxN4/k= X-Google-Smtp-Source: ABdhPJxhD10dG2JNDZtfCeWCk2On7S1uRGsOmf6fA6xNGJ7jApi3i3v4IX12xKPL0C4FpK0japY3wg== X-Received: by 2002:a1c:80c6:: with SMTP id b189mr3259019wmd.31.1631102484533; Wed, 08 Sep 2021 05:01:24 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id 17sm1810588wmj.20.2021.09.08.05.01.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Sep 2021 05:01:23 -0700 (PDT) To: PHP internals References: Message-ID: Date: Wed, 8 Sep 2021 13:01:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV] Alias stdClass to DynamicObject? From: rowan.collins@gmail.com (Rowan Tommins) On 08/09/2021 11:08, Nicolas Grekas wrote: > I'm reading the discussion about the side of the alias. Can't we solve > these concerns by making DynamicObject extend stdClass instead of > aliasing? That wouldn't allow an stdClass object to get through the > DynamicObject typehint, but that shouldn't be an issue since no such > code has yet been written, isn't it? I've been pondering inheritance options, but I don't think they really help - whichever approach we use, one of these assertions will be false: assert( new DynamicObject instanceof stdClass ); // false if stdClass is a sub-class of DynamicObject assert( new stdClass instanceof DynamicObject ); // false if DynamicObject is a sub-class of stdClass assert( get_class(new stdClass) === 'stdClass' ); // false if stdClass is an alias of DynamicObject assert( get_class(new DynamicObject) === 'DynamicObject' ); // false if DynamicObject is an alias of stdClass My guess would be that the name reported by get_class etc would mainly be used in tests and debugging, whereas instanceOf checks (and type constraints) will be used in actual "business logic" code paths. Existing code will expect "instanceOf stdClass" to work, and new code will expect "instanceOf DynamicObject" to work, so an alias (in either direction) seems the better compromise. Regards, -- Rowan Tommins [IMSoP]