diff options
| author | 2023-12-18 17:59:16 +0100 | |
|---|---|---|
| committer | 2023-12-18 17:59:16 +0100 | |
| commit | a80a5f48a16e7d232168a7aaa68e9a1804235ce1 (patch) | |
| tree | a515b88592629dea7e83b96e26e2452d3f98a98e /lib/Minz/ExtensionManager.php | |
| parent | 6bb45a87268157aab961a6a4a728d9a9bbe043b0 (diff) | |
Pass PHPStan level 8 (#5946)
* Pass PHPStan level 8
And prepare for PHPStan level 9 https://phpstan.org/user-guide/rule-levels
* Revert wrong replace in comment
* Fix PHPStan level 8
* Update PHPStan and other dev dependencies
* Remove obsolete comment
* noVariableVariables and towards bleedingEdge
https://github.com/phpstan/phpstan-strict-rules
https://phpstan.org/blog/what-is-bleeding-edge
* More bleedingEdge
* A bit more PHPStan level 9
* More PHPStan level 9
* Prepare for booleansInConditions
Ignore int and null
* Revert wrong line
* More fixes
* Fix keep_max_n_unread
* Stricter attribute functions
* Stricter callHooks and more PHPStan level 9
* More typing
* A tiny more
Diffstat (limited to 'lib/Minz/ExtensionManager.php')
| -rw-r--r-- | lib/Minz/ExtensionManager.php | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index e1443b9c3..9d8b94cbd 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -147,7 +147,7 @@ final class Minz_ExtensionManager { $meta_raw_content = file_get_contents($metadata_filename) ?: ''; /** @var array{'name':string,'entrypoint':string,'path':string,'author'?:string,'description'?:string,'version'?:string,'type'?:'system'|'user'}|null $meta_json */ $meta_json = json_decode($meta_raw_content, true); - if (!$meta_json || !self::isValidMetadata($meta_json)) { + if (!is_array($meta_json) || !self::isValidMetadata($meta_json)) { // metadata.json is not a json file? Invalid! // or metadata.json is invalid (no required information), invalid! Minz_Log::warning('`' . $metadata_filename . '` is not a valid metadata file'); @@ -347,9 +347,9 @@ final class Minz_ExtensionManager { call_user_func($function, ...$args); } } elseif ($signature === 'NoneToString') { - return self::callNoneToString($hook_name); + return self::callHookString($hook_name); } elseif ($signature === 'NoneToNone') { - self::callNoneToNone($hook_name); + self::callHookVoid($hook_name); } return; } @@ -391,9 +391,9 @@ final class Minz_ExtensionManager { * @param string $hook_name is the hook to call. * @return string concatenated result of the call to all the hooks. */ - private static function callNoneToString(string $hook_name): string { + public static function callHookString(string $hook_name): string { $result = ''; - foreach (self::$hook_list[$hook_name]['list'] as $function) { + foreach (self::$hook_list[$hook_name]['list'] ?? [] as $function) { $result = $result . call_user_func($function); } return $result; @@ -407,8 +407,8 @@ final class Minz_ExtensionManager { * * @param string $hook_name is the hook to call. */ - private static function callNoneToNone(string $hook_name): void { - foreach (self::$hook_list[$hook_name]['list'] as $function) { + public static function callHookVoid(string $hook_name): void { + foreach (self::$hook_list[$hook_name]['list'] ?? [] as $function) { call_user_func($function); } } |
