Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.3 breaks composer with continue/targeting error (solution: downgrade to 7.2) #7783

Closed
kakohari opened this issue Nov 13, 2018 · 15 comments

Comments

Projects
None yet
@kakohari
Copy link

commented Nov 13, 2018

PHP version not working:

/usr/bin/php7.3 -v
PHP 7.3.0RC4 (cli) (built: Nov  7 2018 10:06:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.0RC4, Copyright (c) 1999-2018, by Zend Technologies

PHP version working:

PHP 7.2.12-1+0~20181112102304.11+stretch~1.gbp55f215 (cli) (built: Nov 12 2018 10:23:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.12-1+0~20181112102304.11+stretch~1.gbp55f215, Copyright (c) 1999-2018, by Zend Technologies

My composer.json:

empty / not existing

Output of composer diagnose:

[some bullshit complaining about a wrong SPDX-license code which is clearly existing on https://spdx.org/licenses/]
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK

When I run this command:

kako@devserver:~/skripte$ composer require mpdf/mpdf -vvv

I get the following output:

Reading ./composer.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/home/kako/skripte): git branch --no-color --no-abbrev -v
Executing command (/home/kako/skripte): git describe --exact-match --tags
Executing command (/home/kako/skripte): git log --pretty="%H" -n1 HEAD
Reading /home/kako/.composer/composer.json
Loading config file /home/kako/.composer/composer.json
Running 1.2.2 (2016-11-03 17:43:15) with PHP 7.3.0RC4 on Linux / 4.9.0-8-amd64
Downloading https://packagist.org/packages.json
Writing /home/kako/.cache/composer/repo/https---packagist.org/packages.json into cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2013.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2014.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2015.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2016.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2017.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2018-01.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2018-04.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2018-07.json from cache
Downloading http://packagist.org/p/provider-2018-10%24aa9e2fdf4422be2ee3f3633edaf047f05e92c0ec96f760c5fa2f2257f89fa98e.json
Writing /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2018-10.json into cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-archived.json from cache
Downloading http://packagist.org/p/provider-latest%2430d19a056d26ac01f571e70ec61607d697a76339914cc646bdfa8416f79f7f07.json
Writing /home/kako/.cache/composer/repo/https---packagist.org/p-provider-latest.json into cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/provider-mpdf$mpdf.json from cache
Using version ^6.1 for mpdf/mpdf
./composer.json has been updated
Reading ./composer.json
Loading config file ./composer.json
Executing command (/home/kako/skripte): git branch --no-color --no-abbrev -v
Executing command (/home/kako/skripte): git describe --exact-match --tags
Executing command (/home/kako/skripte): git log --pretty="%H" -n1 HEAD
Reading /home/kako/.composer/composer.json
Loading config file /home/kako/.composer/composer.json
Loading composer repositories with package information
Downloading https://packagist.org/packages.json
Writing /home/kako/.cache/composer/repo/https---packagist.org/packages.json into cache
Updating dependencies (including require-dev)

Installation failed, reverting ./composer.json to its original content.

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

Exception trace:
 () at /usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php:286
 Composer\Util\ErrorHandler::handle() at /usr/share/php/Composer/autoload.php:258
 require() at /usr/share/php/Composer/autoload.php:258
 {closure}() at n/a:n/a
 spl_autoload_call() at /usr/share/php/Composer/DependencyResolver/Solver.php:75
 Composer\DependencyResolver\Solver->__construct() at /usr/share/php/Composer/Installer.php:459
 Composer\Installer->doInstall() at /usr/share/php/Composer/Installer.php:216
 Composer\Installer->run() at /usr/share/php/Composer/Command/RequireCommand.php:175
 Composer\Command\RequireCommand->execute() at /usr/share/php/Symfony/Component/Console/Command/Command.php:259
 Symfony\Component\Console\Command\Command->run() at /usr/share/php/Symfony/Component/Console/Application.php:844
 Symfony\Component\Console\Application->doRunCommand() at /usr/share/php/Symfony/Component/Console/Application.php:192
 Symfony\Component\Console\Application->doRun() at /usr/share/php/Composer/Console/Application.php:231
 Composer\Console\Application->doRun() at /usr/share/php/Symfony/Component/Console/Application.php:123
 Symfony\Component\Console\Application->run() at /usr/share/php/Composer/Console/Application.php:104
 Composer\Console\Application->run() at /usr/bin/composer:44

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader]` [-a|--classmap-authoritative] [--] [<packages>]...

And I expected this to happen:
composer installing mpdf ;-)

@xabbuh

This comment has been minimized.

Copy link
Contributor

commented Nov 13, 2018

Which version of Composer do you use? This has been fixed in c861535 which was part in all releases starting with 1.6.0.

@kakohari

This comment has been minimized.

Copy link
Author

commented Nov 13, 2018

Composer version 1.2.2 2016-11-03 17:43:15

Sorry, my bad. self-upgrading seems not be part of this version(?), coming from a debain package. Did't expect it being that old...

@Seldaek

This comment has been minimized.

Copy link
Member

commented Nov 13, 2018

Yeah.. thanks linux packages :/ Please install from https://getcomposer.org to get the latest code. We can't offer support for outdated versions sorry.

@lserni

This comment has been minimized.

Copy link

commented Feb 11, 2019

As a quick and dirty alternative, you can fix the error in that one file. Just replace "continue" with "break" (or maybe "continue 2").

/usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php at line 286

@rafaelqueiroz88

This comment has been minimized.

Copy link

commented Feb 14, 2019

As a quick and dirty alternative, you can fix the error in that one file. Just replace "continue" with "break" (or maybe "continue 2").

/usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php at line 286

It works to me. Thanks!

@Haritsinh

This comment has been minimized.

Copy link

commented Feb 18, 2019

For me Same error occured as:

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

and what i have done is downloaded the latest composer from the official site and now it is working fine so there is not any fault of PHP 7.3. And downgrading to PHP 7.2 is not the solution. it is giving error because of old version of composer and if you are troubling with the same issue try to upgrading the composer first and see if it works for you.

@voghDev

This comment has been minimized.

Copy link

commented Mar 5, 2019

For me Same error occured as:

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

and what i have done is downloaded the latest composer from the official site and now it is working fine so there is not any fault of PHP 7.3. And downgrading to PHP 7.2 is not the solution. it is giving error because of old version of composer and if you are troubling with the same issue try to upgrading the composer first and see if it works for you.

Can you add instructions or example code to upgrade composer please?

@dbrumann

This comment has been minimized.

Copy link
Contributor

commented Mar 5, 2019

@voghDev This is not related to composer. One of your dependencies is raising a warning with PHP 7.3. You have to find out which one and upgrade it. I know that doctrine/orm used to have this problem, but it could also be anything else. Maybe take this to stackoverflow with a detailed description which command showed the error and what your composer.json & lock looks like.

@voghDev

This comment has been minimized.

Copy link

commented Mar 5, 2019

Thanks for the information. My case is not the same as the creator of the issue but I was getting the same error (the one pointed by @Haritsinh). Finally solved it upgrading my version of composer as he mentioned. I did it by following the download instructions in getcomposer.org. Thanks everyone for your help :)

@exenin

This comment has been minimized.

Copy link

commented Mar 5, 2019

Thanks @voghDev
used your suggestion. adding
`

UPGRADE COMPOSER

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"

`

in the web dockerfile . just before composer is used solved this for me

@harrygulliford

This comment has been minimized.

Copy link

commented Mar 7, 2019

Using composer self-update worked for me!

@thewhiterabbit

This comment has been minimized.

Copy link

commented Apr 17, 2019

If this is fixed and the website is the best way to get the latest composer...please explain this!
Screenshot_2019-04-17_06-59-12
Screenshot_2019-04-17_07-11-29

@dbrumann

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2019

You execute the command with the old version (as seen in your second screenshot). Your new installation is stored locally as /var/www/omofomo/com/composer.phar. You probably want to remove the composer installation installed via your package manager (apt or yum) and then store the manual installation in a folder that is accessible in your PATH environment variable. If you need help, this issue tracker is unfortunately not the right place for this, instead consider opening a question in an appropriate forum, e.g. on askubuntu.

@thewhiterabbit

This comment has been minimized.

Copy link

commented Apr 17, 2019

Correct! I did neglect to apt-get remove composer. Thank you. Sorry for my mistake.

@PragnaBrahmbhatt

This comment has been minimized.

Copy link

commented May 22, 2019

As a quick and dirty alternative, you can fix the error in that one file. Just replace "continue" with "break" (or maybe "continue 2").

/usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php at line 286

Thanks.. worked for me..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.