blade-formatter
blade-formatter copied to clipboard
array_reduce function breaks
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
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.
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.
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