bdelespierre / laravel-blade-linter

A simple Blade template syntax checker for Laravel
MIT License
18 stars 5 forks source link

Error occurs when using "laravel-blade-linter.phar" lint for "Blade Component" #8

Open yaegassy opened 3 years ago

yaegassy commented 3 years ago

Repro Prepare

cd /tmp
laravel new lvlint-error-check
cd /tmp/lvlint-error-check

composer require laravel/breeze --dev
php artisan breeze:install

# package
composer require --dev bdelespierre/laravel-blade-linter

# phar
curl -LO https://github.com/bdelespierre/laravel-blade-linter/releases/download/v1.6.0/laravel-blade-linter.phar

chmod a+x laravel-blade-linter.phar

Prepare the template that will generate the error:

(resources/views/dashboard.blade.php)

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Dashboard' }} <!-- <==== Here -->
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6 bg-white border-b border-gray-200">
                    You're logged in!
                </div>
            </div>
        </div>
    </div>
</x-app-layout>

[OK] php artisan blade:lint resources/views/dashboard.blade.php

$ php artisan blade:lint resources/views/dashboard.blade.php
PHP Parse error:  syntax error, unexpected token ";", expecting ")" in resources/views/dashboard.blade.php on line 9

[NG] ./laravel-blade-linter.phar lint resources/views/dashboard.blade.php

lvlint-error-check$ ./laravel-blade-linter.phar lint resources/views/dashboard.blade.php

In Container.php line 1049:

  Target [Illuminate\Contracts\View\Factory] is not instantiable.

lint [--phpstan [PHPSTAN]] [--] [<path>...]

Misc

As a side note, Normal blade files will work fine.

(Prepare "resources/views/welcome.blade.php" so that the error occurs)

$ ./laravel-blade-linter.phar lint resources/views/welcome.blade.php
PHP Parse error:  Unclosed '(' does not match '}' in resources/views/welcome.blade.php on line 2
bdelespierre commented 3 years ago

I can reproduce the bug. I'll look into it. Thank for your support :+1:

hallowichig0 commented 1 year ago

I also encountered this error, it shows:

In Container.php line 1049:

  Target [Illuminate\Contracts\View\Factory] is not instantiable.