MIR1706
ImpureStaticPropertyAssignment
An impure function assigns to a static property, which introduces side effects that can make code harder to reason about and test.
Example
Section titled “Example”<?phpclass Counter { public static $count = 0;
public static function increment(): void { self::$count++; // Static property modification in function }}How to fix
Section titled “How to fix”Consider using instance properties or dependency injection instead of static properties:
<?phpclass Counter { private int $count = 0;
public function increment(): void { $this->count++; }
public function getCount(): int { return $this->count; }}