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 <kja...@gmail.com> wrote:

> On Thu, Sep 12, 2019 at 4:00 PM Michał Brzuchalski <
> michal.brzuchal...@gmail.com> wrote:
>
> > Hi internals,
> >
> > I'd like to open discussion about RFC: Object Initializer.
> >
> > This proposal reduces boilerplate of object instantiation and properties
> > initialization in case of classes without required constructor arguments
> as
> > a single expression with initializer block.
> >
> > https://wiki.php.net/rfc/object-initializer
> >
> > I appreciate any feedback you all can provide.
> >
> > Thanks,
> > --
> > Michał Brzuchalski
> > brzuc...@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 = [];
>
> foreach ($peopleFromDatabase as [$id, $username, $name]) {
>     $people[] = {
>         Uuid id => $id,
>         string username => $username,
>         string name => $name,
>     };
>     // and possible automatic assignment:
>     $people[] = {Uuid $id, string $username, string $name};
> }
> ```
>
> Regards,
> Lynn van der Berg
>

Reply via email to