pub struct Settings {Show 31 fields
pub version: PHPVersion,
pub find_unused_expressions: bool,
pub find_unused_definitions: bool,
pub analyze_dead_code: bool,
pub memoize_properties: bool,
pub allow_possibly_undefined_array_keys: bool,
pub check_throws: bool,
pub unchecked_exceptions: AtomSet,
pub unchecked_exception_classes: AtomSet,
pub check_missing_override: bool,
pub find_unused_parameters: bool,
pub strict_list_index_checks: bool,
pub no_boolean_literal_comparison: bool,
pub check_missing_type_hints: bool,
pub check_closure_missing_type_hints: bool,
pub check_arrow_function_missing_type_hints: bool,
pub register_super_globals: bool,
pub use_colors: bool,
pub diff: bool,
pub trust_existence_checks: bool,
pub class_initializers: AtomSet,
pub check_property_initialization: bool,
pub check_use_statements: bool,
pub saturation_complexity_threshold: u16,
pub disjunction_complexity_threshold: u16,
pub negation_complexity_threshold: u16,
pub consensus_limit_threshold: u16,
pub formula_size_threshold: u16,
pub string_combination_threshold: u16,
pub integer_combination_threshold: u16,
pub array_combination_threshold: u16,
}Expand description
Configuration settings that control the behavior of the Mago analyzer.
This struct allows you to enable/disable specific checks, suppress categories of issues, and tune the analyzer’s performance and strictness.
Fields§
§version: PHPVersionThe target PHP version for the analysis.
find_unused_expressions: boolFind and report expressions whose results are not used (e.g., $a + $b;). Defaults to false.
find_unused_definitions: boolFind and report unused definitions (e.g., private methods that are never called). Defaults to false.
analyze_dead_code: boolAnalyze code that appears to be unreachable. Defaults to false.
memoize_properties: boolTrack the literal values of class properties when they are assigned.
This improves type inference but may increase memory usage. Defaults to true.
allow_possibly_undefined_array_keys: boolAllow accessing array keys that may not be defined without reporting an issue. Defaults to true.
check_throws: boolEnable checking for unhandled thrown exceptions.
When true, the analyzer will report any exception that is thrown but not caught
in a try-catch block or documented in a @throws tag.
This check is disabled by default (false) as it can be computationally expensive.
unchecked_exceptions: AtomSetExceptions to ignore including all subclasses (hierarchy-aware).
When an exception class is in this set, any exception of that class or any of its
subclasses will be ignored during check_throws analysis.
For example, adding LogicException will ignore LogicException, InvalidArgumentException,
OutOfBoundsException, and all other subclasses.
unchecked_exception_classes: AtomSetExceptions to ignore (exact class match only, not subclasses).
When an exception class is in this set, only that exact class will be ignored
during check_throws analysis. Parent classes and subclasses are not affected.
check_missing_override: boolCheck for missing #[Override] attributes on overriding methods.
When enabled, the analyzer reports methods that override a parent method without
the #[Override] attribute (PHP 8.3+).
Defaults to true.
find_unused_parameters: boolFind and report unused function/method parameters.
When enabled, the analyzer reports parameters that are declared but never used within the function body.
Defaults to true.
strict_list_index_checks: boolEnforce strict checks when accessing list elements by index.
When true, the analyzer requires that any integer used to access a list
element is provably non-negative (e.g., of type int<0, max>). This helps
prevent potential runtime errors from using a negative index.
When false (the default), any int is permitted as an index, offering
more flexibility at the cost of type safety.
no_boolean_literal_comparison: boolDisable comparisons to boolean literals (true/false).
When enabled, comparisons to boolean literals will not be reported as issues.
Defaults to false.
check_missing_type_hints: boolCheck for missing type hints on parameters, properties, and return types.
When enabled, the analyzer will report warnings for function parameters, class properties, and function return types that lack explicit type declarations. The analyzer uses its type system knowledge to avoid false positives - for instance, it won’t require a type hint on a property if adding one would conflict with a parent class or trait that has no type hint.
Defaults to false.
check_closure_missing_type_hints: boolCheck for missing type hints (both parameters and return types) in closures when check_missing_type_hints is enabled.
When true, closures (anonymous functions declared with function() {}) will be
checked for missing type hints. When false, closures are ignored, which is useful
because closures often rely on type inference.
Defaults to false.
check_arrow_function_missing_type_hints: boolCheck for missing type hints (both parameters and return types) in arrow functions when check_missing_type_hints is enabled.
When true, arrow functions (declared with fn() => ...) will be checked for missing
type hints. When false, arrow functions are ignored, which is useful because arrow
functions often rely on type inference and are typically short, making types obvious.
Defaults to false.
register_super_globals: boolRegister superglobals (e.g., $_GET, $_POST, $_SERVER) in the analysis context.
If disabled, super globals won’t be available unless explicitly imported using
the global keyword.
Defaults to true.
use_colors: boolEnable colored output in terminal environments that support it. Defaults to true.
This setting is primarily used for enabling/disabling colored diffs in issue reports.
diff: boolInternal use only.
Enables a diffing mode for incremental analysis, used by integrations like LSPs.
This avoids re-analyzing unchanged code in the same session. Defaults to false.
trust_existence_checks: boolTrust symbol existence checks to narrow types.
When enabled, conditional checks like method_exists(), property_exists(),
function_exists(), and defined() will narrow the type within the conditional block,
suppressing errors for symbols that are verified to exist at runtime.
When disabled, these checks are ignored and the analyzer requires explicit type hints, which is stricter but may produce more false positives for dynamic code.
Defaults to true.
class_initializers: AtomSetMethod names treated as class initializers (like __construct).
Properties initialized in these methods count as “definitely initialized”
just like in the constructor. This is useful for frameworks that use
lifecycle methods like PHPUnit’s setUp() or framework boot() methods.
Example: ["setUp", "initialize", "boot"]
Defaults to empty (no additional initializers).
check_property_initialization: boolEnable property initialization checking (missing-constructor, uninitialized-property).
When false, disables both missing-constructor and uninitialized-property issues
entirely. This is useful for projects that prefer to rely on runtime errors for
property initialization.
Defaults to false.
check_use_statements: boolCheck for non-existent symbols in use statements.
When enabled, the analyzer will report use statements that import symbols (classes, interfaces, traits, enums, functions, or constants) that do not exist in the codebase.
Defaults to false.
saturation_complexity_threshold: u16Maximum number of clauses to process during CNF saturation.
Controls how many clauses the simplification algorithm will work with. If exceeded, saturation returns an empty result to avoid performance issues.
Defaults to 8192.
disjunction_complexity_threshold: u16Maximum number of clauses per side in disjunction operations.
Controls the complexity limit for OR operations between clause sets. If either side exceeds this, the disjunction returns an empty result.
Defaults to 4096.
negation_complexity_threshold: u16Maximum cumulative complexity during formula negation.
Controls how complex the negation of a formula can become. If exceeded, negation gives up to avoid exponential blowup.
Defaults to 4096.
consensus_limit_threshold: u16Upper limit for consensus optimization during saturation.
Controls when the consensus rule is applied during saturation. Only applies when clause count is between 3 and this limit.
Defaults to 256.
formula_size_threshold: u16Maximum logical formula size during conditional analysis.
Limits the size of generated formulas to prevent exponential blowup in deeply nested conditionals.
Defaults to 512.
string_combination_threshold: u16Maximum number of literal strings to track before generalizing.
When combining types with many different literal string values, tracking each literal individually causes O(n) memory and O(n²) comparison time. Once the threshold is exceeded, we generalize to the base string type.
Defaults to 128.
integer_combination_threshold: u16Maximum number of literal integers to track before generalizing.
When combining types with many different literal integer values, tracking each literal individually causes O(n) memory and O(n²) comparison time. Once the threshold is exceeded, we generalize to the base int type.
Defaults to 128.
array_combination_threshold: u16Maximum number of array elements to track individually.
When building array types through repeated push operations ($arr[] = ...),
this limits how many individual elements are tracked before generalizing
to a simpler array type. This prevents memory explosion on files with
thousands of array pushes.
Defaults to 128.
Implementations§
Source§impl Settings
impl Settings
pub fn new(version: PHPVersion) -> Self
Sourcepub fn algebra_thresholds(&self) -> AlgebraThresholds
pub fn algebra_thresholds(&self) -> AlgebraThresholds
Returns the algebra thresholds derived from the settings.
Sourcepub fn combiner_options(&self) -> CombinerOptions
pub fn combiner_options(&self) -> CombinerOptions
Returns the combiner options derived from the settings.
Trait Implementations§
impl Eq for Settings
impl StructuralPartialEq for Settings
Auto Trait Implementations§
impl Freeze for Settings
impl RefUnwindSafe for Settings
impl Send for Settings
impl Sync for Settings
impl Unpin for Settings
impl UnwindSafe for Settings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);