mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-02-20 01:21:20 +01:00
Fix phpstan errors
This commit is contained in:
@@ -355,182 +355,12 @@ parameters:
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_csv2vcard.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property object\\:\\:\\$sets\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap.php
|
||||
|
||||
-
|
||||
message: "#^Binary operation \"\\+\" between string and int results in an error\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap.php
|
||||
|
||||
-
|
||||
message: "#^Binary operation \"\\.\" between ' UID '\\|'UNDELETED UID ' and non\\-empty\\-array results in an error\\.$#"
|
||||
count: 2
|
||||
path: program/lib/Roundcube/rcube_imap.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method object\\:\\:get\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method object\\:\\:get_parameters\\(\\)\\.$#"
|
||||
count: 2
|
||||
path: program/lib/Roundcube/rcube_imap.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method object\\:\\:revert\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method object\\:\\:set_message_index\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$folder in empty\\(\\) is never defined\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$uids in empty\\(\\) always exists and is not falsy\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_cache.php
|
||||
|
||||
-
|
||||
message: "#^Binary operation \"\\+\" between int\\<3, max\\> and string results in an error\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Binary operation \"\\-\" between string and 1 results in an error\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Call to method acquireCredentials\\(\\) on an unknown class GSSAPIContext\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Call to method initSecContext\\(\\) on an unknown class GSSAPIContext\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Call to method open\\(\\) on an unknown class KRB5CCache\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Call to method unwrap\\(\\) on an unknown class GSSAPIContext\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Call to method wrap\\(\\) on an unknown class GSSAPIContext\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Instantiated class GSSAPIContext not found\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Instantiated class KRB5CCache not found\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Undefined variable\\: \\$otoken$#"
|
||||
count: 2
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$entries in empty\\(\\) is never defined\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$found might not be defined\\.$#"
|
||||
count: 2
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$key might not be defined\\.$#"
|
||||
count: 2
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$mode might not be defined\\.$#"
|
||||
count: 3
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$result might not be defined\\.$#"
|
||||
count: 3
|
||||
path: program/lib/Roundcube/rcube_imap_generic.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method get_set\\(\\) on array\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_imap_search.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method bind\\(\\) on class\\-string\\|object\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_ldap.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$charsets might not be defined\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_message.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property rcube\\:\\:\\$action\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_plugin_api.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$messages in empty\\(\\) always exists and is not falsy\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_result_thread.php
|
||||
|
||||
-
|
||||
message: "#^Binary operation \"\\+\" between string and 1 results in an error\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_session.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$host in empty\\(\\) always exists and is not falsy\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_smtp.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$prefixes might not be defined\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_utils.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$value might not be defined\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_vcard.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#"
|
||||
count: 2
|
||||
path: program/lib/Roundcube/rcube_washtml.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method DOMNode\\:\\:setAttribute\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/rcube_washtml.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$e might not be defined\\.$#"
|
||||
count: 1
|
||||
path: program/lib/Roundcube/spellchecker/googie.php
|
||||
|
||||
@@ -7,5 +7,9 @@ parameters:
|
||||
- .
|
||||
excludePaths:
|
||||
- vendor
|
||||
|
||||
ignoreErrors:
|
||||
- '~class (GSSAPIContext|KRB5CCache)~'
|
||||
|
||||
scanFiles:
|
||||
- vendor/pear/pear-core-minimal/src/PEAR.php
|
||||
|
||||
@@ -32,23 +32,18 @@ class rcube_imap extends rcube_storage
|
||||
public $conn;
|
||||
|
||||
/**
|
||||
* Instance of rcube_imap_cache
|
||||
*
|
||||
* @var rcube_imap_cache
|
||||
*/
|
||||
* @var ?rcube_imap_cache Instance of rcube_imap_cache */
|
||||
protected $mcache;
|
||||
|
||||
/**
|
||||
* Instance of rcube_cache
|
||||
*
|
||||
* @var rcube_cache
|
||||
*/
|
||||
/** @var ?rcube_cache Instance of rcube_cache */
|
||||
protected $cache;
|
||||
|
||||
protected $plugins;
|
||||
protected $delimiter;
|
||||
protected $namespace;
|
||||
protected $struct_charset;
|
||||
|
||||
/** @var rcube_result_thread|rcube_result_index|rcube_result_multifolder Search result */
|
||||
protected $search_set;
|
||||
protected $search_string = '';
|
||||
protected $search_charset = '';
|
||||
@@ -1588,10 +1583,10 @@ class rcube_imap extends rcube_storage
|
||||
/**
|
||||
* Invoke search request to IMAP server
|
||||
*
|
||||
* @param string $folder Folder name to search in
|
||||
* @param string $search Search criteria
|
||||
* @param string $charset Search charset
|
||||
* @param string $sort_field Header field to sort by
|
||||
* @param string|array $folder Folder name(s) to search in
|
||||
* @param string $search Search criteria
|
||||
* @param string $charset Search charset
|
||||
* @param string $sort_field Header field to sort by
|
||||
*
|
||||
* @return rcube_result_index Search result object
|
||||
*
|
||||
@@ -1795,7 +1790,7 @@ class rcube_imap extends rcube_storage
|
||||
}
|
||||
|
||||
$res .= substr($str, $last, $m[1] - $last - 1) . rcube_imap_generic::escape($string);
|
||||
$last = $m[0] + $string_offset - 1;
|
||||
$last = intval($m[0]) + $string_offset - 1;
|
||||
}
|
||||
|
||||
if ($last < strlen($str)) {
|
||||
|
||||
@@ -673,9 +673,10 @@ class rcube_imap_generic
|
||||
return $this->parseResult($line);
|
||||
}
|
||||
|
||||
try {
|
||||
$itoken = base64_decode(substr($line, 2));
|
||||
$itoken = base64_decode(substr($line, 2));
|
||||
$otoken = null;
|
||||
|
||||
try {
|
||||
if (!$gssapicontext->unwrap($itoken, $itoken)) {
|
||||
throw new Exception('GSSAPI SASL input token unwrap failed');
|
||||
}
|
||||
@@ -2822,6 +2823,9 @@ class rcube_imap_generic
|
||||
|
||||
$binary = true;
|
||||
$initiated = false;
|
||||
$result = false;
|
||||
$found = false;
|
||||
$mode = 0;
|
||||
|
||||
do {
|
||||
if (!$initiated) {
|
||||
@@ -2874,6 +2878,7 @@ class rcube_imap_generic
|
||||
}
|
||||
|
||||
// handle UNKNOWN-CTE response - RFC 3516, try again with standard BODY request
|
||||
// @phpstan-ignore-next-line
|
||||
if ($binary && !$found && preg_match('/^' . $key . ' NO \[(UNKNOWN-CTE|PARSE)\]/i', $line)) {
|
||||
$binary = $initiated = false;
|
||||
continue;
|
||||
@@ -2928,6 +2933,7 @@ class rcube_imap_generic
|
||||
elseif (!$mode && !$file && !$print) {
|
||||
$result = $this->readBytes($bytes);
|
||||
} else {
|
||||
$result = '';
|
||||
while ($bytes > 0) {
|
||||
$chunk = $this->readBytes($bytes > $chunkSize ? $chunkSize : $bytes);
|
||||
|
||||
@@ -2957,12 +2963,14 @@ class rcube_imap_generic
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (!$this->startsWith($line, $key, true) || !$initiated);
|
||||
} while (!$initiated || !$this->startsWith($line, $key, true)); // @phpstan-ignore-line
|
||||
|
||||
if ($result !== false) {
|
||||
if ($file) {
|
||||
return fwrite($file, $result);
|
||||
} elseif ($print) {
|
||||
}
|
||||
|
||||
if ($print) {
|
||||
echo $result;
|
||||
return true;
|
||||
}
|
||||
@@ -3492,8 +3500,8 @@ class rcube_imap_generic
|
||||
/**
|
||||
* Send the SETMETADATA command with NIL values (RFC5464)
|
||||
*
|
||||
* @param string $mailbox Mailbox name
|
||||
* @param array $entries Entry names array
|
||||
* @param string $mailbox Mailbox name
|
||||
* @param array|string $entries Entry names array (or space separated string)
|
||||
*
|
||||
* @return bool True on success, False on failure
|
||||
*
|
||||
@@ -3814,7 +3822,7 @@ class rcube_imap_generic
|
||||
$orig_part = $part;
|
||||
$pos = strpos($part, '.');
|
||||
$rest = substr($orig_part, $pos + 1);
|
||||
$part = substr($orig_part, 0, $pos);
|
||||
$part = (int) substr($orig_part, 0, $pos);
|
||||
|
||||
return self::getStructurePartArray($a[$part - 1], $rest);
|
||||
} elseif ($part > 0) {
|
||||
@@ -3949,6 +3957,7 @@ class rcube_imap_generic
|
||||
// error
|
||||
}
|
||||
|
||||
$bytes = (int) $bytes;
|
||||
$result[] = $bytes ? substr($str, $epos + 3, $bytes) : '';
|
||||
$str = substr($str, $epos + 3 + $bytes);
|
||||
break;
|
||||
|
||||
@@ -32,7 +32,7 @@ class rcube_imap_search
|
||||
/** @var int Time limit in seconds */
|
||||
protected $timelimit = 0;
|
||||
|
||||
/** @var array Search results */
|
||||
/** @var ?rcube_result_multifolder Search results */
|
||||
protected $results;
|
||||
|
||||
/** @var rcube_imap_generic IMAP connection object */
|
||||
@@ -108,7 +108,7 @@ class rcube_imap_search
|
||||
/**
|
||||
* Setter for previous (potentially incomplete) search results
|
||||
*
|
||||
* @param array $res Search result
|
||||
* @param rcube_result_multifolder $res Search result
|
||||
*/
|
||||
public function set_results($res)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
*/
|
||||
class rcube_ldap extends rcube_addressbook
|
||||
{
|
||||
// public properties
|
||||
public $primary_key = 'ID';
|
||||
public $groups = false;
|
||||
public $readonly = true;
|
||||
@@ -34,8 +33,9 @@ class rcube_ldap extends rcube_addressbook
|
||||
public $coltypes = [];
|
||||
public $export_groups = false;
|
||||
|
||||
// private properties
|
||||
/** @var ?rcube_ldap_generic LDAP handler */
|
||||
protected $ldap;
|
||||
|
||||
protected $formats = [];
|
||||
protected $prop = [];
|
||||
protected $fieldmap = [];
|
||||
|
||||
@@ -1217,6 +1217,8 @@ class rcube_message
|
||||
return $name;
|
||||
}
|
||||
|
||||
$charsets = [];
|
||||
|
||||
// find charset from part or its parent(s)
|
||||
if ($part->charset) {
|
||||
$charsets[] = $part->charset;
|
||||
|
||||
@@ -326,7 +326,7 @@ class rcube_result_index
|
||||
/**
|
||||
* Return all messages in the result.
|
||||
*
|
||||
* @return array List of message IDs
|
||||
* @return string List of message IDs
|
||||
*/
|
||||
public function get_compressed()
|
||||
{
|
||||
|
||||
@@ -322,7 +322,7 @@ class rcube_result_thread
|
||||
/**
|
||||
* Return all messages in the result.
|
||||
*
|
||||
* @return array List of message identifiers
|
||||
* @return string List of message identifiers
|
||||
*/
|
||||
public function get_compressed()
|
||||
{
|
||||
@@ -608,7 +608,7 @@ class rcube_result_thread
|
||||
$stop = $begin + strcspn($str, '()', $begin, $end - $begin);
|
||||
$messages = explode(' ', trim(substr($str, $begin, $stop - $begin)));
|
||||
|
||||
if (empty($messages)) {
|
||||
if (empty($messages[0])) {
|
||||
return $node;
|
||||
}
|
||||
|
||||
|
||||
@@ -550,7 +550,7 @@ abstract class rcube_session implements SessionHandlerInterface
|
||||
}
|
||||
$q++;
|
||||
// increment pointer because of outer array
|
||||
$serialized .= 'R:' . ($id + 1) . ';';
|
||||
$serialized .= 'R:' . (intval($id) + 1) . ';';
|
||||
if ($level == 0) {
|
||||
break 2;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class rcube_smtp
|
||||
// reset error/response var
|
||||
$this->error = $this->response = null;
|
||||
|
||||
if (!$host) {
|
||||
if (empty($host)) {
|
||||
$host = $rcube->config->get('smtp_host', 'localhost:587');
|
||||
if (is_array($host)) {
|
||||
if (array_key_exists($_SESSION['storage_host'], $host)) {
|
||||
@@ -64,7 +64,7 @@ class rcube_smtp
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} elseif (!empty($port) && !empty($host) && !preg_match('/:\d+$/', $host)) {
|
||||
} elseif (!empty($port) && !preg_match('/:\d+$/', $host)) {
|
||||
$host = "{$host}:{$port}";
|
||||
}
|
||||
|
||||
|
||||
@@ -1640,6 +1640,7 @@ class rcube_utils
|
||||
public static function remove_subject_prefix($subject, $mode = 'both')
|
||||
{
|
||||
$config = rcmail::get_instance()->config;
|
||||
$prefixes = [];
|
||||
|
||||
// Clean subject prefix for reply, forward or both
|
||||
if ($mode == 'both') {
|
||||
|
||||
@@ -247,6 +247,7 @@ class rcube_vcard
|
||||
|
||||
// split ADR values into assoc array
|
||||
if ($tag == 'ADR') {
|
||||
$value = [];
|
||||
if (isset($raw[2])) {
|
||||
$value['street'] = $raw[2];
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ class rcube_washtml
|
||||
/**
|
||||
* Take a node and return allowed attributes and check values
|
||||
*
|
||||
* @param DOMNode $node Document element
|
||||
* @param DOMElement $node Document element
|
||||
*
|
||||
* @return string Washed element attributes
|
||||
*/
|
||||
@@ -574,7 +574,8 @@ class rcube_washtml
|
||||
|
||||
do {
|
||||
switch ($node->nodeType) {
|
||||
case \XML_ELEMENT_NODE: // Check element
|
||||
case \XML_ELEMENT_NODE:
|
||||
/** @var DOMElement $node */
|
||||
$tagName = strtolower($node->nodeName);
|
||||
|
||||
if ($tagName == 'link') {
|
||||
|
||||
@@ -92,7 +92,7 @@ class rcube_spellchecker_googie extends rcube_spellchecker_engine
|
||||
}
|
||||
|
||||
if (empty($response)) {
|
||||
$this->error = $e ? $e->getMessage() : 'Spelling engine failure';
|
||||
$this->error = isset($e) ? $e->getMessage() : 'Spelling engine failure';
|
||||
} elseif ($response->getStatusCode() != 200) {
|
||||
$this->error = 'HTTP ' . $response->getReasonPhrase();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user