# RFC: Reserve More Type Names in PHP 7

- Status: Implemented (PHP 7.0)
- Authors: Levi Morrison levim@php.net
- Date: 2015-02-18
- Version: 1.1
- Original: https://wiki.php.net/rfc/reserve_more_types_in_php_7
- Page: https://externals.io/rfc/reserve_more_types_in_php_7
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

## Votes

### reserve_more_types_in_php_7 (closed)

Yes: 40 · No: 2

Voters: ajf (Yes), bishop (Yes), bwoebi (Yes), damz (Yes), danack (Yes), daverandom (Yes), derick (Yes), dmitry (No), fredemmott (Yes), frozenfire (Yes), galvao (Yes), guilhermeblanco (Yes), indeyets (Yes), irker (Yes), jedibc (Yes), jgmdev (Yes), jmikola (Yes), jwage (Yes), kalle (No), kguest (Yes), kinncj (Yes), lcobucci (Yes), leigh (Yes), levim (Yes), lstrojny (Yes), malukenho (Yes), mbeccati (Yes), nikic (Yes), pauloelr (Yes), ramsey (Yes), rdohms (Yes), rmf (Yes), santiagolizardo (Yes), seld (Yes), stas (Yes), stelianm (Yes), subjective (Yes), till (Yes), timo (Yes), tyrael (Yes), yunosh (Yes), zeev (Yes)

## Discussions on the mailing list

- [\[RFC\] Reserving More Types in PHP 7](https://externals.io/message/83254.md) — started on 2015-02-20, 14 messages
- [\[RFC\] Reserve EVEN MORE types for PHP7](https://externals.io/message/83333.md) — started on 2015-02-20, 17 messages
- [\[RFC\]\[DISCUSSION\] Context Sensitive Lexer v0.4](https://externals.io/message/83735.md) — started on 2015-02-25, 1 messages
- [\[RFC\]\[PRE-VOTE\] Reserving More Types in PHP 7](https://externals.io/message/84760.md) — started on 2015-03-14, 13 messages
- [\[RFC\]\[VOTE\] Reserve More Type Names in PHP 7](https://externals.io/message/84981.md) — started on 2015-03-16, 4 messages
- [\[RFC\] Reserving More Types in PHP 7](https://externals.io/message/85951.md) — started on 2015-04-26, 25 messages

---

## 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`
