PHP RFC: Reserve Even More Types in PHP 7
- Version: 1.0
- Date: 2015-02-20
- Author: Sara Golemon firstname.lastname@example.org
- Heavily cribbed from Levi Morrison email@example.com
- Status: Partially Accepted (in PHP 7.0)
- First Published at: http://wiki.php.net/rfc/reserve_even_more_types_in_php_7
This RFC adds to https://wiki.php.net/rfc/reserve_more_types_in_php_7 to prevents the use of the following additional words to be used as a class, interface or trait name:
This RFC does not fully reserve them as keywords; it only prohibits their usage as class, interface and trait names. It also prevents them from being used in namespaces.
Facilitate Future RFCs
Reserving these words in PHP 7 would allow for another RFC to add scalar types in a minor release such as PHP 7.1 (assuming they make no backwards compatibility breaks). Without reserving them now a future RFC would only be able to target major PHP versions such as version 8 since they would break backwards compatibility.
Given that PHP has primitive types such as int, float, string and null it does not make sense for them to exist as classes, or if they do they should be provided by PHP itself.
Backward Incompatible Changes
This breaks any and all cases where these new reserved words are used in class, interface or trait names. It does not break any usages as function or method names or as class constants.
Unaffected PHP Functionality
This RFC does not change the way our current parameter and return type hints work. Support for these new reserved words as types for parameters or return types is beyond the scope of this RFC.
Potentially future RFCs could:
- add explicit scalar type support for parameter and return types
- add union types, such as
The following class names are now reserved:
The following class names have not been reserved:
The vote will be a simple “yes” or “no”: do you vote in favor of reserving these type names?
This RFC requires at least two thirds of the votes for a given type name to be “yes” to pass, and also requires the passage of https://wiki.php.net/rfc/reserve_more_types_in_php_7 or one of the ScalarTypeHints RFC (which implicitly reserve the base types by using them).
Voting opened on 2015-03-15 and will end on the later of 2015-03-29 or the close of all currently open Scalar Type Hint votes and Levi's scalar types reservation RFCs.
Patches and Tests
There is currently no implementation.