4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHP CS Fixer 2.0がリリースされていた

Last updated at Posted at 2017-01-05

PHP CS Fixer 2.0がリリースされていた

composer updateかけた後にcommitしたら怒られて、はてなんじゃらほいと思ったら、今日2.0がリリースされていたようで。

PHP CS Fixerについて

詳しくはこちらとかで。

1.x -> 2.0 の変更点まとめ

刺さった1 .php_csの書き方が変わってた

1.x

<?php
$finder = Symfony\CS\Finder\DefaultFinder::create()
    ->exclude('vender')
    ->exclude('server')
    ->exclude('webroot')
    ->in(__DIR__);

return Symfony\CS\Config\Config::create()
    ->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
    ->setUsingCache(true)
    ->finder($finder);

2.0

<?php
$finder = PhpCsFixer\Finder::create()
    ->exclude('vender')
    ->exclude('server')
    ->exclude('webroot')
    ->in(__DIR__);

return PhpCsFixer\Config::create()
    ->setRules(array(
        '@PSR2' => true,
    ))
    ->setUsingCache(true)
    ->setFinder($finder);
Symfony\CS\Finder -> PhpCsFixer\Finder  
Symfony\CS\Config -> PhpCsFixer\Config  

てな感じでNamespaceが変わっている。
それに合わせてRuleの書き方も変わっているので、ご注意を。
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/UPGRADE.md#namespace

刺さった2 --config-file が --config になっていた

1.x

--config-file="/path/to/.php_cs"

2.0

--config "/path/to/.php_cs"

CLIのオプションも結構変わっている。
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/UPGRADE.md#cli-options

4
2
0

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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?