Open micc83 opened 2 years ago
Hi,
Can you show me the output of composer show symplify/template-phpstan-compiler
? (just the version)
Also, do you override any built-in Blade directive by registering your own?
Hi, sorry for not replying to you sooner but I changed my laptop and haven't been able to reproduce the error until now.
The version is:
versions : * 10.0.21
About overriding any built-in Blade directive... not that I'm aware of.
Also I confirm that errors are indeed shown under the controller and not the view file. Ex:
------ --------------------------------------------------------------------------------------------------------------------------------------
Line Domain/Reviews/Http/Controllers/ReviewController.php
------ --------------------------------------------------------------------------------------------------------------------------------------
36 Argument of an invalid type Illuminate\Contracts\Pagination\LengthAwarePaginator supplied for foreach, only iterables are supported.
That foreach is indeed inside the reviews/index.blade.php
file:
55. @foreach($reviews as $review)
which is rendered as:
53. <?php $__currentLoopData = $reviews; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $review): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
The line number (36) is indeed taken from the line returning the template:
36. return view('reviews.index', [
'reviews' => $this->reviews->paginate(),
];
Hi @canvural, I see that the issue is still in state "waiting for feedback". Is there any extra info needed to debug the issue?
Sorry, super late. Here's what I've figured out:
My template is rendered as follow:
public function create(): View
{
return view('someview');
}
{{--someview.blade.php--}}
@include('someview._form')
<?php
/** file: someview.blade.php, line: 1 */ (function () use() {
});
------ --------------------------------------------------------------
Line MyController.php
------ --------------------------------------------------------------
2 Syntax error, unexpected ')', expecting T_VARIABLE on line 2
------ --------------------------------------------------------------
So from a fast check I see that the $usePlaceholder
variable is used even if $allVariablesList
is empty.
One more issue with:
<my-vue-component :enabled="@json(Module::isActive('booking'))"></my-vue-component>
<?php
/** file: someview.blade.php, line: 1 */ echo json_encode(\Common\Settings\Models\Module::isActive('booking'), 15, 512)
------ --------------------------------------------------------------
Line MyController.php
------ --------------------------------------------------------------
2 Syntax error, unexpected T_VARIABLE, expecting ';' on line 2
------ --------------------------------------------------------------
Let me know if I'm on the right path and I'll keep debugging.
Hi @micc83,
The first issue should be fixed in the main branch. Can you try dev-main
?
I'll investigate the second issue. Thanks.
Hi, first of all thank you. I've been waiting to be able to run static analysis on my blade templates since a long time.
Unfortunately on my first try I get only a bunch of syntax errors such as:
or
What I can tell you is that, for example, SchedulePlanController doesn't even have 217 lines so, I guess, its referring to some issue in some of the blade templates rendered by the controller?
My
composer.json
is something like:My
phpstan.neon
file:I've also tried to comment larastan extension but nothing.