PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 9, 2022

[FIXED] Symfony 5.2.3 interface type-hinting

 February 09, 2022     composer-php, php, symfony, symfony5, type-hinting     No comments   

Issue

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?


Solution

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"



Answered By - shrimpwagon
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing