TomasVotruba / bladestan

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

Create new $loop rather then replacing it with a docblock #50

Closed AJenbo closed 1 year ago

AJenbo commented 1 year ago

In some cases the previous implementation would generate the following code:

    foreach ($__currentLoopData as $productGroup) {
        /** @var \TomasVotruba\Bladestan\ValueObject\Loop $loop */
            if ($loop->first) {
                ?> class="active" <?php 
            }
        unset($loop);
    }

The new solution instead does the following:

    foreach ($__currentLoopData as $productGroup) {
        $loop = \TomasVotruba\Bladestan\ValueObject\Loop();
            if ($loop->first) {
                ?> class="active" <?php 
            }
        unset($loop);
    }

This looks to probably have been related to some bad assumptions about the actual code structure.

TomasVotruba commented 1 year ago

Thanks 🙏