> FYI/Just in case anyone already wants to forbid this - there is a sniff
> available which will flag both constructors as well as destructors with
> a return type and/or when the function returns something:
> Universal.CodeAnalysis.ConstructorDestructorReturn
>
> Ref: 
> https://github.com/PHPCSStandards/PHPCSExtra#universalcodeanalysisconstructordestructorreturn-wrench-books

Thank you very much for this information. Using PHP Code Sniffer, we
identified two more return values from the __construct() functions.

Installing PHP Code Sniffer on Windows without using Composer is
cumbersome. For those who want to use the PHP Code Sniffer tool,
I've included installation instructions in the original issue, see:
https://github.com/php/php-src/issues/21090#issuecomment-3870404274

Kind regards,
Mirco Babin

Op za 7 feb 2026 om 00:56 schreef Juliette Reinders Folmer
<[email protected]>:
>
> On 6-2-2026 20:59, Tim Düsterhus wrote:
>
> On 2/2/26 19:00, Mirco Babin wrote:
>
> # RFC
>
> I've been asked to follow the RFC process. And I've been told that the
> rejected PHP RFC Make constructors and destructors return void
> ( https://wiki.php.net/rfc/make_ctor_ret_void ) rejects my proposal.
> However, my proposal is explicitly about the "new" operator and not
> about return types. It does, however, concern return values.
>
>
> Personally I find the fact that it's illegal to define a return type on 
> `__construct()` to be a pretty good indication that the constructor is not 
> meant to be able to return anything. As such I'm a little surprised by the 
> disagreement in that RFC, though it should be noted that a majority was in 
> favor (just not a 2/3's majority).
>
>
> FYI/Just in case anyone already wants to forbid this - there is a sniff 
> available which will flag both constructors as well as destructors with a 
> return type and/or when the function returns something: 
> Universal.CodeAnalysis.ConstructorDestructorReturn
>
> Ref: 
> https://github.com/PHPCSStandards/PHPCSExtra#universalcodeanalysisconstructordestructorreturn-wrench-books

Reply via email to