Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106971 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 47998 invoked from network); 12 Sep 2019 17:31:49 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 12 Sep 2019 17:31:49 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id F3A892CE9F3 for ; Thu, 12 Sep 2019 08:07:44 -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,URIBL_BLOCKED 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-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) (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 08:07:44 -0700 (PDT) Received: by mail-oi1-x234.google.com with SMTP id 11so2086811oix.4 for ; Thu, 12 Sep 2019 08:07:44 -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=YKLibGH1el5SZZemKXp9uV4zYqMt1oyFSKVzxde3NQM=; b=Lopbo8Ja181tIJqW/pfMwBbujw6iWW3iiPtBv80opf9Wmt7wiDvtjU4f7L4pZWtuZc U1S8m845NTSqmsheCVXUUMcbl8lukHW1anmVxMXVmsnKx3LRb/Euy/A9jB31y2EvoHDV Nlz1wTy5CkTQOhQPJina1fQrMrMWOaB+m4RQ8PQdt854eKjy2ARJ5Kevea0IXHwn/K4M 29fwaXvuDv/RFw2uN/DnpgIgKC9ju2MjJF22x5mY9HlOaeU3tQH/uherk91gYlM02x2w lFDHnQAi/OJ10owfZVLgp0/0/o3yPY+MhRB5MQKJPmH2JYmEHyry9NlsI4MCB8/rCE+9 EAbQ== 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=YKLibGH1el5SZZemKXp9uV4zYqMt1oyFSKVzxde3NQM=; b=bu2YL2Zx8cXcE+u16C/0NquzM2CZUuWav1VRuph++f9B6K4/SMDDEZOYUnA9540ijx 0q7X0OLCIyTVTckFUXM7kVJamrkKopLJHBd6ZT8Bcb4NixXLFDaAjzGHRppqpbp+4OBn Z3FqPOooDRv7KwEGRh2eAQnUuintO2wu8Y9msXqBxm+7Yn7xc2KjM2MtOqwGbcopsoGB 17ZOvP4S2pcWb3MOjoRZWkVLE/k0D70HhexkLGEPaXYEBrBGHDS8yanaZRoev5AP/lfC lppuQ2Rz2GV+WezOlRYiUE62dJ8iyViAEw5URnvK83AbYTvHEMy8eo6864VsMsQw0IyB Kmaw== X-Gm-Message-State: APjAAAV+MXv24QMkefwzQs045vSXXqK9JSWwWbT0OzMhcpCJfbhzjQl0 Md4byV2wO9LUozJz9IOTFVmS/9YCtUfg0YihTYc= X-Google-Smtp-Source: APXvYqwk+w5apDDmvyWr3yQoSA457+OBrUY0QK0OtCeh7M7Ds5PzzCGXCGvOQzWhLSqkYHJbADjGo/jWUpcRxhcdCNQ= X-Received: by 2002:aca:ed52:: with SMTP id l79mr476774oih.47.1568300863740; Thu, 12 Sep 2019 08:07:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 12 Sep 2019 16:07:31 +0100 Message-ID: To: Lynn Cc: =?UTF-8?Q?Micha=C5=82_Brzuchalski?= , PHP internals Content-Type: multipart/alternative; boundary="000000000000e2654d05925c7faf" X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] Object Initializer From: oludonsexy@gmail.com (Olumide Samson) --000000000000e2654d05925c7faf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable The RFC is a beautiful feature suggestion, but something is telling me as beautiful and straightforward the syntax is, what can the use case be? I really love Constructor or Object initialization to be implemented in PHP, but is there something I think you're missing in the RFC? Thanks for the RFC. On Thu, Sep 12, 2019, 4:02 PM Lynn wrote: > On Thu, Sep 12, 2019 at 4:00 PM Micha=C5=82 Brzuchalski < > michal.brzuchalski@gmail.com> wrote: > > > Hi internals, > > > > I'd like to open discussion about RFC: Object Initializer. > > > > This proposal reduces boilerplate of object instantiation and propertie= s > > initialization in case of classes without required constructor argument= s > as > > a single expression with initializer block. > > > > https://wiki.php.net/rfc/object-initializer > > > > I appreciate any feedback you all can provide. > > > > Thanks, > > -- > > Micha=C5=82 Brzuchalski > > brzuchal@php.net > > > > > 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}; > } > ``` > > Regards, > Lynn van der Berg > --000000000000e2654d05925c7faf--