-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Partially support first-class callable syntax in constant expressions #9236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah, I think there should be an RFC to discuss and clarify the details. Note that there is also #8959 which is a more general feature request. |
There has not been any recent activity in this feature request. It will automatically be closed in 14 days if no further action is taken. Please see https://github.com/probot/stale#is-closing-stale-issues-really-a-good-idea to understand why we auto-close stale feature requests. |
Please, Mr Bot, don't close this :) |
See https://wiki.php.net/rfc/howto, if you're interested in pursuing this. |
|
@mvorisek Not sure what you are referring to. That PR is about |
There has not been any recent activity in this feature request. It will automatically be closed in 14 days if no further action is taken. Please see https://github.com/probot/stale#is-closing-stale-issues-really-a-good-idea to understand why we auto-close stale feature requests. |
Any CTE expression like |
If function would be mistakenly added to CTE, but would be causing errors, you can just remove it in the next patch version and no one will notice. Removing function from constant expression would cause breaks. Then as an user, how do you even keep track which function are available for constant expressions? I could also imagine that this would require significant rework to implement. |
There has not been any recent activity in this feature request. It will automatically be closed in 14 days if no further action is taken. Please see https://github.com/probot/stale#is-closing-stale-issues-really-a-good-idea to understand why we auto-close stale feature requests. |
+1 |
Description
The first-class callable syntax is currently not allowed in constant expressions:
I propose partially supporting the first-class callable syntax in a constant expression. Specifically, I propose that PHP allows these two cases in a constant context:
While (still) disallowing expressions that cannot be known at compile time:
Example
Symfony's
Choice
assertion allows the user to specify a callback. It would be nice if we could use the first-class callable syntax in attributes, but this is currently not allowed:Implementation
I hacked together a working patch that supports the
strlen(...)
syntax in constant expressions. I haven't gotten around to implementingSomeClass::someStaticFunction(...)
yet. There are probably some edge cases that I'm missing - I'm not too familiar with the PHP code base.I'm also not sure if this feature would require an RFC. I would imagine it would, though.
Please let me know what you think.
The text was updated successfully, but these errors were encountered: