Skip to content

Commit

Permalink
Fix "missing return statement" phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Jan 27, 2024
1 parent 343561b commit 34500a4
Show file tree
Hide file tree
Showing 30 changed files with 140 additions and 308 deletions.
265 changes: 0 additions & 265 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions plugins/enigma/lib/enigma_driver_gnupg.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public function init()
}

$this->db_sync();

return null;
}

/**
Expand Down
14 changes: 4 additions & 10 deletions plugins/enigma/lib/enigma_driver_phpssl.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,10 @@ public function delete_key($keyid) {}
*
* @return string Hash algorithm name e.g. sha1
*/
public function signature_algorithm() {}

/**
* Converts Crypt_GPG_Key object into Enigma's key object
*
* @param Crypt_GPG_Key $key Key object
*
* @return enigma_key Key object
*/
private function parse_key($key) {}
public function signature_algorithm()
{
return ''; // TODO
}

private function get_openssl_error()
{
Expand Down
8 changes: 6 additions & 2 deletions plugins/enigma/lib/enigma_engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function load_smime_driver()
* @param Mail_mime &$message Original message
* @param int $mode Encryption mode
*
* @return enigma_error On error returns error object
* @return ?enigma_error On error returns error object
*/
public function sign_message(&$message, $mode = null)
{
Expand Down Expand Up @@ -214,6 +214,8 @@ public function sign_message(&$message, $mode = null)
$mime->addPGPSignature($body, $this->pgp_driver->signature_algorithm());
$message = $mime;
}

return null;
}

/**
Expand All @@ -223,7 +225,7 @@ public function sign_message(&$message, $mode = null)
* @param int $mode Encryption mode
* @param bool $is_draft Is draft-save action - use only sender's key for encryption
*
* @return enigma_error On error returns error object
* @return ?enigma_error On error returns error object
*/
public function encrypt_message(&$message, $mode = null, $is_draft = false)
{
Expand Down Expand Up @@ -322,6 +324,8 @@ public function encrypt_message(&$message, $mode = null, $is_draft = false)
$mime->setPGPEncryptedBody($body);
$message = $mime;
}

return null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions plugins/enigma/lib/enigma_key.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public function find_subkey($email, $mode)
}
}
}

return null;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion plugins/enigma/lib/enigma_subkey.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function get_fingerprint()
/**
* Returns human-readable name of the key's algorithm
*
* @return string Algorithm name
* @return ?string Algorithm name
*/
public function get_algorithm()
{
Expand All @@ -75,6 +75,8 @@ public function get_algorithm()
case 22:
return 'EdDSA';
}

return null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions plugins/example_addressbook/example_addressbook_backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public function get_group($group_id)
return $group;
}
}

return null;
}

public function get_name()
Expand Down
4 changes: 3 additions & 1 deletion plugins/managesieve/lib/Roundcube/rcube_sieve_script.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function unset_var($name)
*
* @param string $name Variable name
*
* @return string Variable value
* @return ?string Variable value
*/
public function get_var($name)
{
Expand All @@ -188,6 +188,8 @@ public function get_var($name)
return $this->vars[$i]['name'];
}
}

return null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions program/actions/contacts/qrcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,7 @@ public static function check_support()
return 'image/png';
}
}

return null;
}
}
6 changes: 4 additions & 2 deletions program/actions/mail/attachment_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public static function attachment_success($attachment, $uploadid)
* @param int $filesize File size
* @param string $filetype File mimetype
*
* @return string Error message if the limit is exceeded
* @return ?string Error message if the limit is exceeded
*/
public static function check_message_size($filesize, $filetype)
{
Expand All @@ -252,7 +252,7 @@ public static function check_message_size($filesize, $filetype)
$size = 10 * 1024; // size of message body

if (!$limit) {
return;
return null;
}

// add size of already attached files
Expand All @@ -270,5 +270,7 @@ public static function check_message_size($filesize, $filetype)
$limit = self::show_bytes($limit);
return $rcmail->gettext(['name' => 'msgsizeerror', 'vars' => ['size' => $limit]]);
}

return null;
}
}
4 changes: 3 additions & 1 deletion program/actions/mail/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ public static function part_image_type($part)
$webp_support = $webp_support || rcube_image::is_convertable('image/webp');

if ((!$tiff_support && $mimetype == 'image/tiff') || (!$webp_support && $mimetype == 'image/webp')) {
return;
return null;
}

// Content-Type: image/*...
Expand Down Expand Up @@ -1165,6 +1165,8 @@ public static function part_image_type($part)
) {
return $types[$extension];
}

return null;
}

/**
Expand Down
10 changes: 9 additions & 1 deletion program/include/rcmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ public function get_address_book_id($object)
return $index;
}
}

return null;
}

/**
Expand Down Expand Up @@ -863,6 +865,8 @@ public function login_error()
if ($this->storage && $this->storage->get_error_code() < -1) {
return self::ERROR_STORAGE;
}

return null;
}

/**
Expand Down Expand Up @@ -935,6 +939,8 @@ public function session_error()

return $error;
}

return null;
}

/**
Expand Down Expand Up @@ -1539,7 +1545,7 @@ public function log_login($user = null, $failed_login = false, $error_code = 0)
public function find_asset($path, $minified = true)
{
if (empty($path)) {
return;
return null;
}

$assets_dir = $this->config->get('assets_dir');
Expand All @@ -1558,6 +1564,8 @@ public function find_asset($path, $minified = true)
return $path;
}
}

return null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions program/include/rcmail_oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,8 @@ public function logout_after(array $options)
// propagate logout request to the identity provider
$this->rcmail->output->redirect($this->logout_redirect_url); // exit
}

return $options;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions program/include/rcmail_sendmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ public function header_received()

return wordwrap($http_header, 69, $nldlm);
}

return null;
}

/**
Expand Down Expand Up @@ -829,6 +831,8 @@ public function generic_message_footer($isHtml)
return $footer;
}
}

return null;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions program/lib/Roundcube/rcube_addressbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ public function update($id, $save_cols)
public function delete($ids, $force = true)
{
// empty for read-only address books
return false;
}

/**
Expand All @@ -444,6 +445,7 @@ public function delete($ids, $force = true)
public function undelete($ids)
{
// empty for read-only address books
return [];
}

/**
Expand All @@ -454,6 +456,7 @@ public function undelete($ids)
public function delete_all($with_groups = false)
{
// empty for read-only address books
return false;
}

/**
Expand All @@ -471,6 +474,7 @@ public function delete_all($with_groups = false)
public function set_group($group_id)
{
// empty for address books don't supporting groups
return null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions program/lib/Roundcube/rcube_cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ protected function get_item($key)
protected function add_item($key, $data)
{
// to be overwritten by engine class
return false;
}

/**
Expand All @@ -516,6 +517,7 @@ protected function add_item($key, $data)
protected function delete_item($key)
{
// to be overwritten by engine class
return false;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions program/lib/Roundcube/rcube_charset.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ public static function check($str, $charsets = [])
return $charset;
}
}

return null;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion program/lib/Roundcube/rcube_csv2vcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public function __construct($lang = 'en_US')
* @param bool $dry_run Generate automatic field mapping
* @param bool $skip_head Skip header line
*
* @return array Field mapping info (dry run only)
* @return array|null Field mapping info (dry run only)
*/
public function import($csv, $dry_run = false, $skip_head = true)
{
Expand All @@ -421,6 +421,7 @@ public function import($csv, $dry_run = false, $skip_head = true)
if ($charset = rcube_charset::check($csv)) {
$csv = rcube_charset::convert($csv, $charset);
}

$csv = preg_replace(['/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'], '', $csv); // also remove BOM

// Split CSV file into lines
Expand Down Expand Up @@ -449,6 +450,8 @@ public function import($csv, $dry_run = false, $skip_head = true)
$this->csv_to_vcard($elements);
}
}

return null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions program/lib/Roundcube/rcube_html2text.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ public function tags_preg_callback($matches)

return $this->_handle_link($url, $matches[4]);
}

return '';
}

/**
Expand Down
2 changes: 2 additions & 0 deletions program/lib/Roundcube/rcube_image.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public function props()
'channels' => $channels,
];
}

return null;
}

/**
Expand Down
Loading

0 comments on commit 34500a4

Please sign in to comment.