PHP cs fixer for vim

install

1
2
3
4
5
sudo apt install php-codesniffer

git clone https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git /opt/WordPress-Coding-Standards

sudo phpcs --config-set installed_paths /opt/WordPress-Coding-Standards
1
2
~$ phpcs -i
The installed coding standards are PEAR, PSR2, Squiz, Zend, PSR1, MySource, WordPress-Core, WordPress, WordPress-Docs, WordPress-VIP and WordPress-Extra

Install bundle for vim

  • ~/.vimrc
1
2
3
4
Bundle 'joonty/vim-phpqa.git'
let g:phpqa_codesniffer_args = "--standard=WordPress"
let g:phpqa_messdetector_autorun = 0
let g:phpqa_codesniffer_autorun = 0

Run

1
phpcs --standard=WordPress ./wp-includes/wp-db.php
1
watch 'phpcs --standard=WordPress ./wp-includes/wp-db.php'