php 警告:“继续”定位开关相当于“中断”。您的意思是使用“继续 2”吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/54184707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:55:36  来源:igfitidea点击:

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

phpsymfony

提问by tenderfoot

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

我有 php7.3 和 symfony2.8 当我尝试使用控制台创建类时,出现此错误:

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

[Symfony\Component\Debug\Exception\ContextErrorException]警告:“continue”目标切换相当于“break”。您的意思是使用“继续 2”吗?

回答by Miftah Mizwar

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

我遇到了同样的问题,也遇到了这个错误,但在我的情况下,当我尝试运行composer installcomposer update.

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

我通过运行解决了这个问题composer self-update。它适用于我的项目。

回答by Avnish alok

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.

注意:对于 Windows 专业人士,只需要完成 Step2 和 Step3。



Step1

第1步

Remove the composer:

删除作曲家:

sudo apt-get remove composer

Step2

第2步

Download the composer:

下载作曲家:

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

Step3

Step3

Run composer-setup.php file

运行 composer-setup.php 文件

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命令删除下载的composer

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

回答by Jon

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

在我看来,问题是continueSwitch 语句中的关键字与 PHP 7.3 向后不兼容。查看Backward Incompatible Changes中的“Continue Targeting Switch issues Warning”部分。

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

我在使用 PHP 7.3 的 Symfony 3.3 中遇到了同样的问题,降级到 PHP 7.2 解决了警告。

回答by Cosmo Arun

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

我升级到 PHP 7.3,在我使用之前,这些都不适合我,

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

这只是版本依赖。PHP 7.3

and composer update worked like a charm!

和作曲家更新就像一个魅力!

回答by cyber8200

composer self-update composer install

composer self-update composer install

Now, it should works

现在,它应该有效

enter image description here

在此处输入图片说明

回答by John Hanley

Windows 10 Professional

Windows 10 专业版

PHP 7.3.1

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

回答by kheengz

Did you try to do a composer self-update?

您是否尝试过作曲家自我更新?

composer self-update

composer self-update

回答by d212digital

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

我在 shortcodeComon.php 中的第 1579 行更改了 continue to continue 2 并解决了我的问题

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

           continue;

    }

Change to:

改成:

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

             continue 2;

   }

回答by aimme

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

在我的情况下,php 从 php7.2.22 升级到 php7.3.9。

so had to downgrade cliphp as composer is run on terminal

所以不得不降级cliphp 因为 composer 在终端上运行

//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

如果您使用的是 apache,请记住将 cli 和 apache 保持在同一版本中。就我而言,我不得不降级

//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

这将适用于其他版本。所以可以随意在版本之间切换。只需适当替换版本号

回答by Vitalicus

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

或者从站点下载 composer.phar:“ https://getcomposer.org/download/”(手动下载),并使用命令:

php composer.phar require your/package