This is an old revision of the document!
PHP RFC: First Class Callables in constant expressions
- Version: 1.0
- Date: 2025-01-07
- Author: Tim Düsterhus (tim@tideways-gmbh.com), Volker Dusch (volker@tideways-gmbh.com)
- Status: Draft
- First Published at: http://wiki.php.net/rfc/fcc_in_const_expr
Introduction
The elevator pitch for the RFC. The first paragraph of this section will be slightly larger to give it emphasis; please write a good introduction.
Proposal
All the features and examples of the proposal.
To paraphrase Zeev Suraski, explain hows the proposal brings substantial value to be considered for inclusion in one of the world's most popular programming languages.
Remember that the RFC contents should be easily reusable in the PHP Documentation.
If applicable, you may wish to use the language specification as a reference.
Backward Incompatible Changes
None. Using first class callables within constant expressions previously resulted in a compile-time error. Closures can appear within constant expressions since the Support Closures in constant expressions RFC.
Nevertheless, as with every RFC that changes what previously was a compile-time error to be valid PHP code, this RFC requires changes to static analyzers and IDEs to correctly understand the semantics of the code and not erroneously report errors.
Proposed PHP Version(s)
Next 8.x (8.5).
RFC Impact
To SAPIs
None.
To Existing Extensions
None.
To Opcache
tbd
New Constants
None.
php.ini Defaults
None.
Open Issues
None.
Unaffected PHP Functionality
Only constant expression are affected by this change, but Closures could already appear within them.
Future Scope
None.
Proposed Voting Choices
Patches and Tests
Implementation
After the project is implemented, this section should contain
- the version(s) it was merged into
- a link to the git commit(s)
- a link to the PHP manual entry for the feature
- a link to the language specification section (if any)
References
Rejected Features
n/a