phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

Error Formating blade files (v1.45.15382 (pre-release))

Open trollfalgar opened this issue 9 months ago • 18 comments

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.

image

But when formatting a file with more complex parameters for blade component (or livewire component), the extension crashes, and restart.

image

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.

image

vs

image

I hope the explenation is clear. ^^'

Here are the logs:

image

I also receave the following message:

image

Obs: The false errors in the files are not present anymore.

trollfalgar avatar May 03 '24 16:05 trollfalgar

Obs.: If I use Developer: Reload Window or restart the VSCode after formatting, the error or the message bellow will not apprear.

image

trollfalgar avatar May 03 '24 16:05 trollfalgar

thanks, will be fixed!

jakubmisek avatar May 03 '24 19:05 jakubmisek

It must be something else, works for me:

vsc-format-blade

jakubmisek avatar May 03 '24 20:05 jakubmisek

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

trollfalgar avatar May 03 '24 20:05 trollfalgar

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.

trollfalgar avatar May 03 '24 20:05 trollfalgar

May I ask for the whole file?

Miloslav avatar May 04 '24 16:05 Miloslav

Sure, here it is.

list-index.blade.zip

Other similar files also gives me errors.

trollfalgar avatar May 04 '24 19:05 trollfalgar

Thank you! I'm not able to replicate this. May I ask if you have other extensions installed? Maybe there is some unwanted interference.

Miloslav avatar May 06 '24 12:05 Miloslav

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.

image

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.

image

trollfalgar avatar May 06 '24 16:05 trollfalgar

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.

image

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.

image

trollfalgar avatar May 06 '24 16:05 trollfalgar

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?

Miloslav avatar May 07 '24 13:05 Miloslav

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.

trollfalgar avatar May 07 '24 14:05 trollfalgar

About the $this-> inside a blade in Livewire is normal to call a function for exemple. Should not retorn a warning or error.

image

trollfalgar avatar May 08 '24 01:05 trollfalgar

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.

jakubmisek avatar May 08 '24 14:05 jakubmisek

An update about error formatting. When I'm using the directives @foreach or @forelse I get an error to format the file.

image

image

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).

trollfalgar avatar May 13 '24 23:05 trollfalgar

Inside @php directive the formatter add extra identation each time we format the file.

image

trollfalgar avatar May 16 '24 00:05 trollfalgar

@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

jakubmisek avatar May 16 '24 09:05 jakubmisek

Sure @jakubmisek, here's the file. select-multiple.blade.zip

trollfalgar avatar May 16 '24 20:05 trollfalgar