Skip to content

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Aug 3, 2024

PHP allows for not just having an (array/iterable object) variable in the "iterable" (before as) part, it also allows for those to be passed as an expression.

While this is surely more rare, it does mean that it is possible for an as keyword to exist in the expression.

This commit makes the Context::inForeachCondition() method more robust by explicitly skipping over array declarations while searching for the as keyword belonging to the foreach. This fixes the bug.

Includes tests.

…claration in foreach

PHP allows for not just having an (array/iterable object) variable in the "iterable" (before as) part, it also allows for those to be passed as an expression.

While this is surely more rare, it does mean that it is _possible_ for an `as` keyword to exist in the expression.

This commit makes the `Context::inForeachCondition()` method more robust by explicitly skipping over array declarations while searching for the `as` keyword belonging to the `foreach`.
This fixes the bug.

Includes tests.
@jrfnl jrfnl force-pushed the feature/context-inforeach-fix-array-declaration-bug branch from d133b8c to 50cc0bf Compare August 3, 2024 20:14
@jrfnl jrfnl merged commit 482407c into develop Aug 4, 2024
54 checks passed
@jrfnl jrfnl deleted the feature/context-inforeach-fix-array-declaration-bug branch August 4, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant