1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 01:25:56 +00:00

Address PHPStan warnings in 'classes/mailer.php', 'classes/opml.php', and 'classes/pluginhandler.php'.

This commit is contained in:
wn_
2021-11-12 06:16:18 +00:00
parent 9db5e402a0
commit 2c41bc7fbc
3 changed files with 31 additions and 17 deletions

View File

@@ -1,8 +1,12 @@
<?php
class Mailer {
private $last_error = "";
private string $last_error = "";
function mail($params) {
/**
* @param array<string, mixed> $params
* @return bool|int bool if the default mail function handled the request, otherwise an int as described in Mailer#mail()
*/
function mail(array $params) {
$to_name = $params["to_name"] ?? "";
$to_address = $params["to_address"];
@@ -26,6 +30,8 @@ class Mailer {
// 4. set error message if needed via passed Mailer instance function set_error()
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEND_MAIL) as $p) {
// Implemented via plugin, so ignore the undefined method 'hook_send_mail'.
// @phpstan-ignore-next-line
$rc = $p->hook_send_mail($this, $params);
if ($rc == 1)
@@ -46,12 +52,12 @@ class Mailer {
return $rc;
}
function set_error($message) {
function set_error(string $message): void {
$this->last_error = $message;
user_error("Error sending mail: $message", E_USER_WARNING);
}
function error() {
function error(): string {
return $this->last_error;
}
}