stitcher.io icon indicating copy to clipboard operation
stitcher.io copied to clipboard

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

Open snpy opened this issue 1 year ago • 1 comments

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 avatar Apr 11 '24 07:04 snpy

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

snpy avatar Apr 11 '24 07:04 snpy