Mago reimagines PHP development tooling by combining three traditionally separate tools into a single Rust-powered binary. The formatter takes a parse-and-reprint approach inspired by Prettier and rustfmt, parsing PHP code into an AST, discarding original formatting entirely, and reprinting according to PER-CS compliant rules. This guarantees 100 percent consistent output regardless of input style, ending code formatting debates across teams with a single command that never alters runtime behavior.
The linter operates at the structural level with over 100 rules for identifying code smells, redundant patterns, and outdated syntax. It sits between the parser and the analyzer in the processing pipeline, catching issues that relate to how code is written rather than what it does. The semantic checker validates PHP version compatibility and catches syntax that the tolerant parser accepts but the PHP runtime would reject, making it a faster and more capable replacement for php -l validation in CI pipelines.
The static analyzer goes deeper by building a semantic understanding of the entire codebase with type inference, property initialization checking, and exception flow analysis. It identifies logical impossibilities like calling methods that do not exist on inferred types, accessing properties before initialization, and unchecked exception propagation. An architectural guard component validates module boundaries and coding standards at the project structure level, preventing dependency violations that accumulate over time in large PHP codebases.