TomasVotruba / bladestan

PHPStan analysis for Blade templates
https://tomasvotruba.com/blog/introducing-bladestan-phpstan-analysis-of-blade-templates/
MIT License
279 stars 13 forks source link

Infinite loop on template recursion #96

Open LordSimal opened 4 months ago

LordSimal commented 4 months ago

Bladestan 0.5.0 PHP 8.3.2 PHPStan 1.10.59 with extension installer Laravel 10.45.1 Livewire 3.4.6

It seems this plugin doesn't account for template recursion as I get a

     Child process error: PHPStan process crashed because it reached configured PHP memory limit: 2G  
     Increase your memory limit in php.ini or run PHPStan with --memory-limit CLI option.    

Whenever I do something like this inside my resources/views/livewire/category/partials/options.blade.php:

@foreach($children as $category)
    <option value="{{ $category->id }}" {{ $category->id === $editingCategoryParentId ? 'selected' : '' }} >
        @for ($i = $category->lvl; $i >= 1; $i--)-@endfor
        {{ $category->name }}
    </option>
    @if($category->children)
        @include('livewire.category.partials.options', ['children' => $category->children])
    @endif
@endforeach

as you can probably see this is a blade partial to render options for a tree structure which can have multiple levels like you can see here image

When I disable the recursive template renderings I don't get the error and instead get correct balde template stan issues.

kenguest commented 1 week ago

Hi, just wanted to say I can confirm this happens for some of our blade files too - if there's a file being recursively included bladestan will just hang indefinitely.