Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116162 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 47184 invoked from network); 25 Sep 2021 16:17:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Sep 2021 16:17:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B98CE1804BA for ; Sat, 25 Sep 2021 09:59:05 -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-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 ; Sat, 25 Sep 2021 09:59:05 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id t8so37243045wrq.4 for ; Sat, 25 Sep 2021 09:59:05 -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=4Olc4CiTVARnfXVbgy+tNezRxFBRV/wISbICENFkiv8=; b=eJ9kGLWJCiaIDYO7w6LWZAjNh5Nf3uZeLrXAbts6pQlQyta4J1pGE2HAlkxK/7bC0t B+F1sSXsyYxUifIxkkl/Af8jsrgF5tk5QcfdIuYEUyz64MEJJESgw8dZj7vZG/x3e1qb xRueuCLntkKwb4B459Rxbtvod+wSJcGWsxoliKx0Ll/rNVN/o0qaKfueUkWIxHvagxDU cdIIR/NRvjNmxUSa8MVXRwf1MBncuXbxPPN0zO/M2okxXfXvbQSTvRVXrnrQ+iTPyt7v xLaFm/rTmh1NoAk6cW1feSvt0zF6q26V1Y7eQ4FuIYYDLY+JhpaD+vv5bdUXtTHbdDya rpAA== 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=4Olc4CiTVARnfXVbgy+tNezRxFBRV/wISbICENFkiv8=; b=RLGfgE0KSaK9ijvBhwG3xMXNKuuzSmwVrc8cYv3OYzY9hpSDsdzoBj1U1wVzmH1FVL 1gXkxjMjO4I5WEPmpSkLye04QzDUyAAUaJGheiNV87dj4oSYt/t9LNPWvLBk9TOQyD2l IoOFtAXKow/oWqZPsbvF4oymUgMUD8Lf2DZ8sSaIzFSgQI/BxD+pMgenwVv39GPvw0pT 3/UbsQvM+2SjTE1ukqMOwJdhcx0/GiK4WGQk5VNhR4uAgxrvQhUKLAUCwTefC5Wwi9oJ lMfYGhInH/ZVqRSPFPaVIQKvCtFm60uDac6FvR1IYd8Ee3zq4K5JQgrLoOt5uk3S9Nyb KJUA== X-Gm-Message-State: AOAM5330r2Yvury09KCQE7gsWJEH2pJ+yW1iIMC5DKo5IEBYPtF0d1Y7 RE0SD7z5am4wzDkQfMKGexcBQv+4zTQ= X-Google-Smtp-Source: ABdhPJxC0Ar8Z6BL1JxsSBwNEK+Qgs0cSFsEUWhpKaAu/C3U7vRW/3gYfCM0dQMabIy1p1uiIEG9eQ== X-Received: by 2002:a5d:64e6:: with SMTP id g6mr17414902wri.151.1632589142504; Sat, 25 Sep 2021 09:59:02 -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 z13sm13035850wrs.90.2021.09.25.09.59.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Sep 2021 09:59:01 -0700 (PDT) To: internals@lists.php.net References: Message-ID: Date: Sat, 25 Sep 2021 17:59:01 +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] Allowing `(object)['key' => 'value']` in initializers? From: rowan.collins@gmail.com (Rowan Tommins) On 25/09/2021 16:45, tyson andre wrote: > What are your thoughts on allowing the `(object)` cast in initializer types where `new` was already allowed I'm not strongly opposed to this, but am not convinced it's a big improvement. Firstly, as with everything involving stdClass, I would be more interested in a) improving the initialization of anonymous objects, and b) allowing those in initialisers (the RFC currently forbids them, but doesn't say why, so I'm not sure if it's an implementation decision or a philosophical one). Secondly, if you have enough knowledge of the structure to provide an inline default, then you probably have enough to be worth defining a named class, even if that class then implements __set() to allow additional ad hoc properties. That class can then have its own defaults, so that your example becomes `function setData(Data $values = new Data())` Regards, -- Rowan Tommins [IMSoP]