skip to Main Content

I have asked my hosting provider to switch the operating system on my server from Centos to Ubuntu. Upon downloading all my files from GitHub and running “composer install” I am getting the following error in terminal:

Deprecation Notice: The behavior of unparenthesized expressions containing both ‘.’ and ‘+’/’-‘ will change in PHP 8: ‘+’/’-‘ will take a higher precedence in /usr/share/php/Composer/Downloader/GitDownloader.php:223
Deprecation Notice: The behavior of unparenthesized expressions containing both ‘.’ and ‘+’/’-‘ will change in PHP 8: ‘+’/’-‘ will take a higher precedence in /usr/share/php/Composer/Downloader/SvnDownloader.php:132

After this composer quits so I need to be able to resolve this not worked around it.

Already tried solutions:

  • Uninstall and re-install composer.
  • Upgrade, update, and install commands attempted.
  • A fresh install of Laravel in case of corruption on Git clone.

6

Answers


  1. How to solve it

    Put parenthesis surrounding

    $someString . ($a + $b) . $anotherString
    

    What is the error

    If you’d write something like this:

    echo "sum: " . $a + $b;
    

    PHP would previously interpret it like this:

    echo ("sum: " . $a) + $b;
    

    PHP 8 will make it so that it’s interpreted like this:

    echo "sum: " . ($a + $b);
    

    source: https://stitcher.io/blog/new-in-php-74

    Login or Signup to reply.
  2. If composer self-update is not solve your problem, re-installing composer is best way.

    https://getcomposer.org/download/

    My composer also gave these errors and self-update not worked.

    Login or Signup to reply.
  3. While working on a new project this morning, I encountered a similar error. And my solution : if an expression has . with +,- etc. you must add parenthesis,

       $this->io->writeError('    <info>' .count($changes) - 10 . ' more files modified, choose "v" to view the full list</info>');
    

    to

       $this->io->writeError('    <info>'.(count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
    
    Login or Signup to reply.
  4. echo ‘Total’ . 5 + 5;

    Deprecated: The behavior of unparenthesized expressions containing both ‘.’ and ‘+’/’-‘ will change in PHP 8: ‘+’/’-‘ will take a higher precedence in … on line …

    From PHP 8 and later, this will be evaluated as ‘total’ + (5 + 5), with the + and – operators taking higher precedence.

    Login or Signup to reply.
  5. upgrade composer using this command composer self-update
    happy coding

    Login or Signup to reply.
  6. You can rename the composer.phar file with composerOld.phar and download new file manually from the official site and put it over there.
    It will work.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search