[php] Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?

I have php7.3 and symfony2.8 When I try to create the classes with the console I get this error:

[Symfony\Component\Debug\Exception\ContextErrorException]Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?

This question is related to php symfony

The answer is


after upgrading my xampp from 7.2.0 to 7.3.0 i face this issue but after unistall composer.exe and install latest composer.exe from composer.org than issue resolved


I had to upgrade doctrine/orm:

composer update doctrine/orm

Updating doctrine/orm (v2.5.13 => v2.6.6)

that seems to be an issue with php7.3, I guess.

If you have different version installed on your system then you could use this:

php7.1 /usr/bin/composer update // or wherever your composer is

it worked for me


In order to eliminate this error, you have to fo to the wp-config file and add these lines of code

define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);

I had the same issue. but fixed it by downloading composer & installing it from scratch.


If your code cannot be updated on some reason, just change your switch ... continue to switch ... break, as in previous versions of PHP it was meant to work this way.


Sorry for the "diggy up", but i just encoured this issue with an symfony3.8 project deploiement on shared hosting (php 7.3.18)...

I solved this issue by set the php memory limit in the command line options, a stuff like this:

php -dmemory_limit=-1 /path/to/the/executable


The issue looks to me to be a backward incompatibility with PHP 7.3 for the continue keyword in Switch statements. Take a look at the "Continue Targeting Switch issues Warning" section in Backward Incompatible Changes.

I ran into the same issue with Symfony 3.3 using PHP 7.3 and downgrading to PHP 7.2 resolved the warning.


Did you try to do a composer self-update?

composer self-update

or

composer install


I've got same problem and got this error too, but in my case this error shows when i'm trying to run composer install or composer update.

and i solve this issue by running composer self-update. it works on my project.


I changed continue to continue 2 on line 1579 in shortcodeComon.php and it fixed my problem

   if(trim($custom_link[$i]) == ""){

           continue;

    }

Change to:

  if(trim($custom_link[$i]) == ""){

             continue 2;

   }


composer self-update composer install

Now, it should works

enter image description here


I've got the same problem when I run composer install
I solve it by doing in composer directory php composer.phar self-update and then in my project directory composer update


Windows 10 Professional

PHP 7.3.1

I ran these commands to fix the problem on my desktop

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php

I think it's a version problem, you just have to uninstall the old version of composer, then do a new installation of its new version.

 apt remove composer

and follow the steps:

  1. download the composer from its official release site by making use of the following command.
 wget https://getcomposer.org/download/1.6.3/composer.phar
  1. Before you proceed with the installation, you should rename before you install and make it an executable file.
  mv composer.phar composer
  chmod +x composer
  1. Now install the package by making use the following command.
 ./composer
  1. The composer has been successfully installed now, make it access globally using the following command. for Ubuntu 16
 mv composer /usr/bin/

for Ubuntu 18

 mv composer /usr/local/bin/

Maybe your composer is outdated. Below are the steps to get rid of the error.

Note: For Windows professionals, Only Step2 and Step3 is needed and done.


Step1

Remove the composer:

sudo apt-get remove composer

Step2

Download the composer:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

Step3

Run composer-setup.php file

php composer-setup.php

Step4

Finally move the composer:

sudo mv composer.phar /usr/local/bin/composer  


Your composer should be updated now. To check it run command:

composer

You can remove the downloaded composer by php command

php -r "unlink('composer-setup.php');"

On debian 9 php7.3 the answer above pasted below worked perfectly.


sudo wget https://getcomposer.org/download/1.8.0/composer.phar -O /usr/local/bin/composer && sudo chmod 755 /usr/local/bin/composer

Or download composer.phar from site: "https://getcomposer.org/download/" (manual download), and use command:

php composer.phar require your/package

In my case php was upgraded from php7.2.22 to php7.3.9.

so had to downgrade cli php as composer is run on terminal

//checked php version
php -v //was 7.3.9

//changed cli version back to 7.2
sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set phar /usr/bin/phar7.2
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
sudo update-alternatives --set phpize /usr/bin/phpize7.2
sudo update-alternatives --set php-config /usr/bin/php-config7.2

//checked php version 
php -v //was 7.2.22

additional info if you are using apache remember to keep both cli and apache in same version. in my case i had to downgrade

//changed web version back to 7.2
sudo a2dismod php7.3
sudo a2enmod php7.2
sudo service apache2 restart

This will work with other versions. so feel free to switch between versions. just replace the version numbers appropriately


I upgraded to PHP 7.3, and None of these worked for me before I used,

sudo wget https://getcomposer.org/download/1.8.0/composer.phar -O /usr/local/bin/composer && sudo chmod 755 /usr/local/bin/composer

It's just the version dependency. PHP 7.3

and composer update worked like a charm!


@aimme's answer should be accepted!

I would extend his answer with @david-baucum's comment because his explanation is clear!

I would also extend his answer that you can run multiple PHP versions at the same time using ppa:ondrej/php.

Then you don't need to change the PHP version simple call the composer like this: /usr/bin/php7.2 /usr/local/bin/composer install