Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116180 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 74884 invoked from network); 27 Sep 2021 14:08:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Sep 2021 14:08:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 135B51804E3 for ; Mon, 27 Sep 2021 07:51:01 -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-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (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 ; Mon, 27 Sep 2021 07:51:00 -0700 (PDT) Received: by mail-io1-f45.google.com with SMTP id b78so17803502iof.2 for ; Mon, 27 Sep 2021 07:51:00 -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=q+MCDZa86XjFvClhwOM04FojDBpzjv84O2DgY+IQuD8=; b=Of8VX/uSPmGg5YJvp5MfIVVsb7d7/9CyuVxbbwXEfJpGkR8xL3WijYzFEOlovEa2/U sHLJqmI7KOn+PcPXBk3+81012oLlBGxqDb+I8fILYWZP6BqMUUtimgEytWA+fqCbhELR 76EUhjsPZw62ieVg2QRrq1noSKG42klhawL+P0OfkL0HSnPvy//lTWOdVMzw+6GtP8CX S8Rv3kKfUMaGMH0CrBEc6XDvxPcUC2Sf3PG8UvV32z4vK2lR8D8QP3mF53+52yKtp3Ad qNkUJND5pbJkgs700Z2louJwnbq5QVxKYT/o2H8lkxpIyiQw3iFOup8bAD3ZsgSL4kDj dbbQ== 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=q+MCDZa86XjFvClhwOM04FojDBpzjv84O2DgY+IQuD8=; b=qo3eaAT/EPXfkA5IZUt8LB50Qfp8YmvIPASbF8M0QVuToU7Y9UpFrzok4zYNyqkLNy d8CbDujP78XeHpcY9nqwiTAQYG7C6qDtnZeBCNS18+CQBWyEPMrEcK6K4b0fyBqtRzaG +Oq7baii3UJjYRZfLnhzj2FYua4U1RQZxdUKNxXpCbY0ueqFT5VRxOHbz28rySW3qILq JJpTKY+4sboOx4fwslEK8wAEHbYDwdDQaxHrZbXEf3j4Dld2+R8NC5ElzWeWrvOSiyv/ Ii6XDdo0+3+41sZclD9Ko/SPEw/jpdtpRUV6F6dRvHHDR1Uh7T5UFpZR7fYd24SwLggp ghCg== X-Gm-Message-State: AOAM530kJqqNz7JuGHeBfgC4sliuPrlXK2TqqwVH1iPS0tjyNgpLZfs3 LbgTVofspxJDrbTfP87LEBpKbGYLR2l8hiZEvYc= X-Google-Smtp-Source: ABdhPJwjj0ckUbtVNlTfa7URyo+0YHBlg7GK4LOE5gjoWjGn37IszVHw0XpzW4uPfQHLSdpchtWa6cCYGXLTLYwuLiw= X-Received: by 2002:a5d:8c83:: with SMTP id g3mr124567ion.24.1632754259152; Mon, 27 Sep 2021 07:50:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 27 Sep 2021 16:50:33 +0200 Message-ID: To: Sara Golemon Cc: tyson andre , "internals@lists.php.net" Content-Type: multipart/alternative; boundary="0000000000009f575605ccfb39d9" Subject: Re: [PHP-DEV] Allowing `(object)['key' => 'value']` in initializers? From: kjarli@gmail.com (Lynn) --0000000000009f575605ccfb39d9 Content-Type: text/plain; charset="UTF-8" On Mon, Sep 27, 2021 at 3:15 PM Sara Golemon wrote: > I think for consistency's sake, we'd want to provide a base constructor to > stdClass to take an associative array that maps into dynamic properties, > e.g. > > class stdClass { > public function __construct(array $props) { > foreach ($prop as $name => $val) { > $this->$name = $val; > } > } > } > > Then you could: > php> static $x3 = new stdClass(['key' => 'value']); > If the structure of `$something = {};` would ever be allowed in PHP, the following could be done instead: `$something = { ...$array };`. This will reduce the dependency on the stdClass. --0000000000009f575605ccfb39d9--