11
8

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 CodeSnifferでコーディング規約を守れているかチェックしてみる。

Posted at

PHP_CodeSnifferを取ってくる。

git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs

WordPressのコーディング規約の追加

git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs

cd phpcs

./scripts/phpcs --config-set installed_paths ../wpcs

チェックできるコーディング規約の一覧を確認

$ phpcs -i
The installed coding standards are Squiz, Zend, PSR1, PSR2, PHPCS, MySource, PEAR, WordPress-Extra, WordPress-Docs, WordPress, WordPress-VIP and WordPress-Core

コーディン規約のチェック

  • ディテクトリ単位
phpcs --standard=WordPress --report=summary  htdocs/wp-content/themes/origin_theme
  • ファイル単位
phpcs --standard=WordPress htdocs/wp-content/themes/origin_theme/index.php

デフォルトのコーディング規約の変更

phpcs --config-set default_standard WordPress

参考:URL

11
8
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
11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?