Skip to content

Comments

Fix parsing of php blocks#23

Merged
ganyicz merged 2 commits intomainfrom
filip/fix-php-block-parsing
Jan 15, 2026
Merged

Fix parsing of php blocks#23
ganyicz merged 2 commits intomainfrom
filip/fix-php-block-parsing

Conversation

@ganyicz
Copy link
Collaborator

@ganyicz ganyicz commented Jan 15, 2026

The problem

Blaze currently parses component syntax in php blocks.

This causes issues in a component like <flux:modal>:

@php
// Support <flux:modal ... @close="?"> syntax...
if ($attributes['@close'] ?? null) {
    $attributes['wire:close'] = $attributes['@close'];

    unset($attributes['@close']);
}
@endphp

The solution

We are calling the storeVerbatimBlocks method from Blade compiler which fixes a similar issue for @verbatim usage.

The blade compiler already deals with this exact issue with @php blocks in the storeUncompiledBlocks:

/**
 * Store the blocks that do not receive compilation.
 */
protected function storeUncompiledBlocks($value)
{
    if (str_contains($value, '@verbatim')) {
        $value = $this->storeVerbatimBlocks($value);
    }

    if (str_contains($value, '@php')) {
        $value = $this->storePhpBlocks($value);
    }

    return $value;
}

The solution is to call this method which already includes storeVerbatimBlocks and also storePhpBlocks.

Fixes #17
Fixes #22

@ganyicz ganyicz merged commit ac2b863 into main Jan 15, 2026
6 checks passed
@ganyicz ganyicz deleted the filip/fix-php-block-parsing branch January 15, 2026 11:40
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.

Tokenizer parses component tags inside PHP comments Using $attributes-Bag on Flux:Modal-Component

1 participant