Skip to content

MIR0216

NonStaticSelfCall

self::method() is used to call an instance method from within the same class, but the target method is not declared static. This is only valid inside a static context.

<?php
class MyClass {
public function helper(): string {
return 'help';
}
public static function run(): string {
return self::helper(); // helper() is not static
}
}

Declare helper() as static, or call it on an instance instead:

<?php
public static function run(): string {
$instance = new self();
return $instance->helper();
}