Trigger deprecations when using "??" and "not" without explicit parentheses when precedence will change in 4.0#4367
Conversation
385fe86 to
afcfdee
Compare
There was a problem hiding this comment.
I'm wondering whether this could be implemented in the ExpressionParser while resolving precedence (by providing a future_precedence or something like that) instead of inspecting the AST after the fact. This could make it work in combination with third-party operators as well (which might have a precedence between the old and new ones and so be impacted).
| {{ nope ?? nada ?? 'OK' }} | ||
| {{ 1 + nope ?? nada ?? 2 }} | ||
| {{ 1 + nope ?? 3 + nada ?? 2 }} | ||
| {{ nope ?? (nada ?? 'OK') }} |
There was a problem hiding this comment.
should we really report this case ? It will be parsed the same in 4.0
afcfdee to
320751b
Compare
|
@stof I've rewritten how this all works. It's now all automated in the sense that it's done in a generic way where I just need the current and future precedence. It's a quick prototype I've done in a few minutes, so I might have forgotten something. Can you have a look? |
9662b54 to
b0249b6
Compare
b0249b6 to
1acb004
Compare
1acb004 to
69e0b0f
Compare
|
The implementation is now much better. I'm done for this PR. |
69e0b0f to
c726b99
Compare
c726b99 to
877c055
Compare
| * Deprecate using `~` with `+` or `-` in an expression without using parentheses to clarify precedence | ||
| * Deprecate using the `not` unary operator in an expression with ``*``, ``/``, ``//``, or ``%`` without using explicit parentheses to clarify precedence | ||
| * Deprecate using the `??` binary operator without explicit parentheses | ||
| * Deprecate using the `~` binary operator in an expression with `+` or `-` without using parentheses to clarify precedence |
There was a problem hiding this comment.
this should also mention Add support for triggering deprecations for future operator precedence changes (and maybe this should have docymentation as well)
877c055 to
2081b1f
Compare
This PR was merged into the 3.x branch. Discussion ---------- Add missing import Hi `@fabpot`, the phpdoc was updated in #4367 but the import was forgotten. This leads to an error with all static analysis tools when implementing ExtensionInterface. If possible a patch version would be helpful. (Tests are already failing on 3.x) Commits ------- 51d10ba Add missing import
Closes #3387
Closes #3642