Display style warnings appropriately

The logic is rather WET, but that can be fixed.
Test that pre-existing style errors are ignored
Add header comment to pre-commit.php

It's useful sometimes to explain things.
Refactor commit file listing into a function
Only process files with the .php extension

CodeSniffer already ignores most files by default, but we can save a
little processing by only trying to process .php files.
Refactor body of main loop into a function

The function is still ugly, but this is an improvement.
Use a better way to get filename extension
Extract logic to get staged line numbers to a function

It's not a particularly reusable function, but it at least makes the
function it belongs to a bit shorter and more readable.
Simpler workaround for CodeSniffer's cwd stomping

Why CodeSniffer changes the working directory is beyond me.

This is a simpler, prettier way of surviving it, though.
Improve comment's usefulness