Skip to content

[Feature Request]: make PHPStorm understand custom blade @if @else blocks #1323

@ghbob

Description

@ghbob

Feature Description

I am not sure if that's in the scope of this plugin but it's rather annoying and a reason not to use Blade custom ifs right now.

With

Blade::if('CustomIf', static fn(string $input): bool => If::customIf($input));

This works great:

@CustomIf('input')

@endCustomIf

but PHPStorm doesn't understand this:

@CustomIf('input')

@else

@endCustomIf

Missing opening directive
Directive is not closed

So there is no correct formatting and it shows errors where there are none.

Laravel does register @elseCustomIf but that's just an else if block not a working else block.

Open issues in the JetBrains tracker:
https://youtrack.jetbrains.com/projects/WI/issues/WI-42988/Indentation-and-end-start-tag-support-for-blade-Custom-If-Statements
https://youtrack.jetbrains.com/issue/WI-52830/PHPStorm-doesnt-recognize-Blade-custom-directives-companion

Laravel documentation:
https://laravel.com/docs/12.x/blade#custom-if-statements

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions