Add a BC way to access environment operators/expression parsers
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 8.4k
- Forks
- 1.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 37
Description
Hi @fabpot
Twig-CS-Fixer use his own Lexer because
- he needs to keep space/tabs
- he uses more token types
The implementation worked fine so far, but just got recently broke by the 3.21 release since I inspired my getOperatorRegex implementation by yours https://github.com/twigphp/Twig/blob/3468920399451a384bef53cf7996965f7cd40183/src/Lexer.php#L547-L551 and now getUnaryOperator/getBinaryOperator methods was removed. Of course it was possible since it's internal.
I implemented a fix to follow your new implementation https://github.com/twigphp/Twig/blob/b54a265712a475da0aef560e184d68a9affd3ace/src/Lexer.php#L528-L530 (but with some changes since I need to keep the same type for (, [, =>, ... for BC reason). But again getExpressionParsers is internal.
Is there a way to write
$expressionParsers = ['='];
foreach ($this->env->getExpressionParsers() as $expressionParser) {
$expressionParsers = array_merge($expressionParsers, [$expressionParser->getName()], $expressionParser->getAliases());
}
without an internal method ? Would it be OK to make getExpressionParsers part of the API ?
Thanks
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/Lexer.php, especially the current operator-regex implementation and getExpressionParsers, then compare the BC requirements described by Twig-CS-Fixer. Done means providing a supported way for external consumers to access the needed expression-parser or operator information without relying on internal methods.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100