Skip to content

Releases: carthage-software/mago

0.9.1

08 Feb 17:41
7e78c07
Compare
Choose a tag to compare
fix(linter): remove broken example

Signed-off-by: azjezz <[email protected]>

Mago 0.9.0

06 Feb 17:26
e901ff1
Compare
Choose a tag to compare

Mago 0.9.0 introduces deeper undefined reference checks, a brand-new mago find command for locating symbol references, and a new rule to catch unnecessary hash comments (#️⃣).


🔥 Major Changes

1️⃣ Expanded Undefined Member Checks & Improved Severity Handling

Mago now detects more cases of undefined methods, functions, constants, and enum cases, preventing runtime errors before they happen.

New Checks Added:

✅ Calling an undefined, non-static, or abstract static method is now flagged
✅ Creating a closure for an undefined function is now reported
Class-like constants & enum cases that are undefined are now detected
Static method calls on traits (deprecated in PHP 8.2+) now trigger warnings
Fix: Severity levels now correctly respect user configurations

🔎 Why This Matters: These changes ensure Mago catches more real-world issues in PHP codebases, helping developers avoid hard-to-debug runtime errors.


2️⃣ New CLI Command: mago find 🔍

A powerful new command has landed! mago find [query] lets you search for symbol references (e.g., functions, classes, traits, enum cases, and more) across your PHP project instantly.

How It Works

  • Find where a symbol is used: mago find SomeClass
  • Search for function references: mago find some_function
  • Locate all trait usages: mago find SomeTrait
  • Works in user-defined & external sources

🎯 Built for speed & accuracy, this feature is ideal for navigating large codebases, understanding dependencies, and future LSP integrations.

📸 Example screenshots:

Screenshot 2025-02-05 at 13 33 10 Screenshot 2025-02-05 at 13 34 36

3️⃣ Overhauled Linter Rule System & Micro-Optimizations

Big internal refactoring:

✅ Improved performance in various crates
✅ The linter rule system is now more efficient & extendable
✅ These changes pave the way for future improvements


Pull Requests

  • refactor: overhaul linter rule system and micro-optimize crates by @azjezz in #66
  • feat(lexer/linter): add support for #️⃣ hash emoji & corresponding linter rule by @azjezz in #67
  • revert: remove emoji support in lexer and update NoHashEmojiRule by @azjezz in #68
  • feat(linter): expand checks for undefined members & fix level handling by @azjezz in #70
  • feat: introduce reference crate, and find cli command by @azjezz in #69

Full Changelog: 0.8.1...0.9.0

Mago 0.8.1

01 Feb 20:09
d3d0c79
Compare
Choose a tag to compare

🐞 Bug Fixes

Type Hint Compatibility

  • Fixed incorrect version checks for null and false type hints:
    • Previously: Reported as PHP 8.2+ features
    • Now: Correctly allows null and false in union types for PHP 8.0+

Thanks to @Nadyita for reporting #65

✨ New Features

GitLab Issue Reporting

  • Added support for GitLab-compatible issue reporting:
    mago lint --reporting-format=gitlab  

Thanks to @vvvinceocam for the contribution #62


Thank you for your feedback and contributions! 🚀


Full Changelog: 0.8.0...0.8.1

Mago 0.8.0

01 Feb 13:26
d1851d8
Compare
Choose a tag to compare

🚨 Breaking Changes

Removed compatibility Plugin

  • The compatibility plugin has been removed as its functionality is now integrated into the core semantics analyzer.

Strict PHP Version Checks

  • New: The semantics analyzer now enforces strict PHP version compatibility.
    • Detects usage of PHP features not available in the configured version
    • Always results in an error (cannot be disabled or downgraded)
    • Covers more features than the old plugin, ensuring stricter compliance

✨ New Features

PHP 8.5 Support

  • Added support for new PHP 8.5 features:
    • Closures in constant expressions
    • Attributes on constants ( #64 )

Thank you for using Mago! 🚀


Full Changelog: 0.7.0...0.8.0

Mago 0.7.0

31 Jan 02:18
893e634
Compare
Choose a tag to compare

🎯 Focused Update: WASM Overhaul

This release delivers a complete rewrite of the mago_wasm crate to empower web-based PHP tooling:

Key Improvements

  • Linter Integration: Full support for running Mago's PHP linting rules in WASM environments
  • Developer Experience: Simplified API surface with intuitive entry points and error handling
  • Documentation: Revamped Rust docs with usage examples and type-safe interfaces

Note: This is a breaking change for WASM consumers – see docs for migration guidance.

Mago 0.6.2

29 Jan 23:42
9b59274
Compare
Choose a tag to compare

Bug Fixes

  • Fixed Non-Zero Exit Code for Warnings/Notes:
    In version 0.6.1, we fixed the exit code behavior to ensure mago lint exits with a non-zero code when errors are present. However, this inadvertently caused the command to exit with a non-zero code even when only warnings, notes, or help messages were present. This has now been fixed.
    Fix: Replaced the logic level <= Level::Error with the cleaner has_minimum_level(Level::Error) method, which correctly checks if any issues meet or exceed the error level.
    Impact: The CLI now correctly exits with a non-zero code only when errors are present, allowing warnings, notes, and help messages to pass without failing the linting process.

How to Upgrade

  • If you installed Mago using the pre-built binary, the install script, or Homebrew, run:
    mago self-update
  • If you are using Composer, run:
    composer require carthage-software/mago:^0.6.1 --dev
  • If you are using Cargo, run:
    cargo install [email protected]

Why This Matters

This fix is critical for users relying on mago lint in automated workflows, such as CI/CD pipelines, where a non-zero exit code is expected when linting errors are found. Without this fix, pipelines could incorrectly proceed despite linting failures, potentially allowing insecure or problematic code to be deployed.

Thank You

We appreciate the community’s support in making Mago better. If you encounter any issues or have suggestions, please open an issue on GitHub.

Happy linting! 🚀

Mago 0.6.1

29 Jan 22:48
87fbf7b
Compare
Choose a tag to compare

Bug Fixes

  • Fixed Exit Code Behavior:
    The mago lint command now correctly exits with a non-zero status code when linting errors are detected. Previously, it would exit with a zero status code even when errors were present, which could mislead CI/CD pipelines or scripts into thinking the linting passed successfully.
    Impact: This ensures proper integration with automated workflows and prevents false positives in CI/CD pipelines.
    Thanks: A big thank you to @thyseus for reporting this issue in #61.

Tests

  • Regression Tests Added:
    Tests have been added to the mago_reporting crate to ensure the get_highest_level method in IssueCollection correctly identifies the highest severity level. The issue stemmed from the reversed order of the Level enum fields, which has now been fixed. These tests prevent future regressions.

How to Upgrade

  • If you installed Mago using the pre-built binary, the install script, or Homebrew, run:
    mago self-update
  • If you are using Composer, run:
    composer require carthage-software/mago:^0.6.1 --dev
  • If you are using Cargo, run:
    cargo install [email protected]

Why This Matters

This fix is critical for users relying on mago lint in automated workflows, such as CI/CD pipelines, where a non-zero exit code is expected when linting errors are found. Without this fix, pipelines could incorrectly proceed despite linting failures, potentially allowing insecure or problematic code to be deployed.

Thank You

We appreciate the community’s support in making Mago better. If you encounter any issues or have suggestions, please open an issue on GitHub.

Happy linting! 🚀


Full Changelog: 0.6.0...0.6.1

Mago 0.6.0

29 Jan 05:27
b8b736f
Compare
Choose a tag to compare

Mago 0.6.0 introduces new compatibility rules, enhanced CLI flexibility, a new security plugin, and expanded functionality for the fix command.


🛠 New Compatibility Rules for PHP 8.2, 8.3, and 8.4

We've added new compatibility rules to detect and warn about features introduced in PHP 8.2, 8.3, and 8.4, helping you ensure your code runs on the intended PHP version.

PHP 8.2 Compatibility Rules:

  • compatibility/dnf-type-hint-feature – Detects usage of Disjunctive Normal Form (DNF) type hints.
  • compatibility/readonly-class-feature – Warns when using readonly classes before PHP 8.2.
  • compatibility/trait-constants-feature – Detects constants inside traits, which are only available in PHP 8.2.
  • compatibility/true-type-hint-feature – Ensures true as a type hint is used only in PHP 8.2+.

PHP 8.3 Compatibility Rules:

  • compatibility/typed-class-constant-feature – Detects usage of typed class constants, available in PHP 8.3.

PHP 8.4 Compatibility Rules:

  • compatibility/hooked-property-feature – Ensures hooked properties are only used in PHP 8.4+.
  • compatibility/new-without-parentheses-feature – Detects new expressions without parentheses, available from PHP 8.4.

👉 View details for each rule using:

mago lint --explain compatibility/readonly-class-feature

(Replace readonly-class-feature with any other rule name to learn more.)


🎛️ New CLI Options: --no-default-plugins & --plugins

We've improved the lint and fix commands with new flags to fine-tune which plugins are enabled.

  • --no-default-plugins (-n): Disables default plugins, overriding linter.default_plugins in your config.
  • --plugins (-p): Enables one or more specific plugins, overriding linter.plugins.

👉 Examples:

  • Run the linter with only the compatibility plugin:
    mago lint -n -p compatibility
  • List all rules from a specific plugin:
    mago lint -n -p compatibility --list-rules

🔐 New Security Plugin

Mago now includes a security plugin, which detects potential security vulnerabilities in your PHP code.

  • View all security rules:
    mago lint -n -p security --list-rules
    
  • Get details about a specific security rule:
    mago lint --explain security/<rule-name>
    

mago fix Now Accepts Paths

The mago fix command has been expanded to allow specifying paths, so you can apply fixes to a specific file or directory without affecting the entire project.

👉 Examples:

  • Fix issues in a single file:
    mago fix path/to/file.php
  • Fix only issues from the migration plugin in a specific directory:
    mago fix path/to/dir -n -p migration

🔥 Summary

Mago 0.6.0 gives you more control over linting and fixing, improves PHP compatibility checks, and introduces security rules to help safeguard your codebase.

Upgrade today and enjoy more power and flexibility in your PHP workflow! 🚀


Full Changelog: 0.5.1...0.6.0

Mago 0.5.1

28 Jan 01:43
f487ca9
Compare
Choose a tag to compare

We sincerely apologize for the issues encountered in v0.5.0. This hotfix addresses critical regressions:

Bug Fixes:

  • 🛠️ Configuration Loader: Fixed error when MAGO_LOG environment variable is unspecified
  • 📂 Source Loader: No longer attempts to load directories as files.

Mago 0.5.0

27 Jan 22:42
89c29c6
Compare
Choose a tag to compare

🚀 New Features

Enhanced Linting Targets

Run linting on specific files/directories or file descriptors:

# Lint single file
mago lint example.php

# Lint multiple files/directories
mago lint src/ tests/ example.php

# Lint via process substitution (Unix-like systems)
mago lint <(echo '<?php while(true) { break; }')

Type Checking Flexibility

Added ignore_closure_types option to skip parameter/return type checks for:

  • Arrow functions
  • Closures

For more information, use mago lint --explain strictness/require-parameter-type and mago lint --explain strictness/require-return-type

🐞 Bug Fixes

Critical Rule Fixes:

  • Fixed best-practices/loop-does-not-iterate to detect loops with unconditional continue (Resolves #55)
  • Fixed filtering behavior when using MAGO_LOG environment variable

Compatibility Improvements:

  • Made Composer plugin fully compatible with PHP 8.1 environments

🔧 Improvements

Diagnostics & Logging:

  • Revamped logging messages for clearer debugging sessions

⚙️ Internal Changes

  • Updated default Composer configuration templates
  • Optimized rule initialization sequence

What's Changed

  • Make composer plugin compatible with PHP 8.1 by @veewee in #56

Full Changelog: 0.4.1...0.5.0