Skip to content

Configuration Reference

While the Mago Formatter is opinionated and works great out of the box with its PSR-12 compliant defaults, you can customize its behavior in your mago.toml file.

All settings go under the [formatter] table.

toml
[formatter]
print-width = 100
use-tabs = true

Configuration Options

OptionTypeDefaultDescription
excludesstring[][]A list of glob patterns to exclude from formatting.
print-widthinteger120Maximum line length that the printer will wrap on.
tab-widthinteger4Number of spaces per indentation level.
use-tabsbooleanfalseUse tabs instead of spaces for indentation.
end-of-lineenum("auto", "lf", "crlf", "cr")"lf"The end-of-line character sequence to use.
single-quotebooleantruePrefer single quotes over double quotes for strings.
trailing-commabooleantrueAdd a trailing comma to multi-line arrays, parameter lists, etc.
remove-trailing-close-tagbooleantrueRemove the trailing PHP close tag (?>) from files.
control-brace-styleenum("same-line", "next-line")"same-line"Brace style for control structures.
closure-brace-styleenum("same-line", "next-line")"same-line"Brace style for closures.
function-brace-styleenum("same-line", "next-line")"next-line"Brace style for functions.
method-brace-styleenum("same-line", "next-line")"next-line"Brace style for methods.
classlike-brace-styleenum("same-line", "next-line")"next-line"Brace style for classes, traits, etc.
inline-empty-control-bracesbooleanfalsePlace empty control structure bodies on the same line.
inline-empty-closure-bracesbooleantruePlace empty closure bodies on the same line.
inline-empty-function-bracesbooleanfalsePlace empty function bodies on the same line.
inline-empty-method-bracesbooleanfalsePlace empty method bodies on the same line.
inline-empty-constructor-bracesbooleantruePlace empty constructor bodies on the same line.
inline-empty-classlike-bracesbooleanfalsePlace empty class-like bodies on the same line.
inline-empty-anonymous-class-bracesbooleantruePlace empty anonymous class bodies on the same line.
method-chain-breaking-styleenum("same-line", "next-line")"next-line"How to break method chains.
preserve-breaking-member-access-chainbooleanfalsePreserve existing line breaks in method chains.
preserve-breaking-argument-listbooleanfalsePreserve existing line breaks in argument lists.
preserve-breaking-array-likebooleantruePreserve existing line breaks in array-like structures.
preserve-breaking-parameter-listbooleanfalsePreserve existing line breaks in parameter lists.
preserve-breaking-attribute-listbooleanfalsePreserve existing line breaks in attribute lists.
preserve-breaking-conditional-expressionbooleanfalsePreserve existing line breaks in ternary expressions.
break-promoted-properties-listbooleantrueAlways break parameter lists with promoted properties.
line-before-binary-operatorbooleanfalsePlace the binary operator on the next line when breaking.
always-break-named-arguments-listbooleantrueAlways break named argument lists into multiple lines.
always-break-attribute-named-argument-listsbooleanfalseAlways break named argument lists in attributes.
array-table-style-alignmentbooleantrueUse table-style alignment for arrays.
sort-usesbooleantrueSort use statements alphabetically.
separate-use-typesbooleantrueInsert a blank line between different types of use statements.
expand-use-groupsbooleantrueExpand grouped use statements into individual statements.
null-type-hintenum("null-pipe", "question")"null-pipe"How to format null type hints (null|T vs ?T).
parentheses-around-new-in-member-accessbooleanfalseAdd parentheses around new in member access ((new Foo)->bar()).
parentheses-in-new-expressionbooleantrueAdd parentheses to new expressions without arguments (new Foo()).
parentheses-in-exit-and-diebooleantrueAdd parentheses to exit and die constructs.
parentheses-in-attributebooleanfalseAdd parentheses to attributes without arguments.
space-before-arrow-function-parameter-list-parenthesisbooleanfalseAdd a space before arrow function parameters.
space-before-closure-parameter-list-parenthesisbooleantrueAdd a space before closure parameters.
space-before-hook-parameter-list-parenthesisbooleanfalseAdd a space before hook parameters.
space-before-closure-use-clause-parenthesisbooleantrueAdd a space before closure use parentheses.
space-after-colon-in-enum-backing-typebooleantrueAdd a space after the colon in enum backing types.
space-after-cast-unary-prefix-operatorsbooleantrueAdd a space after cast operators like (int).
space-after-reference-unary-prefix-operatorbooleanfalseAdd a space after the reference operator (&).
space-after-error-control-unary-prefix-operatorbooleanfalseAdd a space after the error control operator (@).
space-after-logical-not-unary-prefix-operatorbooleanfalseAdd a space after the logical not operator (!).
space-after-bitwise-not-unary-prefix-operatorbooleanfalseAdd a space after the bitwise not operator (~).
space-after-increment-unary-prefix-operatorbooleanfalseAdd a space after the prefix increment operator (++).
space-after-decrement-unary-prefix-operatorbooleanfalseAdd a space after the prefix decrement operator (--).
space-after-additive-unary-prefix-operatorbooleanfalseAdd a space after unary + and -.
space-around-assignment-operatorsbooleantrueAdd spaces around assignment operators (=, +=, etc.).
space-around-logical-binary-operatorsbooleantrueAdd spaces around logical operators (&&, `
space-around-equality-binary-operatorsbooleantrueAdd spaces around equality operators (==, ===, etc.).
space-around-comparison-binary-operatorsbooleantrueAdd spaces around comparison operators (<, >, etc.).
space-around-bitwise-binary-operatorsbooleantrueAdd spaces around bitwise operators (&, `
space-around-additive-binary-operatorsbooleantrueAdd spaces around additive operators (+, -).
space-around-multiplicative-binary-operatorsbooleantrueAdd spaces around multiplicative operators (*, /, %).
space-around-exponentiation-binary-operatorsbooleantrueAdd spaces around the exponentiation operator (**).
space-around-shift-binary-operatorsbooleantrueAdd spaces around shift operators (<<, >>).
space-around-concatenation-binary-operatorbooleantrueAdd spaces around the concatenation operator (.).
space-around-null-coalescing-binary-operatorbooleantrueAdd spaces around the null coalescing operator (??).
space-around-elvis-binary-operatorbooleantrueAdd spaces around the elvis operator (?:).
space-around-assignment-in-declarebooleanfalseAdd spaces around = in declare statements.
space-within-grouping-parenthesisbooleanfalseAdd spaces inside grouping parentheses ( 1 + 2 ).
empty-line-after-control-structurebooleanfalseAdd an empty line after control structures.
empty-line-after-opening-tagbooleantrueAdd an empty line after the opening <?php tag.
empty-line-after-declarebooleantrueAdd an empty line after a declare statement.
empty-line-after-namespacebooleantrueAdd an empty line after a namespace declaration.
empty-line-after-usebooleantrueAdd an empty line after use statement blocks.
empty-line-after-symbolsbooleantrueAdd an empty line after top-level symbols (class, function, etc.).
empty-line-after-class-like-constantbooleanfalseAdd an empty line after a class constant.
empty-line-after-enum-casebooleanfalseAdd an empty line after an enum case.
empty-line-after-trait-usebooleanfalseAdd an empty line after a use statement inside a trait.
empty-line-after-propertybooleanfalseAdd an empty line after a property.
empty-line-after-methodbooleantrueAdd an empty line after a method.
empty-line-before-returnbooleanfalseAdd an empty line before a return statement.
empty-line-before-dangling-commentsbooleantrueAdd an empty line before dangling comments.
separate-class-like-membersbooleantrueSeparate different kinds of class members with a blank line.