rfc:reserve_even_more_types_in_php_7

PHP RFC: Reserve Even More Types in PHP 7

Proposal

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:

  • “resource”
  • “object”
  • “scalar”
  • “mixed”
  • “numeric”

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.

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, 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.

Future Scope

Potentially future RFCs could:

  • add explicit scalar type support for parameter and return types
  • add union types, such as int|false

Result

The following class names are now reserved:

  • “resource”
  • “object”
  • “mixed”
  • “numeric”

The following class names have not been reserved:

  • “scalar”

Vote

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).

Reserved Type: resource
Real name Yes No
ajf  
bishop  
brianlmoon  
bwoebi  
danack  
datibbaw  
daverandom  
derick  
diegopires  
dm  
dmitry  
dragoonis  
eliw  
fredemmott  
guilhermeblanco  
hywan  
ircmaxell  
irker  
ivonascimento  
jedibc  
jgmdev  
jmikola  
joey  
jwage  
kalle  
kguest  
kinncj  
laruence  
lcobucci  
leigh  
levim  
lstrojny  
mbeccati  
mike  
mj  
nikic  
ocramius  
pauloelr  
pollita  
ramsey  
rdlowrey  
rdohms  
rmf  
salathe  
santiagolizardo  
sebastian  
seld  
stas  
stelianm  
subjective  
svpernova09  
thekid  
timo  
toby  
yohgaki  
yunosh  
zeev  
zimt  
Final result: 40 18
This poll has been closed.

.

Reserved Type: scalar
Real name Yes No
ajf  
bishop  
brianlmoon  
bwoebi  
danack  
datibbaw  
daverandom  
derick  
diegopires  
dm  
dmitry  
dragoonis  
eliw  
fredemmott  
guilhermeblanco  
hywan  
ircmaxell  
irker  
ivonascimento  
jedibc  
jgmdev  
jmikola  
joey  
jwage  
kalle  
kguest  
laruence  
lcobucci  
leigh  
levim  
lstrojny  
mbeccati  
mike  
mj  
nikic  
ocramius  
pauloelr  
pollita  
ramsey  
rdlowrey  
rdohms  
salathe  
santiagolizardo  
sebastian  
stas  
stelianm  
subjective  
svpernova09  
thekid  
timo  
toby  
yohgaki  
zimt  
Final result: 34 19
This poll has been closed.

.

Reserved Type: object
Real name Yes No
ajf  
bishop  
brianlmoon  
bwoebi  
danack  
datibbaw  
daverandom  
derick  
diegopires  
dm  
dmitry  
dragoonis  
eliw  
fredemmott  
guilhermeblanco  
hywan  
ircmaxell  
irker  
ivonascimento  
jedibc  
jgmdev  
jmikola  
joey  
jwage  
kalle  
kguest  
laruence  
lcobucci  
leigh  
levim  
lstrojny  
mbeccati  
mike  
mj  
nikic  
ocramius  
pauloelr  
pollita  
ramsey  
rdlowrey  
rdohms  
rmf  
salathe  
santiagolizardo  
sebastian  
stas  
stelianm  
subjective  
svpernova09  
thekid  
timo  
toby  
yohgaki  
yunosh  
zeev  
Final result: 45 10
This poll has been closed.

.

Reserved Type: mixed
Real name Yes No
ajf  
bishop  
brianlmoon  
bwoebi  
danack  
datibbaw  
daverandom  
derick  
diegopires  
dm  
dmitry  
dragoonis  
eliw  
fredemmott  
guilhermeblanco  
hywan  
ircmaxell  
irker  
ivonascimento  
jedibc  
jgmdev  
jmikola  
joey  
jwage  
kalle  
kguest  
laruence  
lcobucci  
leigh  
levim  
lstrojny  
mbeccati  
mike  
mj  
nikic  
ocramius  
pauloelr  
pollita  
ramsey  
rdlowrey  
rdohms  
salathe  
santiagolizardo  
sebastian  
seld  
stas  
stelianm  
subjective  
svpernova09  
thekid  
timo  
toby  
yohgaki  
yunosh  
zeev  
zimt  
Final result: 41 15
This poll has been closed.

.

Reserved Type: numeric
Real name Yes No
ajf  
andrey  
bishop  
brianlmoon  
bwoebi  
danack  
datibbaw  
daverandom  
derick  
diegopires  
dm  
dmitry  
dragoonis  
eliw  
fredemmott  
guilhermeblanco  
hywan  
ircmaxell  
irker  
ivonascimento  
jedibc  
jgmdev  
jmikola  
joey  
jwage  
kalle  
kguest  
laruence  
lcobucci  
leigh  
levim  
lstrojny  
mbeccati  
mike  
mj  
nikic  
ocramius  
pauloelr  
pollita  
ramsey  
rdlowrey  
rdohms  
salathe  
santiagolizardo  
sebastian  
seld  
stas  
stelianm  
subjective  
svpernova09  
thekid  
timo  
toby  
yohgaki  
zeev  
zimt  
Final result: 44 12
This poll has been closed.

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.

rfc/reserve_even_more_types_in_php_7.txt · Last modified: by 127.0.0.1