-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntax error, unexpected T_VARIABLE, expecting ';' #68
Comments
This is most often cause by non-terminated lined PHP statements in the template. See #57 for details. When you get a syntax error like this the line number is in relation to the compiled php, not the blade template, so not very useful. If you post the full template I can maybe spot the issue, unless it's in an included component. |
Here's the full template, with a couple changes from what I posted earlier (still the same results): @php
$itemComponent = sprintf('entity-list.%s.item', $layout->value);
@endphp
<section {{ $attributes->class(['entity-list', 'flex flex-col']) }}>
@if ($title)
<x-section-title class='entity-list__title'>
{{ $title }}
</x-section-title>
@endif
<div @class([
'entity-list__items',
sprintf('is-layout-%s', $layout->value),
'flex',
'gap-4' => $layout === \App\View\Support\EntityListLayout::GRID,
'flex-col gap-y-8' =>
$layout === \App\View\Support\EntityListLayout::STREAM,
])>
@foreach ($entities as $entity)
<div class="gap-4">
<x-dynamic-component
:component="$itemComponent"
:$entity
/>
</div>
@endforeach
</div>
</section> I've looked through the entire project for non-terminated statements in any template, but found none. I assume that the standalone |
No, that is exactly where this issue normally arises. They are normally allowed in PHP but to analyze all of the code Bladestan collects them all in to a single script. Edit: I'm not seeing any issues in the file you posted. |
Hmm… even after eliminating Is there any way I could see more detailed output to trace the exact code output that causes the issue? More ripgrep output, also double-checked in phpstorm in case my regex is bad:
|
I guess, also: do you know of any other problematic directives / bad practices to watch out for? Edit: for example, might these attributes count as non-terminated statements? <x-header
:title="$report->title()"
:image="$report->image()"
> |
If this is a partial then you can't have use statements in it as it would result in things like: @foreach([1])
@include('topic.content')
} <?php
foreach ([1] as $a) {
use App\View\Support\EntityListLayout;
} Thought I would have expected a different error if this was the issue. See #58 |
I documented the issues i found here: https://github.com/TomasVotruba/bladestan/issues/created_by/AJenbo
I don't belive that would be an issue. |
I would suggest analyzing one file at a time, enable debugging and in BladeToPHPCompiler around line 160 echo out the compiled php so you can see what it is analyzing, then you can search for the faulty line in your templates locate the cause of the issue that way. bladestan/src/Compiler/BladeToPHPCompiler.php Line 160 in 256b84c
|
If that still doesn't give you a clear result then try removing 50% of the template until it parses succesfuld, the recover 25% and continue until you find the offending line. |
Not sure exactly what's causing this error, but I can update the title if we come to a more specific description of the issue.
When I install bladestan and run phpstan for the first time, I see the following error:
There are no other reported errors.
From some of the other issue descriptions in this repo, I gather that the line number corresponds to the template, not the controller? I saw that removing a blank line in the template caused an equal change in line numbering in the error report (was L18, now is L17).
Here is the relevant context, including both the template and its corresponding
Component
class:Other notes:
EntityListLayout
is an enumEntityList.php
sprintf
sThe text was updated successfully, but these errors were encountered: