PHP_CodeSniffer: notify-send report
I use emacs as IDE, and wanted to have direct feedback about the validity of my .php files when writing them. The most easy way was to add a save hook that runs PHP_CodeSniffer - but the results should be displayed in a nice, unobtrusive way.
phpcs has multiple reporting modes - xml, checkstyle, csv etc. - but nothing for the desktop. I thought that notify-send would be the right fit since it is able to display pretty popup messages without getting in the way.
So I hacked a bit and send a pull request to Greg that got merged today. So in the next version of PHP_CodeSniffer, you will be able to enjoy it, too!
So when running$ phpcs --report=notifysend file.php
you will see something along this:
The integration into emacs is pretty simple. Just put the following into your .emacs file:(defun phpcs-notifysend() "Performs a PHP code sniffer check on the current file and shows a popup message." (interactive) (start-process-shell-command "phpcs" nil (format "phpcs --standard=TYPO3 --report=notifysend \"%s\"" (buffer-file-name))))
Using M-x phpcs-notifysend, you'll run the check immediately. Running it automatically when a file gets saved isn't hard either:(defun phpcs-notifysend-hook () (when (string-match "\.php$" buffer-file-truename) (phpcs-notifysend))) (add-hook 'after-save-hook 'phpcs-notifysend-hook)