rfc:parameter-no-type-variance

This is an old revision of the document!


PHP RFC: Your Title Here

Introduction

PHP doesn't currently allow variance for parameters as checking these for compatibility isn't possible on compile time. This limitation is caused by autoloading and doesn't allow widening the accepted parameters.

Proposal

This RFC proposes to allow ommiting the type entirely in a subclass, as dropping all parameter constraints is always valid according to the LSP principle.

Backward Incompatible Changes

None.

Proposed PHP Version(s)

Next minor version, currently 7.2.

RFC Impact

To SAPIs

None.

To Existing Extensions

None.

To Opcache

None.

New Constants

None.

php.ini Defaults

None.

Open Issues

None.

Future Scope

In the future there might be support for contra-variance / co-variance for parameters / return types.

Proposed Voting Choices

Requires a 2/3 majority.

Patches and Tests

TBD.

Implementation

TBD.

References

None.

Rejected Features

None.

rfc/parameter-no-type-variance.1479720427.txt.gz · Last modified: 2017/09/22 13:28 (external edit)