Closed AJenbo closed 1 year ago
We'll need exact code, in a test fixture for the rule.
Sure, I'll create a minimal code for triggering it once I get a bit further with getting on top of things :)
Went on emergency vacation ... will be back at the end of April.
Hey I'm back :D
I created a minimal project that will provoke the issue : example-app.zip
I wasn't entirely sure how to add it as a test yet. I see there are some folders that appear to have test fixtures, but I'm not sure if this should go in Blade/Compiler/PhpParser, all of them or if they need to be be hooked up somehow. So at least for a start this is the approach I feel most comfortable with (it would be helpful with a nice CONTRIBUTING.md for how to do this).
vendor/bin/phpstan analyze --error-format=blade --level 0 --debug app/Http/Controllers/ArticlesController.php
------ ---------------------------------------------
Line app/Http/Controllers/ArticlesController.php
------ ---------------------------------------------
6 Syntax error, unexpected T_ENDIF on line 6
------ ---------------------------------------------
Blade file:
@include('partials.part1', $products)
@if(true)
@include('partials.part2')
@endif
It appears to be related to providing properties for the @include directive via a variable.
I created a test case, please let me know if there is something about how to set it up that I missed.
Digging around a bit I'm thinking this might be where the issue is?
Probably this should solve the issue:
private const VIEW_INCLUDE_REPLACE_REGEX = '#echo \$__env->make\(\'%s\',( \[(.*?)?],| \$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]?,)? \\\Illuminate\\\Support\\\Arr::except\(get_defined_vars\(\), \[\'__data\', \'__path\']\)\)->render\(\);#s';
(allow for aliases given as a variable)
Indeed that was the issue, I have updated my PR from just adding a test to a full on fix. Once merged it should solve a lot of the issues I was having which should clear up the source of the remaining issues.
use statements in blad files causes parsing errors.