brendt / stitcher.io

Source code of stitcher.io
https://stitcher.io
179 stars 137 forks source link

Promoted properties are allowed in abstract class c-tor as long as c-tor itself is not abstract #252

Open snpy opened 7 months ago

snpy commented 7 months ago

https://github.com/brendt/stitcher.io/blob/2bb72fff42166013fc60705d8b82d13432c90021/src/content/blog/2020-06-12-constructor-promotion.md?plain=1#L245

Having body in an abstract method is not allowed.

So this:

abstract class A
{
    abstract public function __construct(
        public string $a,
    ) {}
}

Should be this:

abstract class A
{
    abstract public function __construct(
        public string $a,
    );
}

But this is allowed:

abstract class A
{
    public function __construct(
        public string $a,
    ) {}
}
snpy commented 7 months ago

Was looking around the Internet if I can do more with promoted properties that I'm already using and stumbled upon your article.