#linter #ast #spans #mago #php #coding-style #php-toolchain #warnings #diagnostics

mago-span

Tracks exact character positions in source code, making it easier to report precise errors, warnings, and other diagnostics

140 releases (13 stable)

Uses new Rust 2024

new 1.6.0 Feb 7, 2026
1.3.0 Jan 29, 2026
1.0.3 Dec 24, 2025
1.0.0-rc.6 Nov 26, 2025
0.0.18 Dec 29, 2024

#2 in #spans

Download history 599/week @ 2025-10-17 58/week @ 2025-10-24 38/week @ 2025-10-31 57/week @ 2025-11-07 49/week @ 2025-11-14 87/week @ 2025-11-21 77/week @ 2025-11-28 53/week @ 2025-12-05 25/week @ 2025-12-12 253/week @ 2025-12-19 78/week @ 2025-12-26 207/week @ 2026-01-02 770/week @ 2026-01-09 340/week @ 2026-01-16 249/week @ 2026-01-23 509/week @ 2026-01-30

1,946 downloads per month
Used in 34 crates (27 directly)

MIT/Apache

88KB
1.5K SLoC

Provides fundamental types for source code location tracking.

This crate defines the core primitives Position and Span used throughout mago to identify specific locations in source files. It also provides the generic traits HasPosition and HasSpan to abstract over any syntax tree node or token that has a location.


Mago Banner

An extremely fast PHP linter, formatter, and static analyzer, written in Rust.

CI Status CD Status CodeQL Crates.io Latest Stable Version for PHP Total Composer Downloads License

Mago is a comprehensive toolchain for PHP that helps developers write better code. Inspired by the Rust ecosystem, Mago brings speed, reliability, and an exceptional developer experience to PHP projects of all sizes.

Table of Contents

Installation

The most common way to install Mago on macOS and Linux is by using our shell script:

curl --proto '=https' --tlsv1.2 -sSf https://carthage.software/mago.sh | bash

To install a specific version:

curl --proto '=https' --tlsv1.2 -sSf https://carthage.software/mago.sh | bash -s -- --version=1.6.0

For all other installation methods, including Homebrew, Composer, and Cargo, please refer to our official Installation Guide.

Getting Started

To get started with Mago and learn how to configure your project, please visit our Getting Started Guide in the official documentation.

Features

  • ⚡️ Extremely Fast: Built in Rust for maximum performance.
  • 🔍 Lint: Identify issues in your codebase with customizable rules.
  • 🔬 Static Analysis: Perform deep analysis of your codebase to catch potential type errors and bugs.
  • 🛠️ Automated Fixes: Apply fixes for many lint issues automatically.
  • 📜 Formatting: Automatically format your code to adhere to best practices and style guides.
  • 🧠 Semantic Checks: Ensure code correctness with robust semantic analysis.
  • 🌳 AST Visualization: Explore your code’s structure with Abstract Syntax Tree (AST) parsing.

Our Sponsors

JetBrainsBoudewijn Vahrmeijer

Jason R. McNeilVincent Berset

Bohuslav ŠimekTicketSwap

See all sponsors

Contributing

Mago is a community-driven project, and we welcome contributions! Whether you're reporting bugs, suggesting features, writing documentation, or submitting code, your help is valued.

Inspiration & Acknowledgements

Mago stands on the shoulders of giants. Our design and functionality are heavily inspired by pioneering tools in both the Rust and PHP ecosystems.

Inspirations:

  • Clippy: For its comprehensive linting approach.
  • OXC: A major inspiration for building a high-performance toolchain in Rust.
  • Hakana: For its deep static analysis capabilities.

Acknowledgements:

We deeply respect the foundational work of tools like PHP-CS-Fixer, Psalm, PHPStan, and PHP_CodeSniffer. While Mago aims to offer a unified and faster alternative, these tools paved the way for modern PHP development.

License

Mago is dual-licensed under your choice of the following:

Dependencies

~10–23MB
~211K SLoC