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

Documented as void

...

Explicit declaration

...

Consistency with other methods

...

__clone() allows void return type

...

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

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.1592241029.txt.gz · Last modified: 2020/06/15 17:10 by moliata