fabpot/PHP-CS-Fixer — pull request #336 by jaydiablo (2014-04-11 20:24:37+00:00)
Title: Ignoring some special cases of functions getting visibility added

This is similar to #332, but this one includes a fix. When running php-cs-fixer against more procedural style code (no oop) this visibility fixer would add "public" visibility keyword to the front of the function declarations, causing fatal syntax errors. I added the test cases from #332, and added some more that I discovered it was processing (that it shouldn't be).

To pass these tests, I've modified the fixer to look for the OOP trigger words in what would be considered PHP code, rather than just the entire source content (ignores comments, doc blocks, strings and inline html). I didn't see any easy way to do this with the regex used, but by using PHP's tokenizer I was able to strip these tokens from the content before the regex is run.

I had to add