Hi Mirco,

Am 17. Februar 2026 07:59:43 MEZ schrieb Mirco Babin <[email protected]>:
>>Hi Mirco, and welcome!
>>
>>I agree that allowing constructors to return a value leads to confusion,
>>and would support deprecating and then forbidding this.
>>
>>However, I agree with others that this should be checked when compiling
>>the constructor, not when running it under the "new" operator. In other
>>words, make any method named "__construct" give >the same error as a
>>function or method marked ": void".
>
>Hello Rowan Tommins,
>
>I disagree with the compiling part. The __construct() function can
>currently not have a return type, so the return type is implicitly
>"mixed". Changing that would be a BC break for those calling the
>__construct() function as a regular function.
>
>As written to Tim Düsterhus: I have prepared a RFC at
>https://gist.github.com/MircoBabin/aaa574297c8d1baa879f19c99ce28e93

I'm with Roman here as well.
Yes, it's a BC break, but as Roman suggested, there would be a deprecation 
phase before and forbidden only in PHP 9. This should give enough time to adopt.

Also, you are talking about the constructor only, which is ok, but I believe 
the destructor needs to be discussed as well and mentioned in the RFC.


>
>Kind regards,
>Mirco Babin

Regards,
Marc

Reply via email to