0
I have this mistake on line 38, the code is like this
syntax error, unexpected '[', expecting ')'vendor/sendgrid/sendgrid/lib/helpers/mail/Mail.php on line 38
The code:
public function jsonSerialize()
{
return array_filter(
[
'email' -> $this->getEmail()
]
);
}
I think it might be incompatibility with server, because on my localhost it works, the server PHP and 5.4, someone knows how to solve
The notation
[]
for arrays was just added in version 5.4, so it shouldn’t be a problem; allied to this, there is no such thing in PHP->
. To arrays associative uses=>
.– Woss
Errata: "Does not exist in PHP" when the context is array. Exists when treated of objects.
– Woss
That said and considering the fact that the error occurred in a third party library file,
sendgrid/sendgrid
, I’d say it’s not enough that you fix the syntax in the file. If there is an error due to syntax incompatibility it is because you are using libraries incompatible with the installed version (or vice versa). The ideal is to upgrade PHP to a version that satisfies all its dependencies.– Woss