Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phpunit not working, says "PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? on line 277" [duplicate]

Tags:

php

symfony

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"?

like image 571
tenderfoot Avatar asked Jan 14 '19 15:01

tenderfoot


7 Answers

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.

like image 52
Miftah Mizwar Avatar answered Oct 09 '22 21:10

Miftah Mizwar


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');"
like image 22
Avnish alok Avatar answered Oct 09 '22 23:10

Avnish alok


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.

like image 28
Jon Avatar answered Oct 09 '22 21:10

Jon


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!

like image 45
Arun Panneerselvam Avatar answered Oct 09 '22 21:10

Arun Panneerselvam


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;

   }

like image 37
d212digital Avatar answered Oct 09 '22 23:10

d212digital


composer self-update composer install

Now, it should works

enter image description here

like image 28
code-8 Avatar answered Oct 09 '22 23:10

code-8


Did you try to do a composer self-update?

composer self-update

or

composer install

like image 38
kheengz Avatar answered Oct 09 '22 23:10

kheengz