Skip to content

Configuration reference

Mago's analyzer is highly configurable, allowing you to tailor the analysis to your project's specific needs. All settings go under the [analyzer] table in your mago.toml file.

toml
[analyzer]
# Disable a specific issue category
redundancy-issues = false

# Ignore a specific error code across the whole project
ignore = ["mixed-argument"]

# Use a baseline file to ignore existing issues
baseline = "analyzer-baseline.toml"

General options

OptionTypeDefaultDescription
excludesstring[][]A list of paths or glob patterns to exclude from analysis.
ignorestring[][]A list of specific issue codes to ignore globally.
baselinestringnullPath to a baseline file to ignore listed issues. When specified, the analyzer will use this file as the default baseline, eliminating the need to pass --baseline on every run. Command-line --baseline arguments will override this setting.
baseline-variantstring"loose"The baseline format variant to use when generating new baselines. Options: "loose" (count-based, resilient to line changes) or "strict" (exact line matching). See Baseline Variants for details.

Tool-Specific Excludes

The excludes option here is additive to the global source.excludes defined in the [source] section of your configuration. Files excluded globally will always be excluded from analysis, and this option allows you to exclude additional files from the analyzer specifically.

For example:

toml
[source]
excludes = ["cache/**"]  # Excluded from ALL tools

[analyzer]
excludes = ["tests/**/*.php"]  # Additionally excluded from analyzer only

Feature flags

These flags control specific, powerful analysis capabilities.

OptionDefaultDescription
find-unused-expressionstrueFind and report expressions whose results are not used (e.g., $a + $b;).
find-unused-definitionstrueFind and report unused definitions (e.g., private methods that are never called).
analyze-dead-codetrueAnalyze code that appears to be unreachable.
memoize-propertiesfalseTrack the literal values of class properties. Improves type inference but may increase memory usage.
allow-possibly-undefined-array-keystrueAllow accessing array keys that may not be defined without reporting an issue.
check-throwstrueCheck for unhandled thrown exceptions that are not caught or documented with @throws.
perform-heuristic-checkstruePerform extra heuristic checks for potential issues that are not strict typing errors.
strict-list-index-checksfalseWhen true, requires any integer used as a list index to be provably non-negative.
no-boolean-literal-comparisonfalseWhen true, disallows direct comparison to boolean literals (e.g., $a === true).
check-missing-type-hintsfalseWhen true, reports missing type hints on parameters, properties, and return types.
check-closure-missing-type-hintsfalseWhen true, checks closures for missing type hints when check-missing-type-hints is enabled.
check-arrow-function-missing-type-hintsfalseWhen true, checks arrow functions for missing type hints when check-missing-type-hints is enabled.
register-super-globalstrueAutomatically register PHP superglobals (e.g., $_GET, $_POST) for analysis.