Take the State of PHP 2026 Survey →

Reserve More Type Names in PHP 7 View as Markdown

Implemented (PHP 7.0)
Authors
Levi Morrison levim@php.net
Date
2015-02-18
Version
1.1
Source
wiki.php.net/rfc/reserve_more_types_in_php_7

Vote

reserve_more_types_in_php_7 closed
Yes
40
No
2
42 voters
ajf Yes 2015-03-16 10:23
bishop Yes 2015-03-17 01:27
bwoebi Yes 2015-03-17 14:41
damz Yes 2015-03-16 15:53
danack Yes 2015-03-16 11:29
daverandom Yes 2015-03-23 10:26
derick Yes 2015-03-16 15:20
dmitry No 2015-03-16 10:09
fredemmott Yes 2015-03-16 16:12
frozenfire Yes 2015-03-16 17:58
galvao Yes 2015-03-16 15:44
guilhermeblanco Yes 2015-03-16 15:34
indeyets Yes 2015-03-16 06:45
irker Yes 2015-03-30 11:21
jedibc Yes 2015-03-16 09:30
jgmdev Yes 2015-03-16 21:45
jmikola Yes 2015-03-16 15:41
jwage Yes 2015-03-16 17:03
kalle No 2015-03-16 16:00
kguest Yes 2015-03-16 11:54
kinncj Yes 2015-03-23 16:23
lcobucci Yes 2015-03-18 13:14
leigh Yes 2015-03-16 15:20
levim Yes 2015-03-30 15:38
lstrojny Yes 2015-03-23 16:50
malukenho Yes 2015-03-28 05:07
mbeccati Yes 2015-03-23 08:05
nikic Yes 2015-03-16 11:38
pauloelr Yes 2015-03-16 19:39
ramsey Yes 2015-03-23 21:32
rdohms Yes 2015-03-21 09:51
rmf Yes 2015-03-18 00:17
santiagolizardo Yes 2015-03-17 11:53
seld Yes 2015-03-16 11:56
stas Yes 2015-03-17 18:27
stelianm Yes 2015-03-17 19:50
subjective Yes 2015-03-30 10:10
till Yes 2015-03-20 20:40
timo Yes 2015-03-16 15:07
tyrael Yes 2015-03-16 16:21
yunosh Yes 2015-03-16 17:12
zeev Yes 2015-03-22 23:08

Discussions on the mailing list

[RFC] Reserving More Types in PHP 7
by Levi Morrison · 14 messages
[RFC] Reserve EVEN MORE types for PHP7
by Sara Golemon · 17 messages
[RFC][DISCUSSION] Context Sensitive Lexer v0.4
by Marcio Almada · 1 message
[RFC][PRE-VOTE] Reserving More Types in PHP 7
by Levi Morrison · 13 messages
[RFC][VOTE] Reserve More Type Names in PHP 7
by Levi Morrison · 4 messages
[RFC] Reserving More Types in PHP 7
by Nate Abele · 25 messages

RFC text

Copied from wiki.php.net, last synchronized Oct 13, 2026 11:51 UTC

Proposal

This RFC prevents the use of the following words to be used as a class, interface or trait name:

  • int
  • float
  • bool
  • string
  • true, false
  • null

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.

I have chosen to not reserve integer, double and boolean out of interest of proposing the smallest useful subset. Another RFC could reserve these aliases in the future.

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:

  • reserve the aliases of these types, such as integer, double and boolean
  • add explicit scalar type support for parameter and return types
  • add union types, such as int|false
  • 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.

Vote: reserve_more_types_in_php_7 — Yes: 40 · No: 2 (closed)

Patches and Tests

There is currently no implementation.

Version History

  • 1.0: Reserve int, integer, float, double, bool, boolean, string, true, false, null
  • 1.1: No longer reserve integer, double and boolean