Open fh32000 opened 4 months ago
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
@fh32000
I'd recommend you to use @php
~ @endphp
directive for long line:
<html>
<head></head>
<body>
@php
$notification = App\Models\Notification::whereBetween('created_at', [auth('seller')->user()->created_at, Carbon::now()])->where('sent_to', 'seller')->whereDoesntHave('notificationSeenBy')->count()
@endphp
</body>
</html>
would formatting to
<html>
<head></head>
<body>
@php
$notification = App\Models\Notification::whereBetween('created_at', [
auth('seller')->user()->created_at,
Carbon::now()
])
->where('sent_to', 'seller')
->whereDoesntHave('notificationSeenBy')
->count();
@endphp
</body>
</html>
Or use the --no-trailing-comma-php
option for work around.
➜ ./bin/blade-formatter.js test.blade.php --no-trailing-comma-php
<html>
<head></head>
<body>
@php(
$notification = App\Models\Notification::whereBetween('created_at', [auth('seller')->user()->created_at, Carbon::now()])->where('sent_to', 'seller')->whereDoesntHave('notificationSeenBy')->count()
)
</body>
But I think this case should be fixed as it cause syntax error. Thanks.
Version
1.41.1
Template before formatting
Template after formatting
Expected Behaviour
Relevant log output The error encountered during runtime due to the added comma results in a PHP syntax error:
Additional Context
Laravel Version: v10.48.9 Issue occurs in a development environment using Laravel Blade files, specifically impacting PHP expressions wrapped in @php directives. Steps to Reproduce
Use a Blade file with a complex @php directive containing multiple chained method calls. Format the file using the blade-formatter with the specified configuration. Observe the introduction of a comma at the end of the PHP expression, leading to syntax errors.
Relevant log output