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

Make ExpressionLanguage more extensible #26322

Closed
markoffk opened this issue Feb 26, 2018 · 3 comments
Closed

Make ExpressionLanguage more extensible #26322

markoffk opened this issue Feb 26, 2018 · 3 comments

Comments

@markoffk
Copy link

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 3.4

Hello!

I need to restrict one binary operator from Symfony expression language (for example: .. double dot operator). All binary operators are defined in Symfony\Component\ExpressionLanguage\Parser.
So I came to conclusion that I need somehow to redefine $this->binaryOperators in Parser.
That Parser is used later in Symfony\Component\ExpressionLanguage\ExpressionLanguage. But unfortunately, it is not possible to override ExpressionLanguage class to make it use another custom Parser in any way (except of just creating own class by copying 99% of ExpressionLanguage class), because of this piece of code:

    private function getParser()
    {
        if (null === $this->parser) {
            $this->parser = new Parser($this->functions);
        }

        return $this->parser;
    }

May I kindly ask SF developers to adjust this class: make this function protected or make it possible to use Parser injection from constructor?

Thanks!

@ostrolucky
Copy link
Contributor

I suggest to use hoa/ruler instead. It's more flexible and less quirky than Symfony ExpressionLanguage.

@stof
Copy link
Member

stof commented Feb 27, 2018

The ExpressionLanguage component is not meant to provide an extendable parser to build your own languages. This is not the goal of the component. There is already dedicated libraries targetting such goal.

@nicolas-grekas
Copy link
Member

Closing as explained. Thanks for the proposal anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants