rfc:raw-identifiers

PHP RFC: Raw identifiers

Introduction

Introduce syntax allowing symbol names to use reserved and semi-reserved ways with no risk of getting reserved in future PHP versions.

Proposal

Reserved words being keywords in parser context cannot be used as symbol names, for eg. class/interface/trait/enum/function/const declarations. As PHP evolves more keywords are introduced and more words are forbidden to use in described symbol names. A new syntax fully BC would allow these words to be still used or just used by adding “\” prefix in front of a keyword name.

This allows smoother migration of old code that for eg. uses “match” as a function name, as this has become a reserved word in recent PHP versions. There are and possibly will be new RFCs that may introduce more reserved words as new keywords, like the use of “is” in pattern matching, etc.

This proposal's aim is to secure code maintained currently which may be broken in the future because of reserving more words and allow smooth migration path by just adding “\” in front of symbol names which might be automated to some degree.

Backward Incompatible Changes

None.

Proposed PHP Version(s)

8.2

RFC Impact

To SAPIs

None.

To Existing Extensions

None.

To Opcache

Unverified.

Proposed Voting Choices

Language change requires 2/3.

Patches and Tests

TBD

Implementation

References

rfc/raw-identifiers.txt · Last modified: 2022/03/24 07:41 by brzuchal