Closed MKodde closed 2 weeks ago
Bladestan and Larasan are both PHPStan plugins. There are no reason they should conflict and I use both together on multiple project.
I don't see any indication from the errors or what else you have included to indicate that this is caused by them conflicting. You also apparently didn't test if it still happens if you have Bladestan but not Larastan.
The Larastan PR you linked to is also relevant.
It's much more likely that this is caused by you having inline PHP in your blade file that Bladestan isn't able to transform in to an analyzable format. Can you please provide a sample of the code that can trigger this issue.
If you are not able to give me access to the project where it fails to compile the template then I will need you to narrow down the issue and provide me with a template that can trigger it.
For figuring out what is causing the issue I would suggest that you start by just analyzing RedactedController. Then remove view calls until you have just 1 in the file and the issue is still triggered.
Next edit the blade file until, start by removing any @include
or component that isn't causing the issue.
At that point you should be able to see what files trigger the issue, if preferred you can continue to reduce the offending code til you have just the minimum for triggering the issue and then share that so that I can replicate the issue.
Most likely I think your issue is caused by having non-terminated PHP statements in your temples, this isn't currently supported by Bladestan, see this issue for details: https://github.com/TomasVotruba/bladestan/issues/57
Something like would result in what you have reported:
@php
echo ''
@endphp
@if(1)
@endif
If this isn't what you issue turns out to be please provide further details and I will be happy to reopen the issue and investigate further.
Thanks for your pointers @AJenbo sadly my project is private so I can not give you direct access. I will however try to narrow down the point where the error is triggered from. My hope was that the PHPstan report would show which template causes the trouble. I'll try to report if I find out what seems to be causing the trouble.
Edit 2024-09-30 12:59
Got the sucker! It turned out to be an unexpected @else
stament in a @ifHtmx
Glad to hear you figured it out!
Bladestan still has a few rough corners but we are working on making it better all the time, PRs are very welcome 🙂
Description
Larastan does not seem to support Bladestan, at least when installing Bladestan, my analysis starts throwing a seemingly random, and false error
On line 27 of this class there is nothing wrong, not even an IF statement is found there, that line is still in the list of use statements for that controller..
Disabling Bladestan makes the error go away.
As can be read in the external link below. I found a PR discussion that larastan excludes blade templates by default. So there's that also. But this issue seems unrelated to that.
Running a more verbose phpstan run shows that Bladestan seems to be loaded by PHPStan
However, it is not listed as a loaded plugins:
Version details
External references
Found this in a Larastan PR