-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
[ExpressionLanguage] Add enum
expression function
#17632
[ExpressionLanguage] Add enum
expression function
#17632
Conversation
syntax as PHP and JavaScript. The ExpressionLanguage component comes with one | ||
function by default: ``constant()``, which will return the value of the PHP | ||
constant:: | ||
syntax as PHP and JavaScript. The ExpressionLanguage component comes with two |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the "two" and use "following functions"...
This way we don't need to adapt it for further methods in the future
function by default: ``constant()``, which will return the value of the PHP | ||
constant:: | ||
syntax as PHP and JavaScript. The ExpressionLanguage component comes with two | ||
functions by default. The first one is ``constant()``, which will return the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's use headlines instead of the introduction with "the first..." and "the second"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, as well as your previous feedback!
6797b62
to
1ac5815
Compare
Constant function | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
This function will return the value of the PHP constant:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function will return the value of the PHP constant:: | |
This function will return the value of a PHP constant:: |
Kann you also add an example for a class with a namespace? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! 🙂
1ac5815
to
8f1976e
Compare
…lexandre-daubois) This PR was merged into the 6.3 branch. Discussion ---------- [ExpressionLanguage] Add `enum` expression function | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #48593 | License | MIT | Doc PR | symfony/symfony-docs#17632 Commits ------- 53bfee4 [ExpressionLanguage] Add `enum` expression function
…lexandre-daubois) This PR was merged into the 6.3 branch. Discussion ---------- [ExpressionLanguage] Add `enum` expression function | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #48593 | License | MIT | Doc PR | symfony/symfony-docs#17632 Commits ------- 53bfee4440 [ExpressionLanguage] Add `enum` expression function
* ``constant()`` | ||
* ``enum()`` | ||
|
||
Constant function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant function | |
``constant()`` function |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this is better! I'm doing the change, and I'll revert it if Wouter and/or Javier don't agree! 🙂
This will print out ``root``. | ||
|
||
Enum function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum function | |
``enum()`` function |
? WDYT @wouterj @javiereguiluz
8f1976e
to
f3c194c
Compare
|
||
define('DB_USER', 'root'); | ||
|
||
var_dump($expressionLanguage->evaluate( | ||
'constant("DB_USER")' | ||
)); | ||
|
||
// This also works with class constants |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this a plain text followed by a new code block and add a namespace for the class.
Maybe let's not reuse DB_USER
|
||
This function will return the case of an enumeration:: | ||
|
||
enum Foo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a namespace please
PR header still referencing quadruple |
f3c194c
to
42dc551
Compare
That's fixed! 🙂 |
Thanks for your work on this new feature! |
Related to symfony/symfony#48669.
ℹ️ I added a namespace to the enum in the example to kind of remind that triple backslashes must be used in the expression to use the namespaced enum.