Releases: carthage-software/mago
Mago 0.0.17
Mago 0.0.17 is a minor release focusing on refining the descriptions of commands, arguments, and flags in the command-line interface (CLI). These updates enhance clarity and consistency, making the CLI more intuitive and user-friendly. While there are no functional changes, this release ensures a smoother experience for users navigating Mago's features.
Mago 0.0.16
Mago 0.0.16 introduces significant enhancements, new features, and improvements to the PHP toolchain, further refining the developer experience. Here's what's new:
🎉 New Features
Deterministic Formatter Testing
- Added deterministic testing for the formatter to ensure formatted code, when re-formatted, remains unchanged. This guarantees stable and predictable results across multiple formatting runs.
New CLI Options
mago lint --semantics-only
: Perform a quick check for semantic correctness without invoking linter rules. Ideal for rapid validation of code correctness.
New Linter Rules
analysis/inheritance
: Detects issues with class inheritance, ensuring valid and proper usage of parent classes and interfaces.analysis/instantiation
: Identifies problems in instantiation nodes, such as using new Foo when Foo does not exist, is abstract, or has a private constructor.
🛠 Improvements
Formatter Logic Overhaul
- Completely re-implemented formatting logic for assignment and binary operations, ensuring consistency and predictability. This update provides a more intuitive formatting experience for these node types.
Documentation
Launched the official documentation site: https://mago.carthage.software/.
Includes guides on installation, configuration, CLI usage, and detailed explanations of formatter and linter settings.
Miscellaneous Changes
Various small tweaks and refinements to enhance usability and performance.
Mago 0.0.15
🛠 Bug Fixes
Linter Improvements
- Property Type Hint Awareness
- Fixed an issue where the linter incorrectly flagged properties as missing type hints, even when they were inherited from a parent class. The linter now understands inheritance and won’t bug you unnecessarily!
Configuration Handling
exclude
Entry in Config- Resolved an issue where
exclude
entries in the[source]
section of the config were mishandled:- Entries with
*
are now properly treated as glob patterns. - Absolute paths are matched directly, while relative paths are joined with the root directory.
- Entries with
- Resolved an issue where
Source Loading
- Fixed a problem where files in
include
were incorrectly treated as user-defined files if theinclude
directory was inside thepaths
directory.- Example: With
paths = ["src"]
andincludes = ["src/external-library"]
,src/external-library
is now correctly recognized as external code.
- Example: With
Formatter Fixes
- Unary Operations with Parentheses
- Fixed an issue where parentheses around unary operations on the left-hand side of binary operations were removed, causing execution order changes.
- Example:
- Previously:
(@include $foo) === false
→@include $foo === false
(incorrect). - Now: Parentheses are preserved to maintain correct order.
- Previously:
🌟 Community Contributions
Special thanks to Ben Davies (@bendavies) and Giorgio Pogliani (@giorgiopogliani) for reporting these issues and testing Mago.
Your support helps us make Mago better!
Full Changelog: 0.0.14...0.0.15
Mago 0.0.14
We are thrilled to unveil Mago v0.0.14, a groundbreaking update that takes Mago to the next level! This release introduces reflections, smarter linting, and critical bug fixes.
🚀 New Features
Reflections and Built-in PHP Type Awareness
- Mago is now aware of all PHP built-in types, thanks to JetBrains/phpstorm-stubs.
- Reflections enable Mago to analyze and understand your entire codebase, including built-in PHP types, user-defined code, and dependencies.
New Analysis Linter Plugin
- Undefined Functions Rule: Detects and notifies you about calls to undefined functions.
- Undefined Constants Rule: Identifies the usage of undefined constants.
- These rules are just the beginning! Reflections pave the way for detecting runtime errors statically, with planned rules for inheritance and other advanced analysis.
Smarter Linter Suggestions
- Mago’s linter is now smarter and more context-aware:
- It will no longer suggest renaming parameters or adding types to parameters inherited from a class or interface, avoiding potential inheritance-breaking changes.
Improved Analysis with Composer
- To get the best results, include your
vendor
directory in your configuration file (excludingcomposer
files). Example:
[source]
paths = ["src"]
includes = ["vendor"]
excludes = ["*/vendor/composer/*"]
🐛 Bug Fixes
Lexer Fixes
- Recognizes callable as a keyword.
- Correctly parses heredoc when a line starts with the label text (e.g., PHPDOC in the example below).
$a = <<<PHP
PHPDOC <-- no longer mistakenly considered as the closing label
PHP;
Linter Fixes
- The implicit nullable parameter rule now fixes code correctly, preventing runtime issues.
Formatter Fixes
- Parentheses are preserved in cases like
new ($foo->bar())()
to avoid errors.
🌟 Community Contributions
A huge shoutout to @bendavies (Ben Davies) for reporting many of these issues in our Discord. Your feedback and effort make Mago better for everyone!
What's Changed
Full Changelog: 0.0.13...0.0.14
Mago 0.0.13
Enhancements
-
Internal Refactoring
- Various internal improvements to streamline performance and maintainability.
-
New Command:
mago self-update
- Easily update Mago to the latest version or check for updates without manual intervention.
Chores
-
Crates Removed
mago_cli
andmago_services
are no longer available.
-
Build Process Fixes
- Resolved build issues across multiple targets, ensuring broader compatibility.
New Feature: One-Line Installation
Quickly install or update Mago with a simple script for macOS or Linux.
Installation Command
curl --proto '=https' --tlsv1.2 -sSf https://carthage.software/mago.sh | bash
# or
wget -qO- https://carthage.software/mago.sh | bash
Full Changelog: 0.0.12...0.0.13
Mago 0.0.12
Enhancements
- Linter Rules:
-
no-unsafe-finally
- What it does: Prevents the use of
return
,throw
,break
, andcontinue
withinfinally
blocks intry
statements. - Why it matters: Ensures code predictability and avoids unintended control flow behavior when
finally
executes.
- What it does: Prevents the use of
-
no-multi-assignments
- What it does: Disallows chained assignments like
$a = $b = $c
. - Why it matters: Improves code clarity and reduces the risk of bugs caused by unintended assignments.
- What it does: Disallows chained assignments like
-
Chores
- Refactor
ast-utils
crate:- Details: Comprehensive refactor of the
ast-utils
crate. - Impact: This change introduces breaking changes (BC breaks), so ensure to review and adapt your projects accordingly when updating.
- Details: Comprehensive refactor of the
Expanded Build Target Support
We now support a broader range of targets in our build process, ensuring compatibility across diverse systems. Below is the updated list of supported targets:
Windows
- MinGW
x86_64-pc-windows-gnu
- MSVC
-i686-pc-windows-msvc
(tested)
-x86_64-pc-windows-msvc
(tested)
macOS
aarch64-apple-darwin
(tested)x86_64-apple-darwin
(tested)
FreeBSD
i686-unknown-freebsd
x86_64-unknown-freebsd
Linux
aarch64-unknown-linux-gnu
(tested)arm-unknown-linux-gnueabi
arm-unknown-linux-gnueabihf
armv7-unknown-linux-gnueabihf
arm-unknown-linux-musleabi
arm-unknown-linux-musleabihf
armv7-unknown-linux-musleabihf
i686-unknown-linux-gnu
(tested)i686-unknown-linux-musl
(tested)powerpc-unknown-linux-gnu
powerpc64-unknown-linux-gnu
powerpc64le-unknown-linux-gnu
s390x-unknown-linux-gnu
x86_64-unknown-linux-gnu
(tested)x86_64-unknown-linux-musl
(tested)
Full Changelog: 0.0.11...0.0.12
Mago 0.0.11
Fixes
- Lexer: Improved error handling for unterminated multiline comments.
- Formatter: Fixed formatting issues with literal strings.
Full Changelog: 0.0.10...0.0.11
Mago 0.0.10
Mago 0.0.10 Release Notes
Enhancements
- Reporting:
- Linter:
Fixes
- Reflector: Improved handling of constant items, especially in PHP 8.5 and above.
- Lexer: Fixed tokenization of empty multiline comments.
Chore
Full Changelog: 0.0.9...0.0.10
Mago 0.0.9
New Features
-
Linter Command:
- Introduced
--reporting-target
and--reporting-format
flags to themago lint
command, providing greater flexibility in how linting issues are reported.
--reporting-target
:Allows specifying the output target for issue reports.
- Default:
stdout
- Options:
stdout
: Outputs to standard output.stderr
: Outputs to standard error.
--reporting-format
:Allows selecting the format for issue reports.
- Default:
rich
- Options:
rich
: Detailed output for terminal display.medium
: Compact, terminal-friendly format.short
: Minimal output, useful for quick overviews.github
: Tailored for GitHub Actions annotations.json
: Structured JSON output for machine-readable reports.
- Introduced
Full Changelog: 0.0.8...0.0.9
Mago 0.0.8
Enhancements
-
Linter:
-
Introduce Laravel Plugin: Adds a new Laravel-specific plugin with an initial rule detecting
Request::all()
usage and suggestingRequest::only(...)
instead. Enable it with:[linter] plugins = ["laravel"]
Future plans include adding more Laravel-specific rules.
-
Add Combine Consecutive Issets Rule: Transforms
isset($a) && isset($b)
into the more conciseisset($a, $b)
. -
Introduce Migration Plugin: Adds two migration rules:
- Convert
strpos($a, $b) == 0
tostr_starts_with($a, $b)
- Convert
strpos($a, $b) != false
tostr_contains($a, $b)
More PHP migration rules are planned for future releases.
- Convert
-
Add Explicit Octal Notation Rule: Part of the migration plugin, converts old-style octal notation (e.g.,
012
) to the more explicit0o12
for improved readability. -
Add Readonly Class Promotion Rule: Transforms classes with only readonly properties into a readonly class, removing individual readonly modifiers for cleaner code.
-
Introduce Deprecation Plugin: Detects PHP deprecations with two initial rules:
- Convert implicitly nullable params
string $a = null
to explicitly nullable?string $a = null
(deprecated in PHP 8.4) - Identify and suggest renaming class-like nodes named
_
(deprecated in PHP 8.4)
- Convert implicitly nullable params
-
Add PHP 8.0 and 8.2 Deprecation Rules:
- Detect optional parameters before required ones (deprecated in PHP 8.0)
- Identify return by reference from void functions/methods/closures (deprecated in PHP 8.2)
Fixes
- Formatter:
- Preserve Single Inline Argument Formatting: Fixes an issue where a single argument to a function call would incorrectly break the parent nodes' formatting.
Full Changelog: 0.0.7...0.0.8