Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

"continue" targeting switch is equivalent to "break" error under php 7.3

Hello, I install laravel 5.8 on new Ubuntu 16 instance under Digital Ocean. I need to install php 7.2 and for this I run commands:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update 
sudo apt-get remove php7.0
sudo apt-get install php7.2

I was very surprosed that I found php 7.3:

# php -v
PHP 7.3.5-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May  3 2019 10:00:05) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.5-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

After that I got error on composer installing:

# composer  install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file

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

Googling I found that it is some specific php7.3 error and I wonder which can be decision here? To downgrade to php7.2(If yes how better to make it?)

Or some other decision ?

Thanks!

0 likes
6 replies
ChristophHarms's avatar

A continue that is targeting a switch block is bad practice, no matter if you are using php 7.2 or 7.3. Just because php 7.3 reports it as an error while 7.2 does not, does not mean that it is a good thing to do in 7.2. Just replace the continue by a break.

Or, of you are using a continue inside a switch that is inside a for or foreach loop, and you want to continue the outer loop from inside a case, you have to use continue 2 to target the outer loop instead of the switch, just like the error message suggests.

mstdmstd's avatar

I got error :

root@msg-laravel:~# php composer.phar self-update
Could not open input file: composer.phar
root@msg-laravel:~# sudo -H composer self-update

                                         
  [InvalidArgumentException]             
  Command "self-update" is not defined.

Is it valid command ?

mstdmstd's avatar

Running sudo update-alternatives --set php /usr/bin/php7.2 I got in console:

# php -v
PHP 7.2.18-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May  3 2019 09:23:41) ( NTS )

but phpinfo in browser shows :

PHP Version 7.0.33-0ubuntu0.16.04.4

How to refresh it?

Please or to participate in this conversation.