Re: [RFC] [DISCUSSION] Allow void return type for constructors/destructors

From: Date: Tue, 16 Jun 2020 14:36:43 +0000
Subject: Re: [RFC] [DISCUSSION] Allow void return type for constructors/destructors
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-110597@lists.php.net to get a copy of this message
On 16.06.2020 at 16:19, Benas IML wrote:

> I meant something like this:
> ```
> <?php
> class Test {
>     public function __construct() {}
> }
>
> class Test2 extends Test {
>     /* this is legal */
>     public function __construct(): void {}
> }
>
> class Test3 extends Test {
>     /*
>      * this is illegal, even though no
>      * return type means mixed|void
>      */
>     public function __construct(): mixed {}
> }
>
> class Test4 extends Test2 {
>     /*
>      * this is legal, even though we are
>      * widening void type to mixed|void
>      * but LSP checks don't apply to
>      * constructors and destructors
>      */
>     public function __construct() {}
> }
> ```

Currently, constructors are exempt from LSP checks[1]; are you planning
to change that?

[1] <https://3v4l.org/PeDCY>

--
Christoph M. Becker


Thread (23 messages)

« previous php.internals (#110597) next »