TomasVotruba / bladestan

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

Report when a template cannot be found #56

Open AJenbo opened 1 year ago

AJenbo commented 1 year ago

Currently the package simply ignores when a template cannot be found and just assumes it's an empty file.

https://github.com/TomasVotruba/bladestan/blob/ff27832d08ea43dc0d9fee2e9d208dcb9e21ce92/src/Compiler/BladeToPHPCompiler.php#L111

If we instead throw a PHPStan\AnalysedCodeException we could report issues like these back to the user.

I gave it a quick go and it looked to work well, the only issue was that I couldn't figure out how to make this test happy since it tries to include a non existing file and I can't figure out what path it is looking in so couldn't add a file for it either.

https://github.com/TomasVotruba/bladestan/blob/main/tests/Compiler/BladeToPHPCompiler/Fixture/basic_include.blade.php#L1

But maybe it would also be better to not stop processing but simply report the issue and continue as we du currently. But I don't know how to do so :sweat_smile: