outl1ne/nova-multiselect-field

Syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')'

Closed this issue · 2 comments

I have been using this package for quite a while but I have encountered the following error recently

exception: "ParseError"
file: "/var/www/html/vendor/outl1ne/nova-multiselect-field/src/Traits/MultiselectBelongsToSupport.php"
line: 109
message: "syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')'"

The error seems to be in regard to this line, about to the '{' and '}'

return $value->map(fn ($model) => $model->{$this->keyName ?? $model->getKeyName()})->toArray();

A simple fix to something like this should be enough

return $value->map(function ($model) {
    $tempKeyName = $this->keyName ?? $model->getKeyName();
    return $model->$tempKeyName;
})->toArray();

Link to the Pull Request

Thanks for the report.
What version of php are you running?
Unable to reproduce it myself with 8.1.13

Heya! I fixed it for backwards compatibility in 4.3.0. :) Thanks!