Re: [RFC][Draft] Body-less __construct

From: Date: Mon, 10 May 2021 18:01:42 +0000
Subject: Re: [RFC][Draft] Body-less __construct
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-114349@lists.php.net to get a copy of this message
On Mon, 10 May 2021 at 21:59, Larry Garfield <larry@garfieldtech.com> wrote:

> 1) Please don't top-post.
>
> 2) The reason is that the old way doesn't provide any way to populate them
> on construction.  The pattern of "assign the arg to the prop in the
> constructor" is stupendously common, and promotion makes it vastly more
> convenient.
>
> For more details:
>
> https://platform.sh/blog/2020/php-80-feature-focus-constructor-property-promotion/
>
> The constructor isn't "supposed" to be empty.  It just often is with
> promotion, because the constructor wasn't doing anything else besides
> shuffling its parameters over to properties, which is now automatic.
>
> --Larry Garfield
>
>
Sorry for top-posting. Didn't know what it means :), also it was kind of my
first reply to mailing list.

Yes, I see now. I had forgotten that bit when I replied; apologies.
I guess it makes sense now to end the constructor with a semicolon when it
holds no body.


Thread (34 messages)

« previous php.internals (#114349) next »