Skip to content
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

Merged

Conversation

alexandre-daubois
Copy link
Contributor

@alexandre-daubois alexandre-daubois commented Dec 30, 2022

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.

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
Copy link
Contributor

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
Copy link
Contributor

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"?

Copy link
Contributor Author

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!

@javiereguiluz javiereguiluz added the Waiting Code Merge Docs for features pending to be merged label Dec 30, 2022
@carsonbot carsonbot modified the milestones: 6.3, next Dec 30, 2022
Constant function
~~~~~~~~~~~~~~~~~

This function will return the value of the PHP constant::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! 🙂

nicolas-grekas added a commit to symfony/symfony that referenced this pull request Jan 9, 2023
…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
symfony-splitter pushed a commit to symfony/expression-language that referenced this pull request Jan 9, 2023
…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
@OskarStark OskarStark removed the Waiting Code Merge Docs for features pending to be merged label Jan 9, 2023
* ``constant()``
* ``enum()``

Constant function
Copy link
Contributor

@OskarStark OskarStark Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Constant function
``constant()`` function

?

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Enum function
``enum()`` function

? WDYT @wouterj @javiereguiluz


define('DB_USER', 'root');

var_dump($expressionLanguage->evaluate(
'constant("DB_USER")'
));

// This also works with class constants
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a namespace please

@OskarStark
Copy link
Contributor

PR header still referencing quadruple

@alexandre-daubois
Copy link
Contributor Author

That's fixed! 🙂

@OskarStark
Copy link
Contributor

Thanks for your work on this new feature!

@OskarStark OskarStark merged commit 3f9c576 into symfony:6.3 Jan 10, 2023
@alexandre-daubois alexandre-daubois deleted the feat/expression-language-enum branch January 10, 2023 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants