Skip to content

Commit

Permalink
partially satisfying psalm, updating baseline, leaving notes to fix l…
Browse files Browse the repository at this point in the history
  • Loading branch information
bapcltd-marv committed Jan 15, 2020
1 parent 3cc31f8 commit b01369f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
30 changes: 7 additions & 23 deletions psalm.baseline.xml
Expand Up @@ -11,9 +11,8 @@
</PropertyTypeCoercion>
</file>
<file src="src/PhpImap/Mailbox.php">
<DocblockTypeContradiction occurrences="3">
<DocblockTypeContradiction occurrences="2">
<code>\is_int($retriesNum)</code>
<code>\is_array($params)</code>
<code>\is_resource($this-&gt;imapStream)</code>
</DocblockTypeContradiction>
<InvalidScalarArgument occurrences="3">
Expand All @@ -28,9 +27,6 @@
<code>$mailId</code>
<code>$mailId</code>
</MissingParamType>
<MissingReturnType occurrences="1">
<code>initMailPart</code>
</MissingReturnType>
<MixedArgument occurrences="50">
<code>$mail-&gt;subject</code>
<code>$mail-&gt;subject</code>
Expand Down Expand Up @@ -83,9 +79,8 @@
<code>$t[1]-&gt;personal</code>
<code>$t[1]-&gt;personal</code>
</MixedArgument>
<MixedAssignment occurrences="14">
<MixedAssignment occurrences="13">
<code>$value</code>
<code>$mail</code>
<code>$to</code>
<code>$cc</code>
<code>$bcc</code>
Expand All @@ -112,17 +107,7 @@
<code>$recipient-&gt;host</code>
<code>$t[0]-&gt;mailbox</code>
</MixedOperand>
<MixedPropertyAssignment occurrences="4">
<code>$mail</code>
<code>$mail</code>
<code>$mail</code>
<code>$mail</code>
</MixedPropertyAssignment>
<MixedPropertyFetch occurrences="24">
<code>$mail-&gt;subject</code>
<code>$mail-&gt;from</code>
<code>$mail-&gt;sender</code>
<code>$mail-&gt;to</code>
<MixedPropertyFetch occurrences="20">
<code>$param-&gt;value</code>
<code>$param-&gt;value</code>
<code>$param-&gt;attribute</code>
Expand All @@ -148,9 +133,6 @@
<code>$str</code>
<code>$str</code>
</MixedReturnStatement>
<PossiblyFalseOperand occurrences="1">
<code>strpos($name, '}')</code>
</PossiblyFalseOperand>
<PossiblyInvalidArgument occurrences="1">
<code>$mailStructure</code>
</PossiblyInvalidArgument>
Expand Down Expand Up @@ -201,10 +183,12 @@
<code>subscribeMailbox</code>
<code>unsubscribeMailbox</code>
</PossiblyUnusedMethod>
<RedundantConditionGivenDocblockType occurrences="4">
<RedundantCondition occurrences="1">
<code>null != $params and !empty($params)</code>
</RedundantCondition>
<RedundantConditionGivenDocblockType occurrences="3">
<code>!\is_int($retriesNum) or $retriesNum &lt; 0</code>
<code>\is_int($retriesNum)</code>
<code>null != $params and !empty($params)</code>
<code>!\is_resource($this-&gt;imapStream) || !imap_ping($this-&gt;imapStream)</code>
</RedundantConditionGivenDocblockType>
<UnusedVariable occurrences="1">
Expand Down
18 changes: 16 additions & 2 deletions src/PhpImap/Mailbox.php
Expand Up @@ -340,9 +340,14 @@ public function getLogin()
* @param int $retriesNum
* @param array|null $params
*
* @psalm-param mixed $params
*
* @throws InvalidParameterException
*
* @todo drop support for php 5.6, set $options and $retriesNum to int
* @todo drop support for php 5.6, set $param to `array $param = null`
* @todo drop support for php 5.6, remove @psalm-param entry
* @todo drop support for php 5.6, set `!empty($params)` to `count($params) > 0`
*/
public function setConnectionArgs($options = 0, $retriesNum = 0, $params = null)
{
Expand Down Expand Up @@ -481,6 +486,8 @@ public function encodeStringToUtf7Imap($str)
* Returns the provided string in UTF-8 encoded format.
*
* @return string $str UTF-7 encoded string or same as before, when it's no string
*
* @todo revisit return issues pending fix of https://github.com/vimeo/psalm/issues/2625
*/
public function decodeStringFromUtf7ImapToUtf8($str)
{
Expand Down Expand Up @@ -857,9 +864,12 @@ public function clearFlag(array $mailsIds, $flag)
* draft - this mail is flagged as being a draft
*
* @return array $mailsIds Array of mail IDs
*
* @psalm-return list<object>
*/
public function getMailsInfo(array $mailsIds)
{
/** @var list<object>|false */
$mails = $this->imap('fetch_overview', [implode(',', $mailsIds), (SE_UID == $this->imapSearchOption) ? FT_UID : 0]);
if (\is_array($mails) && \count($mails)) {
foreach ($mails as &$mail) {
Expand All @@ -878,7 +888,7 @@ public function getMailsInfo(array $mailsIds)
}
}

/** @var array */
/** @var list<object> */
return $mails;
}

Expand Down Expand Up @@ -1195,6 +1205,8 @@ public function getMail($mailId, $markAsSeen = true)
* @param bool $markAsSeen
* @param bool $emlParse
*
* @return void
*
* @todo flesh out shape of $partStructure
*/
protected function initMailPart(IncomingMail $mail, $partStructure, $partNum, $markAsSeen = true, $emlParse = false)
Expand Down Expand Up @@ -1256,7 +1268,7 @@ protected function initMailPart(IncomingMail $mail, $partStructure, $partNum, $m
&& (TYPEMULTIPART !== $partStructure->type
&& (TYPETEXT !== $partStructure->type || !\in_array(strtolower($partStructure->subtype), ['plain', 'html'])))
) {
return false;
return;
}

if ($isAttachment) {
Expand Down Expand Up @@ -1731,6 +1743,8 @@ protected function possiblyGetHostNameAndAddress($t)

/**
* @return void
*
* @todo revisit redundant condition issues pending fix of https://github.com/vimeo/psalm/issues/2626
*/
protected function pingOrDisconnect()
{
Expand Down

0 comments on commit b01369f

Please sign in to comment.