You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pure PHP implementation of a control flow graph (CFG) with instructions in static single assignment (SSA) form.
The used SSA construction algorithm is based on "Simple and Efficient Construction of Static Single Assignment Form" by
Braun et al. This algorithm constructs SSA form directly from the abstract syntax tree, without going through a non-SSA
IR first. If you're looking for dominance frontiers, you won't find them here...
The constructed SSA form is minimal and pure (or is supposed to be).
Usage
To bootstrap the parser, you need to give it a PhpParser instance:
While not strictly necessary, you likely should also run the Simplifier Visitor via the Traverser to optimize the CFG (remove redundant jumps and blocks, simplify Phi nodes as much as possible, etc). Other visitors exist to help find function and class declarations (PHPCfg\Visitor\DeclarationFinder), find function and method calls (PHPCfg\Visitor\CallFinder), and find all variables (PHPCfg\Visitor\VariableFinder).
You can also implement your own custom PHPCfg\Visitor and add it to the traverser in order to apply analysis or transforms to the CFG to achieve different results.