composer installができなくなった時の解決法(PHP7.3)


PHP7.3にしたら、composer installができなくなった。
(PHP7.2に下げれば根本解決するらしいです。)

$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)


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


install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...

  

Google翻訳さんに聞いたら、

"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?   
→ 「continue」ターゲティングスイッチは「break」と同じです。 "continue 2"を使用するつもりでしたか?  

とのことらしいです。どっかで使ってるんでしょうね。。。。
PHP 7.3から”break”の代わりに”continue”は使えなくなるらしいです。

参考:https://blog.ohgaki.net/php-7-3#continue

  

 解決策

  • composerのバージョンが古い場合、composerのバージョンをあげる。

※composerのバージョンが新しい場合はこちら
【2019年1月現在】PHP7.3でcomposerが使えなくなるバグの対策

 
composerのバージョンを確認。

$ composer -V
Composer version 1.1.2 2016-05-31 19:48:11

composer自体のバージョンをあげる。

$ composer self-update
Updating to version 1.8.0 (stable channel).
    Downloading: 100%         
Use composer self-update --rollback to return to version 1.1.2
$ composer -V
Composer version 1.8.0 2018-12-03 10:31:16

composer install できた!

$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 28 installs, 0 updates, 0 removals

  - Installing sebastian/version (2.0.1): Loading from cache
....

Writing lock file
Generating autoload files