LoginSignup
1
0

More than 1 year has passed since last update.

新規または変更したファイルのみphpStanを実行する

Last updated at Posted at 2022-01-22

使いそうなシチュエーション

・静的解析したいファイルが多すぎるとき
・将来phpStanを導入したいと考えているとき
・新規作成ファイルなど部分的にphpstanのレベルを上げたいとき
・CIでphpstanを実行したいとき(レポジトリ全体にstanを実行すると滅茶苦茶重たい)

コマンド

# git diffした内容をphpstanで実行する
git diff master --name-only | grep '.php' | xargs vendor/bin/phpstan analyse -l max

# diff-filterオプションで新規作成ファイルのみに絞り込みして実行できる
git diff master --diff-filter=A --name-only | grep '.php' | xargs vendor/bin/phpstan analyse -l max

エイリアスを通しとくと便利そう

# ~/.bashrc または ~/.zshrc
alias stan-diff="git diff master --name-only | grep '.php' | xargs vendor/bin/phpstan analyse -l max"
alias stan-diff-add="git diff master --diff-filter=A --name-only | grep '.php' | xargs vendor/bin/phpstan analyse -l max"
1
0
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
1
0