LoginSignup
1
0

More than 1 year has passed since last update.

php cs fixer(0.2.2)のbuiltinされているpharがv3にアップロードされたので対応

Posted at

VSCodeのphp cs fixer(junstyle.php-cs-fixer)が0.2.2のアップデートで、同梱されているphp-cs-fixerがv3に変わったので、作業中のプロジェクトでエラーが出たり、今まで使っていた設定ファイルが読み込まれない状況に対応しました。

1. 設定ファイル名の変更

.vscodeディレクトリに.php_csを置いていたのですが、ファイル名を変更しなければならないようです。

Configuration file `.php_cs` is outdated, rename to `.php-cs-fixer.php`.

2. 拡張の設定変更

before

{
    "php-cs-fixer.config": ".php_cs;.php_cs.dist;"
}

after

{
    "php-cs-fixer.config": ".php-cs-fixer.php;.php-cs-fixer.dist.php;.php_cs;.php_cs.dist;"
}

3. 設定ファイル内容の変更

Configのcreateメソッドがv3で廃止されたので、初期化のやり方を変える必要があります。

before

<?php

return PhpCsFixer\Config::create()
    ->setRules([
        '@PSR2' => true,
        (省略)
    ])
    // ->setIndent("\t")
    ->setLineEnding("\n")
;

after

<?php

return (new PhpCsFixer\Config())
    ->setRules([
        '@PSR2' => true,
        (省略)
    ])
    // ->setIndent("\t")
    ->setLineEnding("\n")
;

あと、ルールの設定方法が変わっているものがあるので、

UPGRADE GUIDE FROM 2.x to 3.0

をみて、使っている設定の書き方が変わってないか確認します。

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0