framework/base/Module.php
public function setModule($id, $module)
    {
        if ($module === null) {
            unset($this->_modules[$id]);
        } else {
            $this->_modules[$id] = $module;
        }
    }
public function setModule($id, $module)
    {
        if ($module === null) {
            unset($this->_modules[$id]);
        } else {
            $this->_modules[$id] = $module;
        }
    }
Adds a sub-module to this module.
@param string $id module ID.
@param Module|array|null $module the sub-module to be added to this module. This can
be one of the following:

- a [[Module]] object
- a configuration array: when [[getModule()]] is called initially, the array
will be used to instantiate the sub-module
- `null`: the named sub-module will be removed from this module