This is an old revision of the document!
PHP RFC: Reserve More Types in PHP 7
- Version: 1.0
- Date: 2015-02-18
- Author: Levi Morrison levim@php.net
- Status: Draft
- First Published at: http://wiki.php.net/rfc/reserving_scalar_type_names
Proposal
This RFC reserves the following words beginning with PHP 7.0:
int
,integer
bool
,boolean
true
,false
float
,double
string
null
This RFC does not fully reserve them as keywords; it only prohibits their usage as class, interface and trait names.
This RFC does not reserve resource
Rationale
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.
Disallowing Classes
Given that PHP has primitive types such as int, float and string 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 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 explicit types is not part of this RFC.
Future Scope
Potentially future RFCs could:
- add explicit scalar type support for parameter and return types
- reserve other types such as
numeric
,mixed
or ''scalar'
Proposed Voting Choices
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 to be “yes” to pass.
Patches and Tests
There is currently no implementation.