Skip to content

Commit

Permalink
Merge pull request FreshRSS#1724 from kevinpapst/exception-bug
Browse files Browse the repository at this point in the history
ExtensionManager fixes
  • Loading branch information
Alkarex authored Dec 13, 2017
2 parents afa4470 + 0c854be commit 78b6807
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions lib/Minz/ExtensionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public static function init() {
* If the extension class name is `TestExtension`, entry point will be `Test`.
* `entry_point` must be composed of alphanumeric characters.
*
* @param $meta is an array of values.
* @return true if the array is valid, false else.
* @param array $meta is an array of values.
* @return bool true if the array is valid, false else.
*/
public static function isValidMetadata($meta) {
$valid_chars = array('_');
Expand All @@ -107,8 +107,8 @@ public static function isValidMetadata($meta) {
/**
* Load the extension source code based on info metadata.
*
* @param $info an array containing information about extension.
* @return an extension inheriting from Minz_Extension.
* @param array $info an array containing information about extension.
* @return Minz_Extension|null an extension inheriting from Minz_Extension.
*/
public static function load($info) {
$entry_point_filename = $info['path'] . '/' . self::$ext_entry_point;
Expand All @@ -127,9 +127,9 @@ public static function load($info) {
$extension = null;
try {
$extension = new $ext_class_name($info);
} catch (Minz_ExtensionException $e) {
} catch (Exception $e) {
// We cannot load the extension? Invalid!
Minz_Log::warning('In `' . $metadata_filename . '`: ' . $e->getMessage());
Minz_Log::warning('Invalid extension `' . $ext_class_name . '`: ' . $e->getMessage());
return null;
}

Expand All @@ -149,7 +149,7 @@ public static function load($info) {
* If the extension is present in $ext_auto_enabled and if its type is "system",
* it will be enabled in the same time.
*
* @param $ext a valid extension.
* @param Minz_Extension $ext a valid extension.
*/
public static function register($ext) {
$name = $ext->getName();
Expand All @@ -168,7 +168,7 @@ public static function register($ext) {
*
* The extension init() method will be called.
*
* @param $ext_name is the name of a valid extension present in $ext_list.
* @param Minz_Extension $ext_name is the name of a valid extension present in $ext_list.
*/
public static function enable($ext_name) {
if (isset(self::$ext_list[$ext_name])) {
Expand All @@ -182,7 +182,7 @@ public static function enable($ext_name) {
/**
* Enable a list of extensions.
*
* @param $ext_list the names of extensions we want to load.
* @param string[] $ext_list the names of extensions we want to load.
*/
public static function enableByList($ext_list) {
foreach ($ext_list as $ext_name) {
Expand All @@ -193,8 +193,8 @@ public static function enableByList($ext_list) {
/**
* Return a list of extensions.
*
* @param $only_enabled if true returns only the enabled extensions (false by default).
* @return an array of extensions.
* @param bool $only_enabled if true returns only the enabled extensions (false by default).
* @return Minz_Extension[] an array of extensions.
*/
public static function listExtensions($only_enabled = false) {
if ($only_enabled) {
Expand All @@ -207,8 +207,8 @@ public static function listExtensions($only_enabled = false) {
/**
* Return an extension by its name.
*
* @param $ext_name the name of the extension.
* @return the corresponding extension or null if it doesn't exist.
* @param string $ext_name the name of the extension.
* @return Minz_Extension|null the corresponding extension or null if it doesn't exist.
*/
public static function findExtension($ext_name) {
if (!isset(self::$ext_list[$ext_name])) {
Expand All @@ -224,9 +224,9 @@ public static function findExtension($ext_name) {
* The hook name must be a valid one. For the valid list, see self::$hook_list
* array keys.
*
* @param $hook_name the hook name (must exist).
* @param $hook_function the function name to call (must be callable).
* @param $ext the extension which register the hook.
* @param string $hook_name the hook name (must exist).
* @param callable $hook_function the function name to call (must be callable).
* @param Minz_Extension $ext the extension which register the hook.
*/
public static function addHook($hook_name, $hook_function, $ext) {
if (isset(self::$hook_list[$hook_name]) && is_callable($hook_function)) {
Expand All @@ -241,8 +241,8 @@ public static function addHook($hook_name, $hook_function, $ext) {
* The hook name must be a valid one. For the valid list, see self::$hook_list
* array keys.
*
* @param $hook_name the hook to call.
* @param additionnal parameters (for signature, please see self::$hook_list).
* @param string $hook_name the hook to call.
* @param additional parameters (for signature, please see self::$hook_list).
* @return the final result of the called hook.
*/
public static function callHook($hook_name) {
Expand Down

0 comments on commit 78b6807

Please sign in to comment.