New Features 🆕
- Fine-grained parentheses control: You can now fine-tune how Mago handles parentheses in your code with three new options:
parentheses_around_new_in_member_access
: Decide whether to include parentheses around instantiation expressions followed by a member access operator (->
). This option is disabled by default, aligning with the streamlined style introduced in PHP 8.4. (#89)parentheses_in_new_expression
: Control whether to include parentheses innew
expressions, even when no arguments are provided. Enabled by default for explicitness. (#89)parentheses_in_exit_and_die
: Choose whether to include parentheses inexit
anddie
constructs, making them resemble function calls. Enabled by default for consistency. (#89)
- Space control in enums: The
space_before_enum_backing_type_hint_colon
option lets you control whether a space is added before the colon in enum backing type hints (e.g.,enum Foo: int
). (#88) - Trailing close tag removal: The
remove_trailing_close_tag
option allows you to control whether the trailing?>
tag is removed from PHP files. (#87)
Formatting Enhancements 🪄
- Improved consistency: We've tackled inconsistencies in formatting various code constructs, including comments, arrays, assignments, binary expressions, and more! (#85)
- Better wrapping: Mago now handles edge cases in wrapping more effectively, ensuring consistent and predictable output. (#85)
- Enhanced width calculation: We've refined the width calculation logic to accurately measure the width of strings, leading to more precise formatting. (#85)
- Use statement organization: Gain more control over use statement formatting with options to sort, expand, and separate them. (#83)
Bug Fixes 🐛
- PHP in HTML alignment: Fixed an issue where indented PHP code within HTML was not aligned correctly. (#85)
- Trailing newline removal: Resolved inconsistent removal of trailing newlines when removing the closing tag. (#87)
Breaking Changes ⚠️
- PHP version requirement: The
format()
function now requires aPHPVersion
argument. This change is necessary to support theparentheses_around_new_in_member_access
option, which has version-specific behavior. (#89)
We hope you enjoy these improvements to the Mago formatter! 🎉
Full Changelog: 0.11.1...0.12.0