squizlabs/PHP_CodeSniffer — pull request #59 by till (2012-09-29 16:40:25+00:00)
Title: Bugfix/allow sniffs with namespaces

This is a simple fix for the following situation:

My sniffs use 5.3 namespaces.

So when I use my coding standard, it gets registered, but PHP_CodeSniffer assumes underscores where I use a namespace.

Hence, my run fails with "Cannot redeclare class 'Vendor\Sniffs\Something\FooSniff'" later.

So the fix I introduced seems simple - without going reflection-crazy, I create a second variable which will do `Vendor\Sniffs\Something\FooSniff` along with the current default of `Vendor_Sniffs_Something_FooSniff`.

Then I test if the 5.3 variation was found (without triggering autoload) - if so, I override the name (`$className`) which is used to internally register it my Sniff.

Then all is good.