rfc:constructor_return_type

This is an old revision of the document!


PHP RFC: Allow void return type on constructors/destructors

Introduction

RFC proposes to allow using void return type on constructors and destructors (e. g. for consistency with other methods, alternative code style, etc.). In a way, this proposal is like a trailing comma: some might use it, some might not, but both cases are valid and allowed.

Proposal

Explicit declaration

...

Consistency with other methods

...

__clone() allows void return type

...

Note: only as part of the “Ensure correct signatures of magic methods” RFC.

PHP manual documents these methods as void

...

Backward Incompatible Changes

None.

To ensure backwards compatibility, it is allowed to not specify a return type at all. Although, since no return type is mixed|void, it is not allowed to narrow the return type to mixed, only void.

Vote

2/3 majority Yes/No.

Implementation

rfc/constructor_return_type.1592168171.txt.gz · Last modified: 2020/06/14 20:56 by moliata