Reputation: 23
Since I updated my composer.json
(I just switched symfony
, console
, dotenv
, framework-bundle
, yaml
versions from "5.0.*
to,"5.2.*
), I have this error:
syntax error, unexpected '|', expecting variable (T_VARIABLE)
coming from line 27, file vendor/psr/link/src/EvolvableLinkInterface.php
.
(public function withHref(string|\Stringable $href);
)
I decided to remove one of my facultative parameter type hint (eg. \Stringable
) and it worked well.
I'm running under PHP 7.4.15
.
Do you know how could I fixed it?
Upvotes: 2
Views: 2380
Reputation: 905
It seems that our good buddies at https://github.com/php-fig jumped the gun with using Union Type Hints which is only available with php8. They did not provide support for php7. They went from php5 to php8 for some reason. You can see this in packagist:
psr/link v1.0.0 vs psr/link v1.1.0
Also in:
psr/log v1.1.4 vs psr/log v2.0.0
This is causing issues also in Laravel 7 that relies on psr/log and running php7.
You will need to specify an older package versions:
composer require psr/link "1.0.*"
composer require psr/log "^1.0"
Upvotes: 2