3 Layers of Static Code Analysis in PHP
Every developer should be running some form of static code analysis on their code regularly. A recent article I read about how this is done at Etsy makes for what I believe should be a minimum standard of code analysis for any team of developers work on a shared codebase. We shall assume you are committing your codebase to some form of version control on a regular basis. The 3 layers can be summarised as: Sanity Checks Formal Checks Security Checks Sanity and Syntax Checks In Stage 1 we perform basically a sanity check of the code. Are there any errors, missing semi-colon's or just plain stupid things being committed to our repository and code base. This is essentially a case of running php -l against all our files being checked in or changed to make sure we catch these before they are committed and let you fix them before they are picked up by the wider team. Formal Checks This stage involves a more global analysis of the source code files, checking for thin