Hi All!

As stated in the Wiki RFC HowTo section I'm here to measure the reaction
about my proposal.

I would like to propose an RFC and then implement initializer list for
constructors in PHP.

Being a C++ developer I find this feature very useful and these are my
considerations:

- This will provide a very convenient way to avoid things like

public function __construct($name, $surname, $age)
{
    $this->name = $name;
    $this->surname = $surname;
    $this->age = $age;
}

in favor of:

public function __construct($name, $surname, $age) : name(name),
surname(surname), age(age) {};

- Another possible use of this could be:

public function __construct() : host("127.0.0.1") {};


- It should not introduce BC (please correct me if I'm wrong)
- In C++ using initializer list is used over assignment also for
performance reasons but right now I can't say if this can be achieved in
PHP or not.

Initializer lists in C++:
http://en.cppreference.com/w/cpp/language/initializer_list


What do you think?

Thank you

Lorenzo Fontana

Reply via email to