Closed AJenbo closed 1 year ago
Hi, please send failing test case to the phpstan rule. We'll check it :+1:
This may well be a duplicate of #26, if cut down to the minimum and no other extension I get Syntax error, unexpected EOF on line 6
. So at least for now I'll not add a test case for it.
Hm turns out this is a separate issue. There is also an issue with $loop
not being known inside loops.
I'm really missing a way to have phpstan print out the generated/analyzed PHP code. Is there anyway to do so?
By hacking up phpblade a bit I can see that the compiled-php is:
<?php
/** file: foreach-include.blade.php, line: 1 */ $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop();
/** file: foreach-include.blade.php, line: 2 */ echo $__env->make('bar', ['bar' => $product], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render();
/** file: foreach-include.blade.php, line: 3 */ endforeach; $__env->popLoop(); $loop = $__env->getLastLoop();
But after transforming the includes we end up with this where it's using $products
insted of $product
<?php
/** file: foreach-include.blade.php, line: 1 */ $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop();
/** file: foreach-include.blade.php, line: 2 */ (function () use($products) {
$bar = $product;
/** file: bar.blade.php, line: 2 */ echo e($foo + 'bar');
P.s. is there some way where I can inspect the generated PHP? I'm having a few strange cases that I'm having a hard time groging.