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-CS-Fixer の導入 #996

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 41 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

if (php_sapi_name() !== 'cli') {
throw new \LogicException();
}

$rules = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

設定理由をソースコメントに残していただけると、参考になります。
特に無効化している項目ですが、具体的に不都合があったのか、何となく避けたかといった辺り分かると、今回は対応を見送っても、今後の対応拡大に繋げやすいと思います。
下に、何項目かコメントつけましたが、無理に今回対応しなくても、後々で良いのかなと思う部分もあります。

'@Symfony' => true,
'@Symfony:risky' => true,
// '@PHP83Migration' => true,

// @Symfony のうち、以下のルールを無効化
'phpdoc_align' => false, // phpdoc の内容が削除されてしまう場合がある
'phpdoc_summary' => false, // 日本語なので不要
'phpdoc_annotation_without_dot' => false, // 日本語なので不要
'no_superfluous_phpdoc_tags' => false, // 副作用があるため
'increment_style' => false, // 強制しなくて良い
'yoda_style' => false, // 強制しなくて良い
'trailing_comma_in_multiline' => false, // `, ]` となるケースを防ぐため

// @Symfony:risky のうち、以下のルールを無効化
'psr_autoloading' => false, // PSR-4 に準拠していないため
'is_null' => false, // 副作用があるため
'native_constant_invocation' => false, // namespace を使用していないため不要
'string_length_to_empty' => false, // 副作用があるため
'ternary_to_elvis_operator' => false, // 副作用があるため
];

$finder = \PhpCsFixer\Finder::create()
->in(__DIR__.'/data/class')
->in(__DIR__.'/data/class_extends')
->in(__DIR__.'/data/module')
->in(__DIR__.'/data/smarty_extends')
->in(__DIR__.'/tests')
->name('*.php')
;
$config = new \PhpCsFixer\Config();
return $config
->setRules($rules)
->setFinder($finder)
;
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"require-dev": {
"doctrine/instantiator": "~1.5.0",
"fakerphp/faker": "^1.23",
"friendsofphp/php-cs-fixer": "^3.9",
"nanasess/ec-cube2-class-extends-stubs": "^1.0",
"nanasess/eccube2-fixture-generator": "^2.0",
"php5friends/phpunit48": ">=4.8.41",
Expand Down
Loading
Loading