Skip to content

[12.x] Fix using pushIf blade directive with complex conditions (#57264)#57274

Merged
taylorotwell merged 3 commits into
laravel:12.xfrom
hosni:12.x
Oct 4, 2025
Merged

[12.x] Fix using pushIf blade directive with complex conditions (#57264)#57274
taylorotwell merged 3 commits into
laravel:12.xfrom
hosni:12.x

Conversation

@hosni

@hosni hosni commented Oct 4, 2025

Copy link
Copy Markdown
Contributor

This PR fixes an issue where the @pushIf directive incorrectly parsed expressions containing multiple commas within nested function calls or array arguments.
This caused the directive to generate invalid PHP during compilation when the condition itself contained commas.

Before

@pushIf(Str::startsWith('abc', 'a'), 'body-end')
test
@endPushIf

To:

<?php if(Str::startsWith('abc'): $__env->startPush( 'a'), 'body-end'); ?>
test
<?php $__env->stopPush(); endif; ?>

❌ Compiled incorrectly, broken expression.

After

✅ Compiles correctly:

@pushIf(Str::startsWith('abc', 'a'), 'body-end')
test
@endPushIf

To:

<?php if(Str::startsWith('abc', 'a')): $__env->startPush('body-end'); ?>
test
<?php $__env->stopPush(); endif; ?>

This is related to issue: #57264

@taylorotwell taylorotwell merged commit 1f0bcbf into laravel:12.x Oct 4, 2025
64 checks passed
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

Successfully merging this pull request may close these issues.

2 participants