Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107041 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92755 invoked from network); 13 Sep 2019 08:13:13 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 13 Sep 2019 08:13:13 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 78F542D201B for ; Thu, 12 Sep 2019 22:49:17 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 12 Sep 2019 22:49:17 -0700 (PDT) Received: by mail-ot1-x32a.google.com with SMTP id g16so13193734otp.8 for ; Thu, 12 Sep 2019 22:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DMY1smIC8EZMr1AA2HKgeFmpPs4f0KEeLIx44rl9jUE=; b=gfCZPhPUcquPXiqtSjjvvnnIYDpA9qy5ls5w0vls3UZgp1vJtyuu8orT4q4k5C5aGw k1ptxeXbDnVlz4iszAkSrIai+E5JJ/iSnyWD8N0+UqfWY/Ai1ouVt+MbqUynsp/UGOas GYsQFyoPCd0a2Hzpd5bpogGtAtnjIHvuVIWrNSdWqPMJLI8FHHF+8z8076xI78s/7FPU SA/Vhu31JZYUcjigN9o7pxSENdVLfb1KATX1ILcBUM9rvcS+j8aPNmLoIuAQceI+seiV YIY4drbU0kZ3GVDorUeVkouooBVXz8kpcH5m0daRKXhvjgwjqj0qsTlyYecopLNGKFlC V1sA== 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=DMY1smIC8EZMr1AA2HKgeFmpPs4f0KEeLIx44rl9jUE=; b=IK2HcHWYIxXAeU/bfKYBLXM6aFfdu7UIertCLIffU3vyYjlYmEGNpubSqma0nfCkRd utievBuT7gNeXKte9yn6l1ZdUn4zOmygPks9/7PxTmuidoL+ODUUP9rXkAnalcUaDa7B pegluUGlH8rGso2bMFx3miPB81ERvEn+Q+gDx+HogpSn/bP+k/KhgMVuQlZTa6QDfIB+ mLYzWoD1rJvVW6BBvVLfBB3KrA2Goke0/U6Up3fkDk2ZYELjjqF59TtfMOZ9jYjhrbuU xTbCBzGc6wbmGi8mKzWx3AvtqnVctcp0IseUt4nuwAQBoQmQf1eC0Qang/np5yxIgLQG qwsQ== X-Gm-Message-State: APjAAAXXsM//RsktkwufR2CgiEzND/Wa/wDlCkrwYLVdAcw+vYzSRHWq UITFph8XWoN7iERo/DBnb5xgSZLCu1DheYwM61M= X-Google-Smtp-Source: APXvYqwO77/5q3tNNqLKZCL76reruxb2ZAlFAmxb2opwoqiW0m9L3puN7tVXvaBiwu5s9x2njx//NW6mkbBM3tmCpuI= X-Received: by 2002:a05:6830:1597:: with SMTP id i23mr9601055otr.182.1568353756153; Thu, 12 Sep 2019 22:49:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 13 Sep 2019 07:49:00 +0200 Message-ID: To: Lynn Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000848c72059268d01b" X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] Object Initializer From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --000000000000848c72059268d01b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Lynn, czw., 12 wrz 2019 o 17:01 Lynn napisa=C5=82(a): > Heya, > > What's the added benefit of this compared to implementing a constructor? > > The part I like is that this can be used to replace stdClass/structured > arrays. Perhaps something like this would nice to have in PHP: > > ``` > $people =3D []; > > foreach ($peopleFromDatabase as [$id, $username, $name]) { > $people[] =3D { > Uuid id =3D> $id, > string username =3D> $username, > string name =3D> $name, > }; > // and possible automatic assignment: > $people[] =3D {Uuid $id, string $username, string $name}; > } > ``` > Removing stdClass for instantiation and initialization of simple objects is one of a future scope proposal. This RFC tries to address instantiation and initialization boilerplate reduction with a syntax which would not be restricted to stdClass only. Although it's not a game-changer, simple addition to the language which reduces boilerplate when dealing with objects which don't need complex constructors like for eg. DTO objects= . Regards, > Lynn van der Berg > > Regards, Micha=C5=82 Brzuchalski --000000000000848c72059268d01b--