8000 [ExpressionLanguage] Registering functions after calling evaluate(), compile() or parse() is not supported by maidmaid · Pull Request #21722 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[ExpressionLanguage] Registering functions after calling evaluate(), compile() or parse() is not supported #21722

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

Closed
wants to merge 7 commits into from

Conversation

maidmaid
Copy link
Contributor
Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

If we add expr. function after first eval/compile like this:

$el = new ExpressionLanguage();
$el->evaluate('1 + 1');
$el->addFunction(new ExpressionFunction('fn', function () {}, function () {}));
$el->evaluate('fn()');

A SyntaxError is thrown that says The function "fn" does not exist around position 1.. It's the same bug with $el->compile('fn()').

This PR fixes this (duplicate of #21098 that was closed).

@fabpot
Copy link
Member
fabpot commented Feb 22, 2017

Thank you @maidmaid.

fabpot added a commit that referenced this pull request Feb 22, 2017
…valuate(), compile() or parse() is not supported (maidmaid)

This PR was squashed before being merged into the 2.7 branch (closes #21722).

Discussion
----------

[ExpressionLanguage] Registering functions after calling evaluate(), compile() or parse() is not supported

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

If we add expr. function after first eval/compile like this:

```php
$el = new ExpressionLanguage();
$el->evaluate('1 + 1');
$el->addFunction(new ExpressionFunction('fn', function () {}, function () {}));
$el->evaluate('fn()');
```
A ``SyntaxError`` is thrown that says ``The function "fn" does not exist around position 1.``. It's the same bug with ``$el->compile('fn()')``.

This PR fixes this (duplicate of #21098 that was closed).

Commits
-------

e305369 [ExpressionLanguage] Registering functions after calling evaluate(), compile() or parse() is not supported
@fabpot fabpot closed this Feb 22, 2017
This was referenced Mar 6, 2017
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.

3 participants
0