Skip to content

Commit

Permalink
Code improvements, PHPDoc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Mar 29, 2024
1 parent 337e906 commit 58d2829
Show file tree
Hide file tree
Showing 11 changed files with 243 additions and 484 deletions.
260 changes: 0 additions & 260 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,6 @@ parameters:
count: 1
path: program/actions/mail/group_expand.php

-
message: "#^Strict comparison using \\!\\=\\= between string and false will always evaluate to true\\.$#"
count: 1
path: program/actions/mail/headers.php

-
message: "#^Foreach overwrites \\$m with its value variable\\.$#"
count: 1
Expand All @@ -235,16 +230,6 @@ parameters:
count: 1
path: program/actions/mail/index.php

-
message: "#^Property rcube_message_header\\:\\:\\$parent_uid \\(int\\) does not accept string\\.$#"
count: 1
path: program/actions/mail/index.php

-
message: "#^Property rcube_message_header\\:\\:\\$uid \\(int\\) does not accept string\\.$#"
count: 1
path: program/actions/mail/index.php

-
message: "#^Right side of && is always true\\.$#"
count: 1
Expand Down Expand Up @@ -290,26 +275,6 @@ parameters:
count: 1
path: program/actions/mail/show.php

-
message: "#^Strict comparison using \\!\\=\\= between int and false will always evaluate to true\\.$#"
count: 1
path: program/actions/settings/folder_edit.php

-
message: "#^Strict comparison using \\!\\=\\= between string and null will always evaluate to true\\.$#"
count: 1
path: program/actions/settings/folder_edit.php

-
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
count: 1
path: program/actions/settings/folder_edit.php

-
message: "#^Strict comparison using \\!\\=\\= between int and false will always evaluate to true\\.$#"
count: 1
path: program/actions/settings/folder_size.php

-
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
count: 1
Expand Down Expand Up @@ -840,226 +805,6 @@ parameters:
count: 1
path: program/lib/Roundcube/rcube_html2text.php

-
message: "#^Implicit array creation is not allowed \\- variable \\$p does not exist\\.$#"
count: 2
path: program/lib/Roundcube/rcube_image.php

-
message: "#^Call to function is_array\\(\\) with array will always evaluate to true\\.$#"
count: 3
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Call to function is_array\\(\\) with string\\|null will always evaluate to false\\.$#"
count: 2
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Call to function is_object\\(\\) with rcube_result_index\\|rcube_result_multifolder\\|rcube_result_thread will always evaluate to true\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#"
count: 13
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^For loop initial assignment overwrites variable \\$count\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Foreach overwrites \\$folder with its key variable\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Foreach overwrites \\$ns with its value variable\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Implicit array creation is not allowed \\- variable \\$mime_part_headers might not exist\\.$#"
count: 3
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Left side of && is always true\\.$#"
count: 5
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Method rcube_imap\\:\\:folder_data\\(\\) should return array but returns null\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Method rcube_imap\\:\\:folder_size\\(\\) should return int but returns false\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Method rcube_imap\\:\\:get_acl\\(\\) should return array but returns null\\.$#"
count: 2
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Method rcube_imap\\:\\:get_cache\\(\\) should return mixed but return statement is missing\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Method rcube_imap\\:\\:get_fetch_headers\\(\\) should return string but returns array\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Method rcube_imap\\:\\:id2uid\\(\\) should return int but returns null\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Method rcube_imap\\:\\:list_rights\\(\\) should return array but returns null\\.$#"
count: 2
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Method rcube_imap\\:\\:my_rights\\(\\) should return array but returns null\\.$#"
count: 2
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^PHPDoc type rcube_imap_generic of property rcube_imap\\:\\:\\$conn is not the same as PHPDoc type mixed of overridden property rcube_storage\\:\\:\\$conn\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^PHPDoc type rcube_result_index\\|rcube_result_multifolder\\|rcube_result_thread of property rcube_imap\\:\\:\\$search_set is not the same as PHPDoc type mixed of overridden property rcube_storage\\:\\:\\$search_set\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Parameter \\#1 \\$set \\(array\\) of method rcube_imap\\:\\:set_search_set\\(\\) should be contravariant with parameter \\$set \\(mixed\\) of method rcube_storage\\:\\:set_search_set\\(\\)$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Property rcube_imap\\:\\:\\$search_set \\(rcube_result_index\\|rcube_result_multifolder\\|rcube_result_thread\\) in empty\\(\\) is not falsy\\.$#"
count: 3
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Property rcube_message_header\\:\\:\\$bodystructure \\(string\\) does not accept array\\|bool\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Result of && is always false\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Return type \\(array\\|null\\) of method rcube_imap\\:\\:get_metadata\\(\\) should be covariant with return type \\(array\\) of method rcube_storage\\:\\:get_metadata\\(\\)$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Return type \\(array\\|null\\) of method rcube_imap\\:\\:get_search_set\\(\\) should be covariant with return type \\(array\\) of method rcube_storage\\:\\:get_search_set\\(\\)$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Return type \\(rcube_message_header\\|false\\) of method rcube_imap\\:\\:get_message_headers\\(\\) should be covariant with return type \\(rcube_message_header\\) of method rcube_storage\\:\\:get_message_headers\\(\\)$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Return type \\(rcube_message_header\\|null\\) of method rcube_imap\\:\\:get_message\\(\\) should be covariant with return type \\(rcube_message_header\\) of method rcube_storage\\:\\:get_message\\(\\)$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Return type \\(rcube_result_index\\|rcube_result_multifolder\\) of method rcube_imap\\:\\:search_once\\(\\) should be covariant with return type \\(rcube_result_index\\) of method rcube_storage\\:\\:search_once\\(\\)$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Return type \\(string\\|null\\) of method rcube_imap\\:\\:get_raw_body\\(\\) should be covariant with return type \\(string\\) of method rcube_storage\\:\\:get_raw_body\\(\\)$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Return type \\(string\\|null\\) of method rcube_imap\\:\\:get_raw_headers\\(\\) should be covariant with return type \\(string\\) of method rcube_storage\\:\\:get_raw_headers\\(\\)$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Return type \\(string\\|null\\) of method rcube_imap\\:\\:get_vendor\\(\\) should be covariant with return type \\(string\\) of method rcube_storage\\:\\:get_vendor\\(\\)$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Right side of && is always true\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Strict comparison using \\!\\=\\= between string and null will always evaluate to true\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap.php

