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

Foreach loop with variable containing "as" #17

Closed
SergeyZubov opened this issue Sep 28, 2017 · 1 comment
Closed

Foreach loop with variable containing "as" #17

SergeyZubov opened this issue Sep 28, 2017 · 1 comment

Comments

@SergeyZubov
Copy link

Hi. First of all - great job on single Blade class.

Today had an issue with foreach loop when tried to loop through variable named $cancelReasons.
Checked out compiled file and noticed that something strange was with foreach.
As my variable contained as string then compileForeach() function using preg_match('/\( *(.*) *as *([^\)]*)/', $expression, $matches); split incorrectly @foreach ($cancelReasons as $code => $reason) part.

Don't know if this is correct way to fix it but changing preg_match part to preg_match('/\( *(.*) * as *([^\)]*)/', $expression, $matches); (added space between * as) helped solve my issue.

Maybe there is better way solving this or at least this could help someone.

@jorgecc
Copy link
Member

jorgecc commented Sep 28, 2017

Im not fancy of using regular expression. This part of the code comes directly from Laravel, so may be they get it bad too.
I added this fix.

@jorgecc jorgecc closed this as completed Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants