10000 [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

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()'
8000
);

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