diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2024-11-13 18:38:32 +0000 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2024-11-13 18:38:32 +0000 |
| commit | 394d606fe977a331f733c62e5509469c2eb3ef31 (patch) | |
| tree | 27832a131eafec209a8de1361c35c69baa45231f /classes/PluginHost.php | |
| parent | 6273e26ea463e2762f2d736455f4912de7171cfa (diff) | |
| parent | 859ce4d7f69a46716a10eacc485ffaf9867a76d4 (diff) | |
Merge branch 'feature/phpstan-2.0.x' into 'master'
PHPStan 2.0.x
See merge request tt-rss/tt-rss!74
Diffstat (limited to 'classes/PluginHost.php')
| -rw-r--r-- | classes/PluginHost.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/classes/PluginHost.php b/classes/PluginHost.php index 23ff03661..608355158 100644 --- a/classes/PluginHost.php +++ b/classes/PluginHost.php @@ -386,7 +386,7 @@ class PluginHost { * @param PluginHost::HOOK_* $type */ function del_hook(string $type, Plugin $sender): void { - if (is_array($this->hooks[$type])) { + if (array_key_exists($type, $this->hooks)) { foreach (array_keys($this->hooks[$type]) as $prio) { $key = array_search($sender, $this->hooks[$type][$prio]); @@ -589,7 +589,7 @@ class PluginHost { } } - /** @return array<string, array{'description': string, 'suffix': string, 'arghelp': string, 'class': Plugin}>> command type -> details array */ + /** @return array<string, array{'description': string, 'suffix': string, 'arghelp': string, 'class': Plugin}> command type -> details array */ function get_commands() { return $this->commands; } @@ -782,12 +782,21 @@ class PluginHost { return $this->feeds[$cat_id] ?? []; } - // convert feed_id (e.g. -129) to pfeed_id first + /** + * convert feed_id (e.g. -129) to pfeed_id first + * + * @return (Plugin&IVirtualFeed)|null + */ function get_feed_handler(int $pfeed_id): ?Plugin { foreach ($this->feeds as $cat) { foreach ($cat as $feed) { if ($feed['id'] == $pfeed_id) { - return $feed['sender']; + if (implements_interface($feed['sender'], 'IVirtualFeed')) { + /** @var Plugin&IVirtualFeed $feed['sender'] */ + return $feed['sender']; + } else { + return null; + } } } } |