*/
class ApiModuleManager extends ContextSource {
+ /**
+ * @var ApiBase
+ */
private $mParent;
+ /**
+ * @var ApiBase[]
+ */
private $mInstances = array();
+ /**
+ * @var null[]
+ */
private $mGroups = array();
+ /**
+ * @var array[]
+ */
private $mModules = array();
/**
* classes who wish to add their own modules to their lexicon or override the
* behavior of inherent ones.
*
- * @param $group string Name of the module group
- * @param $name string The identifier for this module.
- * @param $class string The class where this module is implemented.
+ * @param string $group Name of the module group
+ * @param string $name The identifier for this module.
+ * @param string $class The class where this module is implemented.
*/
public function addModule( $name, $group, $class ) {
$this->mGroups[$group] = null;
/**
* Get module instance by name, or instantiate it if it does not exist
- * @param $moduleName string module name
- * @param $group string optionally validate that the module is in a specific group
- * @param $ignoreCache bool if true, force-creates a new instance and does not cache it
- * @return mixed the new module instance, or null if failed
+ * @param string $moduleName Module name
+ * @param string $group Optionally validate that the module is in a specific group
+ * @param bool $ignoreCache If true, force-creates a new instance and does not cache it
+ * @return mixed The new module instance, or null if failed
*/
public function getModule( $moduleName, $group = null, $ignoreCache = false ) {
if ( !isset( $this->mModules[$moduleName] ) ) {
// cache this instance in case it is needed later
$this->mInstances[$moduleName] = $instance;
}
+
return $instance;
}
}
/**
* Get an array of modules in a specific group or all if no group is set.
- * @param string $group optional group filter
- * @return array list of module names
+ * @param string $group Optional group filter
+ * @return array List of module names
*/
public function getNames( $group = null ) {
if ( $group === null ) {
$result[] = $name;
}
}
+
return $result;
}
/**
* Create an array of (moduleName => moduleClass) for a specific group or for all.
- * @param string $group name of the group to get or null for all
- * @return array name=>class map
+ * @param string $group Name of the group to get or null for all
+ * @return array Name=>class map
*/
public function getNamesWithClasses( $group = null ) {
$result = array();
$result[$name] = $grpCls[1];
}
}
+
return $result;
}
/**
* Returns true if the specific module is defined at all or in a specific group.
- * @param string $moduleName module name
- * @param string $group group name to check against, or null to check all groups,
- * @return boolean true if defined
+ * @param string $moduleName Module name
+ * @param string $group Group name to check against, or null to check all groups,
+ * @return bool True if defined
*/
public function isDefined( $moduleName, $group = null ) {
if ( isset( $this->mModules[$moduleName] ) ) {
return $group === null || $this->mModules[$moduleName][0] === $group;
- } else {
- return false;
}
+
+ return false;
}
/**
* Returns the group name for the given module
* @param string $moduleName
- * @return string group name or null if missing
+ * @return string Group name or null if missing
*/
public function getModuleGroup( $moduleName ) {
if ( isset( $this->mModules[$moduleName] ) ) {
return $this->mModules[$moduleName][0];
- } else {
- return null;
}
+
+ return null;
}
/**