Skip to content

Context::inForeachCondition(): bug fix - improve handling of array declaration in foreach - #617

Merged
jrfnl merged 1 commit into
developfrom
feature/context-inforeach-fix-array-declaration-bug
Aug 4, 2024
Merged

Context::inForeachCondition(): bug fix - improve handling of array declaration in foreach#617
jrfnl merged 1 commit into
developfrom
feature/context-inforeach-fix-array-declaration-bug

Conversation

@jrfnl

@jrfnl jrfnl commented Aug 3, 2024

Copy link
Copy Markdown
Member

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
@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