Re: [PHP-DEV] [RFC] Object Initializer

This is only part of a thread. view whole thread
  107142
September 16, 2019 07:41 arnold.adaniels.nl@gmail.com (Arnold Daniels)
Features like `func_get_args(ARGS_OBJECT)` and `hoist` aren't really needed. You can use `get_defined_vars()` instead.

Many of my classes have constructors like;

public function __construct(int $foo, string $bar, bool $flag = false)
{
set_object_vars($this, get_defined_vars());

}

FYI `set_object_vars` is a user-space function that does the reverse of `get_object_vars`. You could use a `foreach` loop instead.
----

However when a class for a data object has 20 properties, I don't really want to put all 20 as constructor arguments. The object initialize RFC be the preferred solution for me in that case, even if named parameters was also supported. As such, I don't think the two features are mutually exclusive.

[Arnold Daniels - Chat @ Spike](https://www.spikenow.com/?ref=spike-organic-signature&_ts=5w9qi)	[5w9qi]

On September 16, 2019 at 6:22 GMT, Michał Brzuchalski brzuchalski@gmail.com> wrote: