blade-formatter icon indicating copy to clipboard operation
blade-formatter copied to clipboard

array_reduce function breaks

Open formikaio opened this issue 3 years ago • 1 comments

Current Behavior

These lines: @php $n = array_reduce($c, function ($tot, $i) {return $tot + $i; }, 0); @endphp

are formatted like this: @php $n = array_reduce( $c, function ($tot, $i) { return $tot + $i; }, 0, ); @endphp

An extra comma is added after the last parameter (probably the formatter mistakes the array_reduce function for an array declaration). The issue probably affects other array_* functions.

formikaio avatar Mar 11 '21 08:03 formikaio

@formikaio Thank you for reporting issue. blade-formatter currently formats php strings as php 7.4 and php version above 7.3 supprots trailing commas in functions.

image

image

If your environment is below 7.3, it does not support trailing comma syntax and it might happen syntax exception.

I think the possible solution is to allow users to select the php version for format style. I'm not sure if this is a good solution, but I'll take consider it.

shufo avatar Mar 21 '21 13:03 shufo

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

github-actions[bot] avatar Dec 06 '22 01:12 github-actions[bot]