Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
PhpSymfonyPhp Problem Overview
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"?
Php Solutions
Solution 1 - Php
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.
Solution 2 - Php
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');"
Solution 3 - Php
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.
Solution 4 - Php
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!
Solution 5 - Php
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;
}
Solution 6 - Php
Solution 7 - Php
Did you try to do a composer self-update?
composer self-update
or
composer install
Solution 8 - Php
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
Solution 9 - Php
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
Solution 10 - Php
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
Solution 11 - Php
Or download composer.phar from site: "https://getcomposer.org/download/" (manual download), and use command:
php composer.phar require your/package
Solution 12 - Php
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
Solution 13 - Php
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
Solution 14 - Php
I had to upgrade doctrine/orm:
composer update doctrine/orm
Updating doctrine/orm (v2.5.13 => v2.6.6)
Solution 15 - 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:
- 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
- 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
- Now install the package by making use the following command.
./composer
- 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/
Solution 16 - 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
Solution 17 - Php
I had the same issue. but fixed it by downloading composer & installing it from scratch.
Solution 18 - Php
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.
Solution 19 - Php
@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
Solution 20 - Php
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
Solution 21 - Php
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);