If you want to statically analyze the source code you surely need to first parse it and obtain a form of Abstract Syntax Tree (AST). PHP-Parser lets you do that!
You just need to pass the parser the code, then it will return a code representation that you can use to implement several types of analysis.
We’re relying on it to create an in-memory model of an entire source base using Redis to do, afterwards, some type inference analysis. It works pretty well!