Skip to content

MIR1708

ImpureStaticPropertyAccess

An impure function reads a static property, making it dependent on external state that can change unexpectedly.

<?php
class Config {
public static $debug = false;
}
function isDevelopment(): bool {
return Config::$debug; // Depends on external static state
}

Pass dependencies explicitly or use dependency injection:

<?php
class Config {
private bool $debug;
public function __construct(bool $debug) {
$this->debug = $debug;
}
public function isDevelopment(): bool {
return $this->debug;
}
}