carthage-software/mago
Mago is an extremely fast PHP linter, formatter, and static analyzer written in Rust. It brings Rust-inspired speed and reliability to PHP projects with a modern toolchain and great developer experience, plus multiple install options (script, Homebrew, Composer).
The mago ast command is a powerful inspection tool that tokenizes and parses a single PHP file, giving you insight into its lexical and syntactical structure.
:::tip
For global options that can be used with any command, see the Command-Line Interface overview. Remember to specify global options before the ast command.
:::
Usage: mago ast [OPTIONS] <FILE>
<FILE>Required. The path to the single PHP file you want to inspect.
--tokensDisplay the stream of raw tokens generated by the lexer instead of the parsed AST. This is useful for debugging low-level syntax issues. This can be combined with --json for machine-readable output.
--jsonDisplay the output (either the AST or the token stream) in a machine-readable, pretty-printed JSON format. This is ideal for integration with other tools and scripts.
--namesAfter parsing the AST, this flag runs the name resolver and prints a list of all symbols (classes, functions, etc.) and their fully qualified names. This is useful for debugging namespace and import resolution.
The ast command uses a shared set of options for reporting parsing errors.
See the Shared Reporting and Fixing Options documentation.
:::tip
The ast command only reports parsing errors. Auto-fixing and baseline features are not applicable to this command.
:::
| Flag, Alias(es) | Description |
|---|---|
--help, -h |
Print the help summary for the command. |
How can I help you explore Laravel packages today?