framework/base/Module.php
public static function getInstance()
    {
        $class = get_called_class();
        return isset(Yii::$app->loadedModules[$class]) ? Yii::$app->loadedModules[$class] : null;
    }
public static function getInstance()
    {
        $class = get_called_class();
        return isset(Yii::$app->loadedModules[$class]) ? Yii::$app->loadedModules[$class] : null;
    }
Returns the currently requested instance of this module class.
If the module class is not currently requested, `null` will be returned.
This method is provided so that you access the module instance from anywhere within the module.
@return static|null the currently requested instance of this module class, or `null` if the module class is not requested.