-
message: "#^Call to function is_object\\(\\) with rcube_message_header will always evaluate to true\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap_cache.php

-
message: "#^Comparison operation \"\\>\" between int\\<1, max\\> and 0 is always true\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap_cache.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap_cache.php

-
message: "#^Method rcube_imap_cache\\:\\:get_index\\(\\) should return array but returns null\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap_cache.php

-
message: "#^Property rcube_imap_cache\\:\\:\\$icache \\(array\\) does not accept null\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap_cache.php

-
message: "#^Property rcube_message_header\\:\\:\\$body \\(string\\) does not accept null\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap_cache.php

-
message: "#^Right side of && is always true\\.$#"
count: 3
path: program/lib/Roundcube/rcube_imap_cache.php

-
message: "#^Call to function is_array\\(\\) with string will always evaluate to false\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap_search.php

-
message: "#^Result of && is always false\\.$#"
count: 1
path: program/lib/Roundcube/rcube_imap_search.php

-
message: "#^Call to function is_array\\(\\) with array will always evaluate to true\\.$#"
count: 1
Expand Down Expand Up @@ -1175,11 +920,6 @@ parameters:
count: 1
path: program/lib/Roundcube/rcube_message.php

-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
path: program/lib/Roundcube/rcube_message.php

-
message: "#^Strict comparison using \\!\\=\\= between string and null will always evaluate to true\\.$#"
count: 2
Expand Down
1 change: 1 addition & 0 deletions plugins/markasjunk/drivers/cmd_learn.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private function _do_salearn($uids, $spam, $src_mbox)
}

if (!empty($header_names)) {
/** @var rcube_imap $storage */
$storage = $rcube->get_storage();
$storage->check_connection();
$headers = $storage->conn->fetchHeader($src_mbox, $uid, true, false, $header_names);
Expand Down
5 changes: 4 additions & 1 deletion program/actions/mail/headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public function run($args = [])
if ($pos = strpos($uid, '.')) {
$message = new rcube_message($uid);
$source = $message->get_part_body(substr($uid, $pos + 1));
$source = substr($source, 0, strpos($source, "\r\n\r\n"));

if (is_string($source)) {
$source = substr($source, 0, strpos($source, "\r\n\r\n"));
}
} else {
$source = $rcmail->storage->get_raw_headers($uid);
}
Expand Down
2 changes: 1 addition & 1 deletion program/actions/settings/folder_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static function folder_form($attrib)
$rcmail->output->set_env('messagecount', $msgcount);
$rcmail->output->set_env('folder', $mbox);

if ($mbox !== null && empty($_POST)) {
if ($mbox !== '' && empty($_POST)) {
$rcmail->output->command('parent.set_quota', self::quota_content(null, $mbox));
}

Expand Down
14 changes: 9 additions & 5 deletions program/lib/Roundcube/rcube_image.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ public function resize($size, $filename = null, $browser_compat = false)

// use Imagemagick
if ($convert || class_exists('Imagick', false)) {
$p['out'] = $filename;
$p['in'] = $this->image_file;
$p = [
'out' => $filename,
'in' => $this->image_file,
];
$type = $props['type'];

if (!$type && ($data = $this->identify())) {
Expand Down Expand Up @@ -316,9 +318,11 @@ public function convert($type, $filename = null)

// use ImageMagick in command line
if ($convert) {
$p['in'] = $this->image_file;
$p['out'] = $filename;
$p['type'] = self::$extensions[$type];
$p = [
'in' => $this->image_file,
'out' => $filename,
'type' => self::$extensions[$type],
];

$result = rcube::exec($convert . ' 2>&1 -colorspace sRGB -strip -flatten -quality 75 {in} {type}:{out}', $p);

Expand Down
Loading

0 comments on commit 58d2829

Please sign in to comment.