> It's also the entire point of the feature ;) You open the file, and in two
> seconds, you know:
>
> It defines two properties, type int and string, it calls parent::__construct
> with those two parameters.
>
> Currently, you open the class, seek to the constructor, read it to understand
> if it even calls the parent constructor or not. Just like promoted
> properties, the cost is nominal, but now it is nearly ubiquitous in usage and
> saves a large amount of time in reading and writing classes. This feature
> seeks to do the same.
> It's also the entire point of the feature ;) You open the file, and in
> two seconds, you know:
>
> It defines two properties, type int and string, it calls
> parent::__construct with those two parameters.
>
> Currently, you open the class, seek to the constructor, read it to
> understand if it even calls the parent constructor or not. Just like
> promoted properties, the cost is nominal, but now it is nearly
> ubiquitous in usage and saves a large amount of time in reading and
> writing classes. This feature seeks to do the same.
I don't think the "seek to the constructor" problem is real in practice.
By convention the constructor goes first in a PHP class, so the code
you'd be reading is simply:
```
class Foo extends Base
{
public function __construct(public int $a, public string $b)
{
parent::__construct($a, $b);
}
}
```
That's seven lines that fit comfortably on any screen, and each concept,
the class, the constructor, the promoted properties, the parent call,
sits on its own line where it's immediately recognizable. Packing all of
it onto a single line saves nothing and makes the code harder to read,
not easier.
I also disagree with comparing this to promoted properties. Promoted
properties removed genuine boilerplate: the property declaration, the
constructor parameter, and the `$this->x = $x` assignment collapsed into
one place because they were the same information repeated three times.
Primary constructors don't remove repetition; they just relocate the
constructor signature into the class declaration line. There's no
duplicated information being eliminated.
Cheers,
Seifeddine.