phptools-docs
phptools-docs copied to clipboard
Error Formating blade files (v1.45.15382 (pre-release))
Version: 1.45.15382 (pre-release)
When formatting a simple blade file (with some components and Livewire component even, the file is formatted without problems.
But when formatting a file with more complex parameters for blade component (or livewire component), the extension crashes, and restart.
I believe the problem is how we pass the parameters :sortColumn="$sortColumn" :order="$order"
or even :$sortColumn :$order
, with colon. Indicating we are passing a PHP expression and have line break.
As you can see in the image below, the code :order="$order"
is in the next line. This way, the extension crashes. BUT, if I remove the break line, and put all the code in one line, the formatting works fine.
vs
I hope the explenation is clear. ^^'
Here are the logs:
I also receave the following message:
Obs: The false errors in the files are not present anymore.
Obs.: If I use Developer: Reload Window or restart the VSCode after formatting, the error or the message bellow will not apprear.
thanks, will be fixed!
It must be something else, works for me:
Works at the first time. After formatting, if you make a change and mess up with identation for exemple and format again, the message error message appears.
If I reload the window works again, but the loop continue.
https://github.com/DEVSENSE/phptools-docs/assets/441455/93d59e14-fc4b-490d-8673-83b6b479234b
But, I did the same as you in your exemple, a blade file with just a table, and works with no problem. Now I don't know what could be the problem. There are no error output beside the message. And the full file I sent as example in the other issue, are being formatted in the first time perfectly, after that, the error occur.
May I ask for the whole file?
Thank you! I'm not able to replicate this. May I ask if you have other extensions installed? Maybe there is some unwanted interference.
I disabled every extension installed except PHP, PHP Profiler and IntelliPHP, Composer and WSL (I don't have extensions for blade anymore).
On files without tables, a get this error after the first formatting.
On files with a table (practically all my files in this project are similar), I get this error. But, there is no error on the file, at least no error I (or PHP) identify.
The error change on line 5, most often occurs when there are no changes to the file and the format command is triggered.
In another file, the line number changed.
One thing I identify as well is this.
Calling $this
inside a Livewire blade trigger the error above (when formating), but should give us the message of syntax error.
Thank you. May I ask you to try the latest pre-release? If it still occurs we can arrange an online call if you don't mind?
Yes, I'm using v1.45.15391, nothing changed. We can make an online call, no problem. Today after 6PM UTC or tomorrow I'm available.
About the $this->
inside a blade in Livewire is normal to call a function for exemple.
Should not retorn a warning or error.
There are a few related fixes in pre-release 1.46.15400
.
@trollfalgar $this
underlined as warning not resolved there yet - will be fixed later.
An update about error formatting.
When I'm using the directives @foreach
or @forelse
I get an error to format the file.
TO FOREACH Couldn't format the code due to unexpected change on line 257. Please report it at community.devsense.com., Line Offset: 0
TO FORELSE Couldn't format the code due to unexpected change on line 261. Please report it at community.devsense.com., Line Offset: 0
Without then, everything works fine (and with then too, but with the code formated and the directives in the right place already).
Inside @php
directive the formatter add extra identation each time we format the file.
@trollfalgar May I ask for the complete file with @php
/@endphp
directives? It's not happening in our tests:
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
@php
$id = str($label)->slug();
$component = str($id)->replace('-', '');
@endphp
Sure @jakubmisek, here's the file. select-multiple.blade.zip