More params and returns to PHP 7.3+

This commit is contained in:
djmaze 2020-03-16 13:08:53 +01:00
parent 3d246ae842
commit 26c38b3ec9
95 changed files with 1028 additions and 4865 deletions

View file

@ -40,10 +40,7 @@ class Attachment
$this->Clear();
}
/**
* @return \MailSo\Mail\Attachment
*/
public function Clear()
public function Clear() : self
{
$this->sFolder = '';
$this->iUid = 0;
@ -52,36 +49,22 @@ class Attachment
return $this;
}
/**
* @return string
*/
public function Folder()
public function Folder() : string
{
return $this->sFolder;
}
/**
* @return int
*/
public function Uid()
public function Uid() : int
{
return $this->iUid;
}
/**
* @return string
*/
public function MimeIndex()
public function MimeIndex() : string
{
return $this->oBodyStructure ? $this->oBodyStructure->PartID() : '';
}
/**
* @param bool $bCalculateOnEmpty = false
*
* @return string
*/
public function FileName($bCalculateOnEmpty = false)
public function FileName(bool $bCalculateOnEmpty = false) : string
{
$sFileName = '';
if ($this->oBodyStructure)
@ -108,128 +91,77 @@ class Attachment
return $sFileName;
}
/**
* @return string
*/
public function MimeType()
public function MimeType() : string
{
return $this->oBodyStructure ? $this->oBodyStructure->ContentType() : '';
}
/**
* @return string
*/
public function ContentTransferEncoding()
public function ContentTransferEncoding() : string
{
return $this->oBodyStructure ? $this->oBodyStructure->MailEncodingName() : '';
}
/**
* @return int
*/
public function EncodedSize()
public function EncodedSize() : int
{
return $this->oBodyStructure ? $this->oBodyStructure->Size() : 0;
}
/**
* @return int
*/
public function EstimatedSize()
public function EstimatedSize() : int
{
return $this->oBodyStructure ? $this->oBodyStructure->EstimatedSize() : 0;
}
/**
* @return string
*/
public function Cid()
public function Cid() : string
{
return $this->oBodyStructure ? $this->oBodyStructure->ContentID() : '';
}
/**
* @return string
*/
public function ContentLocation()
public function ContentLocation() : string
{
return $this->oBodyStructure ? $this->oBodyStructure->ContentLocation() : '';
}
/**
* @return bool
*/
public function IsInline()
public function IsInline() : bool
{
return $this->oBodyStructure ? $this->oBodyStructure->IsInline() : false;
}
/**
* @return bool
*/
public function IsImage()
public function IsImage() : bool
{
return $this->oBodyStructure ? $this->oBodyStructure->IsImage() : false;
}
/**
* @return bool
*/
public function IsArchive()
public function IsArchive() : bool
{
return $this->oBodyStructure ? $this->oBodyStructure->IsArchive() : false;
}
/**
* @return bool
*/
public function IsPdf()
public function IsPdf() : bool
{
return $this->oBodyStructure ? $this->oBodyStructure->IsPdf() : false;
}
/**
* @return bool
*/
public function IsDoc()
public function IsDoc() : bool
{
return $this->oBodyStructure ? $this->oBodyStructure->IsDoc() : false;
}
/**
* @return bool
*/
public function IsPgpSignature()
public function IsPgpSignature() : bool
{
return $this->oBodyStructure ? $this->oBodyStructure->IsPgpSignature() : false;
}
/**
* @return \MailSo\Mail\Attachment
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @param string $sFolder
* @param int $iUid
* @param \MailSo\Imap\BodyStructure $oBodyStructure
* @return \MailSo\Mail\Attachment
*/
public static function NewBodyStructureInstance($sFolder, $iUid, $oBodyStructure)
public static function NewBodyStructureInstance(string $sFolder, int $iUid, \MailSo\Imap\BodyStructure $oBodyStructure) : self
{
return self::NewInstance()->InitByBodyStructure($sFolder, $iUid, $oBodyStructure);
}
/**
* @param string $sFolder
* @param int $iUid
* @param \MailSo\Imap\BodyStructure $oBodyStructure
* @return \MailSo\Mail\Attachment
*/
public function InitByBodyStructure($sFolder, $iUid, $oBodyStructure)
public function InitByBodyStructure(string $sFolder, int $iUid, \MailSo\Imap\BodyStructure $oBodyStructure) : self
{
$this->sFolder = $sFolder;
$this->iUid = $iUid;

View file

@ -17,26 +17,17 @@ namespace MailSo\Mail;
*/
class AttachmentCollection extends \MailSo\Base\Collection
{
/**
* @access protected
*/
protected function __construct()
{
parent::__construct();
}
/**
* @return \MailSo\Mail\AttachmentCollection
*/
public static function NewInstance()
public static function NewInstance() : \MailSo\Mail\AttachmentCollection
{
return new self();
}
/**
* @return int
*/
public function InlineCount()
public function InlineCount() : int
{
$aList = $this->FilterList(function ($oAttachment) {
return $oAttachment && $oAttachment->IsInline();
@ -45,10 +36,7 @@ class AttachmentCollection extends \MailSo\Base\Collection
return \is_array($aList) ? \count($aList) : 0;
}
/**
* @return int
*/
public function NonInlineCount()
public function NonInlineCount() : int
{
$aList = $this->FilterList(function ($oAttachment) {
return $oAttachment && !$oAttachment->IsInline();
@ -57,10 +45,7 @@ class AttachmentCollection extends \MailSo\Base\Collection
return \is_array($aList) ? \count($aList) : 0;
}
/**
* @return array
*/
public function SpecData()
public function SpecData() : array
{
return $this->MapList(function ($oAttachment) {
if ($oAttachment)

View file

@ -48,152 +48,97 @@ class Folder
private $oSubFolders;
/**
* @access private
*
* @param \MailSo\Imap\Folder $oImapFolder
* @param bool $bSubscribed = true
* @param bool $bExisten = true
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
private function __construct($oImapFolder, $bSubscribed = true, $bExisten = true)
private function __construct(\MailSo\Imap\Folder $oImapFolder, bool $bSubscribed = true, bool $bExisten = true)
{
if ($oImapFolder instanceof \MailSo\Imap\Folder)
$this->oImapFolder = $oImapFolder;
$this->oSubFolders = null;
$aNames = \explode($this->oImapFolder->Delimiter(), $this->oImapFolder->FullNameRaw());
$this->iNestingLevel = \count($aNames);
$this->sParentFullNameRaw = '';
if (1 < $this->iNestingLevel)
{
$this->oImapFolder = $oImapFolder;
$this->oSubFolders = null;
$aNames = \explode($this->oImapFolder->Delimiter(), $this->oImapFolder->FullNameRaw());
$this->iNestingLevel = \count($aNames);
$this->sParentFullNameRaw = '';
if (1 < $this->iNestingLevel)
{
\array_pop($aNames);
$this->sParentFullNameRaw = \implode($this->oImapFolder->Delimiter(), $aNames);
}
$this->bSubscribed = $bSubscribed;
$this->bExisten = $bExisten;
}
else
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
\array_pop($aNames);
$this->sParentFullNameRaw = \implode($this->oImapFolder->Delimiter(), $aNames);
}
$this->bSubscribed = $bSubscribed;
$this->bExisten = $bExisten;
}
/**
* @param \MailSo\Imap\Folder $oImapFolder
* @param bool $bSubscribed = true
* @param bool $bExisten = true
*
* @return \MailSo\Mail\Folder
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public static function NewInstance($oImapFolder, $bSubscribed = true, $bExisten = true)
public static function NewInstance(\MailSo\Imap\Folder $oImapFolder, bool $bSubscribed = true, bool $bExisten = true) : self
{
return new self($oImapFolder, $bSubscribed, $bExisten);
}
/**
* @param string $sFullNameRaw
* @param string $sDelimiter
*
* @return \MailSo\Mail\Folder
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public static function NewNonExistenInstance($sFullNameRaw, $sDelimiter)
public static function NewNonExistenInstance(string $sFullNameRaw, string $sDelimiter) : self
{
return self::NewInstance(
\MailSo\Imap\Folder::NewInstance($sFullNameRaw, $sDelimiter, array('\NoSelect')), true, false);
}
/**
* @return string
*/
public function Name()
public function Name() : string
{
return \MailSo\Base\Utils::ConvertEncoding($this->NameRaw(),
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP,
\MailSo\Base\Enumerations\Charset::UTF_8);
}
/**
* @return string
*/
public function FullName()
public function FullName() : string
{
return \MailSo\Base\Utils::ConvertEncoding($this->FullNameRaw(),
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP,
\MailSo\Base\Enumerations\Charset::UTF_8);
}
/**
* @return string
*/
public function NameRaw()
public function NameRaw() : string
{
return $this->oImapFolder->NameRaw();
}
/**
* @return string
*/
public function FullNameRaw()
public function FullNameRaw() : string
{
return $this->oImapFolder->FullNameRaw();
}
/**
* @return string
*/
public function ParentFullName()
public function ParentFullName() : string
{
return \MailSo\Base\Utils::ConvertEncoding($this->sParentFullNameRaw,
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP,
\MailSo\Base\Enumerations\Charset::UTF_8);
}
/**
* @return string
*/
public function ParentFullNameRaw()
public function ParentFullNameRaw() : string
{
return $this->sParentFullNameRaw;
}
/**
* @return string
*/
public function Delimiter()
public function Delimiter() : string
{
return $this->oImapFolder->Delimiter();
}
/**
* @return array
*/
public function Flags()
public function Flags() : array
{
return $this->oImapFolder->Flags();
}
/**
* @return array
*/
public function FlagsLowerCase()
public function FlagsLowerCase() : array
{
return $this->oImapFolder->FlagsLowerCase();
}
/**
* @param bool $bCreateIfNull = false
* @return \MailSo\Mail\FolderCollection
*/
public function SubFolders($bCreateIfNull = false)
public function SubFolders(bool $bCreateIfNull = false) : \MailSo\Mail\FolderCollection
{
if ($bCreateIfNull && !$this->oSubFolders)
{
@ -203,18 +148,12 @@ class Folder
return $this->oSubFolders;
}
/**
* @return bool
*/
public function HasSubFolders()
public function HasSubFolders() : bool
{
return $this->oSubFolders && 0 < $this->oSubFolders->Count();
}
/**
* @return bool
*/
public function HasVisibleSubFolders()
public function HasVisibleSubFolders() : bool
{
$sList = array();
if ($this->oSubFolders)
@ -227,26 +166,17 @@ class Folder
return 0 < \count($sList);
}
/**
* @return bool
*/
public function IsSubscribed()
public function IsSubscribed() : bool
{
return $this->bSubscribed;
}
/**
* @return bool
*/
public function IsExists()
public function IsExists() : bool
{
return $this->bExisten;
}
/**
* @return bool
*/
public function IsSelectable()
public function IsSelectable() : bool
{
return $this->IsExists() && $this->oImapFolder->IsSelectable();
}
@ -259,18 +189,12 @@ class Folder
return $this->oImapFolder->GetExtended('STATUS');
}
/**
* @return bool
*/
public function IsInbox()
public function IsInbox() : bool
{
return $this->oImapFolder->IsInbox();
}
/**
* @return int
*/
public function GetFolderListType()
public function GetFolderListType() : int
{
$aFlags = $this->oImapFolder->FlagsLowerCase();
$iListType = \MailSo\Imap\Enumerations\FolderType::USER;

View file

@ -42,9 +42,6 @@ class FolderCollection extends \MailSo\Base\Collection
*/
public $SystemFolders;
/**
* @access protected
*/
protected function __construct()
{
parent::__construct();
@ -56,20 +53,12 @@ class FolderCollection extends \MailSo\Base\Collection
$this->Optimized = false;
}
/**
* @return \MailSo\Mail\FolderCollection
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @param string $sFullNameRaw
*
* @return \MailSo\Mail\Folder|null
*/
public function GetByFullNameRaw($sFullNameRaw)
public function GetByFullNameRaw(string $sFullNameRaw) : ?\MailSo\Mail\Folder
{
$mResult = null;
foreach ($this->aItems as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder)
@ -96,10 +85,7 @@ class FolderCollection extends \MailSo\Base\Collection
return $mResult;
}
/**
* @return int
*/
public function CountRec()
public function CountRec() : int
{
$iResult = $this->Count();
foreach ($this->aItems as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder)
@ -114,18 +100,12 @@ class FolderCollection extends \MailSo\Base\Collection
return $iResult;
}
/**
* @return string
*/
public function GetNamespace()
public function GetNamespace() : string
{
return $this->Namespace;
}
/**
* @return string
*/
public function FindDelimiter()
public function FindDelimiter() : string
{
$sDelimiter = '/';
@ -143,22 +123,14 @@ class FolderCollection extends \MailSo\Base\Collection
return $sDelimiter;
}
/**
* @param string $sNamespace
*
* @return \MailSo\Mail\FolderCollection
*/
public function SetNamespace($sNamespace)
public function SetNamespace(string $sNamespace) : \MailSo\Mail\FolderCollection
{
$this->Namespace = $sNamespace;
return $this;
}
/**
* @param array $aUnsortedMailFolders
*/
public function InitByUnsortedMailFolderArray($aUnsortedMailFolders) : void
public function InitByUnsortedMailFolderArray(array $aUnsortedMailFolders) : void
{
$this->Clear();
@ -193,7 +165,7 @@ class FolderCollection extends \MailSo\Base\Collection
$aAddedFolders[$sNonExistenFolderFullNameRaw] =
Folder::NewNonExistenInstance($sNonExistenFolderFullNameRaw, $sDelimiter);
}
catch (\Exception $oExc)
catch (\Throwable $oExc)
{
unset($oExc);
}
@ -218,12 +190,7 @@ class FolderCollection extends \MailSo\Base\Collection
unset($aSortedByLenImapFolders);
}
/**
* @param \MailSo\Mail\Folder $oMailFolder
*
* @return bool
*/
public function AddWithPositionSearch($oMailFolder)
public function AddWithPositionSearch(\MailSo\Mail\Folder $oMailFolder) : bool
{
$oItemFolder = null;
$bIsAdded = false;

View file

@ -27,9 +27,6 @@ class MailClient
*/
private $oImapClient;
/**
* @access private
*/
private function __construct()
{
$this->oLogger = null;
@ -38,114 +35,77 @@ class MailClient
$this->oImapClient->SetTimeOuts(10, \MailSo\Config::$ImapTimeout);
}
/**
* @return \MailSo\Mail\MailClient
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @return \MailSo\Imap\ImapClient
*/
public function ImapClient()
public function ImapClient() : \MailSo\Imap\ImapClient
{
return $this->oImapClient;
}
/**
* @param string $sServerName
* @param int $iPort = 143
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param string $sClientCert = ""
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Connect($sServerName, $iPort = 143,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bVerifySsl = false, $bAllowSelfSigned = false, $sClientCert = '')
public function Connect(string $sServerName, int $iPort = 143,
int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, bool $bVerifySsl = false, bool $bAllowSelfSigned = false, string $sClientCert = '') : self
{
$this->oImapClient->Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl, $bAllowSelfSigned, $sClientCert);
return $this;
}
/**
* @param string $sLogin
* @param string $sPassword
* @param string $sProxyAuthUser = ''
* @param bool $bUseAuthPlainIfSupported = true
* @param bool $bUseAuthCramMd5IfSupported = true
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\LoginException
*/
public function Login($sLogin, $sPassword, $sProxyAuthUser = '',
$bUseAuthPlainIfSupported = true, $bUseAuthCramMd5IfSupported = true)
public function Login(string $sLogin, string $sPassword, string $sProxyAuthUser = '',
bool $bUseAuthPlainIfSupported = true, bool $bUseAuthCramMd5IfSupported = true) : self
{
$this->oImapClient->Login($sLogin, $sPassword, $sProxyAuthUser, $bUseAuthPlainIfSupported, $bUseAuthCramMd5IfSupported);
return $this;
}
/**
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Net\Exceptions\Exception
*/
public function Logout()
public function Logout() : self
{
$this->oImapClient->Logout();
return $this;
}
/**
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Net\Exceptions\Exception
*/
public function Disconnect()
public function Disconnect() : self
{
$this->oImapClient->Disconnect();
return $this;
}
/**
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Net\Exceptions\Exception
*/
public function LogoutAndDisconnect()
public function LogoutAndDisconnect() : self
{
return $this->Logout()->Disconnect();
}
/**
* @return bool
*/
public function IsConnected()
public function IsConnected() : bool
{
return $this->oImapClient->IsConnected();
}
/**
* @return bool
*/
public function IsLoggined()
public function IsLoggined() : bool
{
return $this->oImapClient->IsLoggined();
}
/**
* @return string
*/
private function getEnvelopeOrHeadersRequestStringForSimpleList()
private function getEnvelopeOrHeadersRequestStringForSimpleList() : string
{
return \MailSo\Imap\Enumerations\FetchType::BuildBodyCustomHeaderRequest(array(
\MailSo\Mime\Enumerations\Header::RETURN_PATH,
@ -163,9 +123,6 @@ class MailClient
), true);
}
/**
* @return string
*/
private function getEnvelopeOrHeadersRequestString()
{
if (\MailSo\Config::$MessageAllHeaders)
@ -207,25 +164,19 @@ class MailClient
}
/**
* @param string $sFolderName
* @param string $sMessageFlag
* @param bool $bSetAction = true
* @param bool $sSkipUnsupportedFlag = false
* @param array $aCustomUids = null
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
* @throws \MailSo\Mail\Exceptions\Exception
*/
public function MessageSetFlagToAll($sFolderName, $sMessageFlag, $bSetAction = true, $sSkipUnsupportedFlag = false, $aCustomUids = null)
public function MessageSetFlagToAll(string $sFolderName, string $sMessageFlag, bool $bSetAction = true, bool $bSkipUnsupportedFlag = false, ?array $aCustomUids = null)
{
$this->oImapClient->FolderSelect($sFolderName);
$oFolderInfo = $this->oImapClient->FolderCurrentInformation();
if (!$oFolderInfo || !$oFolderInfo->IsFlagSupported($sMessageFlag))
{
if (!$sSkipUnsupportedFlag)
if (!$bSkipUnsupportedFlag)
{
throw new \MailSo\Mail\Exceptions\RuntimeException('Message flag "'.$sMessageFlag.'" is not supported.');
}
@ -253,26 +204,19 @@ class MailClient
}
/**
* @param string $sFolderName
* @param array $aIndexRange
* @param bool $bIndexIsUid
* @param string $sMessageFlag
* @param bool $bSetAction = true
* @param bool $sSkipUnsupportedFlag = false
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
* @throws \MailSo\Mail\Exceptions\Exception
*/
public function MessageSetFlag($sFolderName, $aIndexRange, $bIndexIsUid, $sMessageFlag, $bSetAction = true, $sSkipUnsupportedFlag = false)
public function MessageSetFlag(string $sFolderName, array $aIndexRange, bool $bIndexIsUid, string $sMessageFlag, bool $bSetAction = true, bool $bSkipUnsupportedFlag = false)
{
$this->oImapClient->FolderSelect($sFolderName);
$oFolderInfo = $this->oImapClient->FolderCurrentInformation();
if (!$oFolderInfo || !$oFolderInfo->IsFlagSupported($sMessageFlag))
{
if (!$sSkipUnsupportedFlag)
if (!$bSkipUnsupportedFlag)
{
throw new \MailSo\Mail\Exceptions\RuntimeException('Message flag "'.$sMessageFlag.'" is not supported.');
}
@ -290,66 +234,43 @@ class MailClient
}
/**
* @param string $sFolderName
* @param array $aIndexRange
* @param bool $bIndexIsUid
* @param bool $bSetAction = true
* @param bool $sSkipUnsupportedFlag = false
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSetFlagged($sFolderName, $aIndexRange, $bIndexIsUid, $bSetAction = true, $sSkipUnsupportedFlag = false)
public function MessageSetFlagged(string $sFolderName, array $aIndexRange, bool $bIndexIsUid, bool $bSetAction = true, bool $bSkipUnsupportedFlag = false) : void
{
$this->MessageSetFlag($sFolderName, $aIndexRange, $bIndexIsUid,
\MailSo\Imap\Enumerations\MessageFlag::FLAGGED, $bSetAction, $sSkipUnsupportedFlag);
\MailSo\Imap\Enumerations\MessageFlag::FLAGGED, $bSetAction, $bSkipUnsupportedFlag);
}
/**
* @param string $sFolderName
* @param bool $bSetAction = true
* @param array $aCustomUids = null
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSetSeenToAll($sFolderName, $bSetAction = true, $aCustomUids = null)
public function MessageSetSeenToAll(string $sFolderName, bool $bSetAction = true, array $aCustomUids = null) : void
{
$this->MessageSetFlagToAll($sFolderName, \MailSo\Imap\Enumerations\MessageFlag::SEEN, $bSetAction, true, $aCustomUids);
}
/**
* @param string $sFolderName
* @param array $aIndexRange
* @param bool $bIndexIsUid
* @param bool $bSetAction = true
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSetSeen($sFolderName, $aIndexRange, $bIndexIsUid, $bSetAction = true)
public function MessageSetSeen(string $sFolderName, array $aIndexRange, bool $bIndexIsUid, bool $bSetAction = true) : void
{
$this->MessageSetFlag($sFolderName, $aIndexRange, $bIndexIsUid,
\MailSo\Imap\Enumerations\MessageFlag::SEEN, $bSetAction, true);
}
/**
* @param string $sFolderName
* @param int $iIndex
* @param bool $bIndexIsUid = true
* @param \MailSo\Cache\CacheClient $oCacher = null
* @param int $iBodyTextLimit = null
*
* @return \MailSo\Mail\Message|false
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Message($sFolderName, $iIndex, $bIndexIsUid = true, $oCacher = null, $iBodyTextLimit = null)
public function Message(string $sFolderName, int $iIndex, bool $bIndexIsUid = true, ?\MailSo\Cache\CacheClient $oCacher = null, int $iBodyTextLimit = 0) : void
{
if (!\MailSo\Base\Validator::RangeInt($iIndex, 1))
{
@ -370,13 +291,9 @@ class MailClient
$oBodyStructure = $aFetchResponse[0]->GetFetchBodyStructure();
if ($oBodyStructure)
{
$aTextParts = $oBodyStructure->SearchHtmlOrPlainParts();
if (is_array($aTextParts) && 0 < \count($aTextParts))
foreach ($oBodyStructure->SearchHtmlOrPlainParts() as $oPart)
{
foreach ($aTextParts as $oPart)
{
$aBodyPeekMimeIndexes[] = array($oPart->PartID(), $oPart->Size());
}
$aBodyPeekMimeIndexes[] = array($oPart->PartID(), $oPart->Size());
}
$aSignatureParts = $oBodyStructure->SearchByContentType('application/pgp-signature');
@ -404,9 +321,9 @@ class MailClient
foreach ($aBodyPeekMimeIndexes as $aTextMimeData)
{
$sLine = \MailSo\Imap\Enumerations\FetchType::BODY_PEEK.'['.$aTextMimeData[0].']';
if (\is_numeric($iBodyTextLimit) && 0 < $iBodyTextLimit && $iBodyTextLimit < $aTextMimeData[1])
if (0 < $iBodyTextLimit && $iBodyTextLimit < $aTextMimeData[1])
{
$sLine .= '<0.'.((int) $iBodyTextLimit).'>';
$sLine .= "<0.{$iBodyTextLimit}>";
}
$aFetchItems[] = $sLine;
@ -432,24 +349,16 @@ class MailClient
$oMessage = \MailSo\Mail\Message::NewFetchResponseInstance(
$sFolderName, $aFetchResponse[0], $oBodyStructure);
}
return $oMessage;
}
/**
* @param mixed $mCallback
* @param string $sFolderName
* @param int $iIndex
* @param bool $bIndexIsUid = true,
* @param string $sMimeIndex = ''
*
* @return bool
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageMimeStream($mCallback, $sFolderName, $iIndex, $bIndexIsUid = true, $sMimeIndex = '')
public function MessageMimeStream($mCallback, string $sFolderName, int $iIndex, bool $bIndexIsUid = true, string $sMimeIndex = '') : bool
{
if (!is_callable($mCallback))
{
@ -536,19 +445,11 @@ class MailClient
}
/**
* @param string $sFolder
* @param array $aIndexRange
* @param bool $bIndexIsUid
* @param bool $bUseExpunge = true
* @param bool $bExpungeAll = false
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageDelete($sFolder, $aIndexRange, $bIndexIsUid, $bUseExpunge = true, $bExpungeAll = false)
public function MessageDelete(string $sFolder, array $aIndexRange, bool $bIndexIsUid, bool $bUseExpunge = true, bool $bExpungeAll = false) : self
{
if (0 === \strlen($sFolder) || !\is_array($aIndexRange) || 0 === \count($aIndexRange))
{
@ -573,20 +474,11 @@ class MailClient
}
/**
* @param string $sFromFolder
* @param string $sToFolder
* @param array $aIndexRange
* @param bool $bIndexIsUid
* @param bool $bUseMoveSupported = false
* @param bool $bExpungeAll = false
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageMove($sFromFolder, $sToFolder, $aIndexRange, $bIndexIsUid, $bUseMoveSupported = false, $bExpungeAll = false)
public function MessageMove(string $sFromFolder, string $sToFolder, array $aIndexRange, bool $bIndexIsUid, bool $bUseMoveSupported = false, bool $bExpungeAll = false) : self
{
if (0 === \strlen($sFromFolder) || 0 === \strlen($sToFolder) ||
!\is_array($aIndexRange) || 0 === \count($aIndexRange))
@ -613,18 +505,11 @@ class MailClient
}
/**
* @param string $sFromFolder
* @param string $sToFolder
* @param array $aIndexRange
* @param bool $bIndexIsUid
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageCopy($sFromFolder, $sToFolder, $aIndexRange, $bIndexIsUid)
public function MessageCopy(string $sFromFolder, string $sToFolder, array $aIndexRange, bool $bIndexIsUid) : self
{
if (0 === \strlen($sFromFolder) || 0 === \strlen($sToFolder) ||
!\is_array($aIndexRange) || 0 === \count($aIndexRange))
@ -640,12 +525,10 @@ class MailClient
}
/**
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderUnSelect()
public function FolderUnSelect() : self
{
if ($this->oImapClient->IsSelected())
{
@ -657,14 +540,8 @@ class MailClient
/**
* @param resource $rMessageStream
* @param int $iMessageStreamSize
* @param string $sFolderToSave
* @param array $aAppendFlags = null
* @param int $iUid = null
*
* @return \MailSo\Mail\MailClient
*/
public function MessageAppendStream($rMessageStream, $iMessageStreamSize, $sFolderToSave, $aAppendFlags = null, &$iUid = null)
public function MessageAppendStream($rMessageStream, int $iMessageStreamSize, string $sFolderToSave, array $aAppendFlags = null, int &$iUid = null) : self
{
if (!\is_resource($rMessageStream) || 0 === \strlen($sFolderToSave))
{
@ -677,15 +554,7 @@ class MailClient
return $this;
}
/**
* @param string $sMessageFileName
* @param string $sFolderToSave
* @param array $aAppendFlags = null
* @param int &$iUid = null
*
* @return \MailSo\Mail\MailClient
*/
public function MessageAppendFile($sMessageFileName, $sFolderToSave, $aAppendFlags = null, &$iUid = null)
public function MessageAppendFile(string $sMessageFileName, string $sFolderToSave, array $aAppendFlags = null, int &$iUid = null) : self
{
if (!@\is_file($sMessageFileName) || !@\is_readable($sMessageFileName))
{
@ -705,15 +574,8 @@ class MailClient
return $this;
}
/**
* @param string $sFolderName
* @param int $iCount
* @param int $iUnseenCount
* @param string $sUidNext
* @param string $sHighestModSeq
*/
protected function initFolderValues($sFolderName, &$iCount, &$iUnseenCount,
&$sUidNext, &$sHighestModSeq = '') : void
protected function initFolderValues(string $sFolderName, int &$iCount, int &$iUnseenCount,
string &$sUidNext, string &$sHighestModSeq = '') : void
{
$aTypes = array(
\MailSo\Imap\Enumerations\FolderResponseStatus::MESSAGES,
@ -755,10 +617,7 @@ class MailClient
}
}
/**
* @return string
*/
public function GenerateImapClientHash()
public function GenerateImapClientHash() : string
{
return \md5('ImapClientHash/'.
$this->oImapClient->GetLogginedUser().'@'.
@ -767,16 +626,7 @@ class MailClient
);
}
/**
* @param string $sFolder
* @param int $iCount
* @param int $iUnseenCount
* @param string $sUidNext
* @param string $sHighestModSeq = ''
*
* @return string
*/
public function GenerateFolderHash($sFolder, $iCount, $iUnseenCount, $sUidNext, $sHighestModSeq = '')
public function GenerateFolderHash(string $sFolder, int $iCount, int $iUnseenCount, string $sUidNext, string $sHighestModSeq = '') : string
{
$iUnseenCount = 0; // unneccessery
return \md5('FolderHash/'.$sFolder.'-'.$iCount.'-'.$iUnseenCount.'-'.$sUidNext.'-'.
@ -785,14 +635,7 @@ class MailClient
);
}
/**
* @param string $sFolderName
* @param string $sPrevUidNext
* @param string $sCurrentUidNext
*
* @return array
*/
private function getFolderNextMessageInformation($sFolderName, $sPrevUidNext, $sCurrentUidNext)
private function getFolderNextMessageInformation(string $sFolderName, string $sPrevUidNext, string $sCurrentUidNext) : array
{
$aNewMessages = array();
@ -856,17 +699,11 @@ class MailClient
}
/**
* @param string $sFolderName
* @param string $sPrevUidNext = ''
* @param array $aUids = ''
*
* @return string
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderInformation($sFolderName, $sPrevUidNext = '', $aUids = array())
public function FolderInformation(string $sFolderName, string $sPrevUidNext = '', array $aUids = array()) : string
{
$aFlags = array();
@ -925,15 +762,11 @@ class MailClient
}
/**
* @param string $sFolderName
*
* @return string
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderHash($sFolderName)
public function FolderHash(string $sFolderName) : string
{
$iCount = 0;
$iUnseenCount = 0;
@ -946,12 +779,10 @@ class MailClient
}
/**
* @return int
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function InboxUnreadCount()
public function InboxUnreadCount() : int
{
$aFolderStatus = $this->oImapClient->FolderStatus('INBOX', array(
\MailSo\Imap\Enumerations\FolderResponseStatus::UNSEEN
@ -963,21 +794,12 @@ class MailClient
return 0 < $iResult ? $iResult : 0;
}
/**
* @return bool
*/
public function IsGmail()
public function IsGmail() : bool
{
return 'ssl://imap.gmail.com' === \strtolower($this->oImapClient->GetConnectedHost());
}
/**
* @param string $sSearch
* @param bool $bDetectGmail = true
*
* @return string
*/
private function escapeSearchString($sSearch, $bDetectGmail = true)
private function escapeSearchString(string $sSearch, bool $bDetectGmail = true) : string
{
return !\MailSo\Base\Utils::IsAscii($sSearch)
? '{'.\strlen($sSearch).'}'."\r\n".$sSearch : $this->oImapClient->EscapeString($sSearch);
@ -985,13 +807,7 @@ class MailClient
// ? '{'.\strlen($sSearch).'+}'."\r\n".$sSearch : $this->oImapClient->EscapeString($sSearch);
}
/**
* @param string $sDate
* @param int $iTimeZoneOffset
*
* @return int
*/
private function parseSearchDate($sDate, $iTimeZoneOffset)
private function parseSearchDate(string $sDate, int $iTimeZoneOffset) : int
{
$iResult = 0;
if (0 < \strlen($sDate))
@ -1003,12 +819,7 @@ class MailClient
return $iResult;
}
/**
* @param string $sSize
*
* @return int
*/
private function parseFriendlySize($sSize)
private function parseFriendlySize(string $sSize) : int
{
$sSize = preg_replace('/[^0-9bBkKmM]/', '', $sSize);
@ -1039,12 +850,7 @@ class MailClient
return $iResult;
}
/**
* @param string $sSearch
*
* @return array
*/
private function parseSearchString($sSearch)
private function parseSearchString(string $sSearch) : array
{
$aResult = array(
'OTHER' => ''
@ -1163,15 +969,7 @@ class MailClient
return $aResult;
}
/**
* @param string $sSearch
* @param string $sFilter
* @param int $iTimeZoneOffset = 0
* @param bool $bUseCache = true
*
* @return string
*/
private function getImapSearchCriterias($sSearch, $sFilter, $iTimeZoneOffset = 0, &$bUseCache = true)
private function getImapSearchCriterias(string $sSearch, string $sFilter, int $iTimeZoneOffset = 0, bool &$bUseCache = true) : string
{
$bUseCache = true;
$iTimeFilter = 0;
@ -1436,11 +1234,7 @@ class MailClient
return $sCriteriasResult;
}
/**
* @param array $aThreads
* @return array
*/
private function threadArrayMap($aThreads)
private function threadArrayMap(array $aThreads) : array
{
$aNew = array();
foreach ($aThreads as $mItem)
@ -1462,12 +1256,7 @@ class MailClient
return $aNew;
}
/**
* @param array $aThreads
*
* @return array
*/
private function compileThreadArray($aThreads)
private function compileThreadArray(array $aThreads) : array
{
$aResult = array();
foreach ($aThreads as $mItem)
@ -1497,19 +1286,11 @@ class MailClient
}
/**
* @param string $sFolderName
* @param string $sFolderHash
* @param array $aIndexOrUids
* @param \MailSo\Cache\CacheClient $oCacher
* @param bool $bCacheOnly = false
*
* @return array
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageListThreadsMap($sFolderName, $sFolderHash, $aIndexOrUids, $oCacher, $bCacheOnly = false)
public function MessageListThreadsMap(string $sFolderName, string $sFolderHash, array $aIndexOrUids, \MailSo\Cache\CacheClient $oCacher, bool $bCacheOnly = false) : array
{
$iThreadLimit = \MailSo\Config::$LargeThreadLimit;
@ -1696,15 +1477,10 @@ class MailClient
}
/**
* @param \MailSo\Mail\MessageCollection &$oMessageCollection
* @param array $aRequestIndexOrUids
* @param bool $bIndexAsUid
* @param bool $bSimple = false
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageListByRequestIndexOrUids(&$oMessageCollection, $aRequestIndexOrUids, $bIndexAsUid, $bSimple = false)
public function MessageListByRequestIndexOrUids(\MailSo\Mail\MessageCollection $oMessageCollection, array $aRequestIndexOrUids, bool $bIndexAsUid, bool $bSimple = false)
{
if (\is_array($aRequestIndexOrUids) && 0 < \count($aRequestIndexOrUids))
{
@ -1747,11 +1523,9 @@ class MailClient
}
/**
* @return bool
*
* @throws \MailSo\Net\Exceptions\Exception
*/
public function IsThreadsSupported()
public function IsThreadsSupported() : bool
{
return $this->oImapClient->IsSupported('THREAD=REFS') ||
$this->oImapClient->IsSupported('THREAD=REFERENCES') ||
@ -1759,16 +1533,11 @@ class MailClient
}
/**
* @param string $sFolderName
* @param array $aUids
*
* @return \MailSo\Mail\MessageCollection
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageListSimple($sFolderName, $aUids)
public function MessageListSimple(string $sFolderName, array $aUids) : \MailSo\Mail\MessageCollection
{
if (0 === \strlen($sFolderName) || !\MailSo\Base\Validator::NotEmptyArray($aUids))
{
@ -1786,20 +1555,11 @@ class MailClient
}
/**
* @param \MailSo\Cache\CacheClient|null $oCacher
* @param string $sSearch
* @param string $sFilter
* @param string $sFolderName
* @param string $sFolderHash
* @param bool $bUseSortIfSupported = false
*
* @return array
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function GetUids($oCacher, $sSearch, $sFilter, $sFolderName, $sFolderHash, $bUseSortIfSupported = false)
public function GetUids(?\MailSo\Cache\CacheClient $oCacher, string $sSearch, string $sFilter, string $sFolderName, string $sFolderHash, bool $bUseSortIfSupported = false) : array
{
$aResultUids = false;
$bUidsFromCacher = false;
@ -1870,26 +1630,14 @@ class MailClient
}
/**
* @param string $sFolderName
* @param int $iOffset = 0
* @param int $iLimit = 10
* @param string $sSearch = ''
* @param string $sPrevUidNext = ''
* @param \MailSo\Cache\CacheClient|null $oCacher = null
* @param bool $bUseSortIfSupported = false
* @param bool $bUseThreadSortIfSupported = false
* @param bool $bUseESearchOrESortRequest = false
* @param string $sThreadUid = ''
* @param string $sFilter = ''
*
* @return \MailSo\Mail\MessageCollection
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageList($sFolderName, $iOffset = 0, $iLimit = 10, $sSearch = '', $sPrevUidNext = '', $oCacher = null,
$bUseSortIfSupported = false, $bUseThreadSortIfSupported = false, $sThreadUid = '', $sFilter = '')
public function MessageList(string $sFolderName, int $iOffset = 0, int $iLimit = 10,
string $sSearch = '', string $sPrevUidNext = '', ?\MailSo\Cache\CacheClient $oCacher = null,
bool $bUseSortIfSupported = false, bool $bUseThreadSortIfSupported = false,
string $sThreadUid = '', string $sFilter = '')
{
$sFilter = \trim($sFilter);
$sSearch = \trim($sSearch);
@ -2131,21 +1879,12 @@ class MailClient
return $oMessageCollection;
}
/**
* @return array|false
*/
public function Quota()
public function Quota() : array
{
return $this->oImapClient->Quota();
}
/**
* @param string $sFolderName
* @param string $sMessageId
*
* @return int|null
*/
public function FindMessageUidByMessageId($sFolderName, $sMessageId)
public function FindMessageUidByMessageId(string $sFolderName, string $sMessageId) : ?int
{
if (0 === \strlen($sMessageId))
{
@ -2160,13 +1899,7 @@ class MailClient
return \is_array($aUids) && 1 === \count($aUids) && \is_numeric($aUids[0]) ? (int) $aUids[0] : null;
}
/**
* @param array $aMailFoldersHelper
* @param int $iOptimizationLimit = 0
*
* @return array
*/
public function folderListOptimization($aMailFoldersHelper, $iOptimizationLimit = 0)
public function folderListOptimization(array $aMailFoldersHelper, int $iOptimizationLimit = 0) : array
{
// optimization
if (10 < $iOptimizationLimit && \is_array($aMailFoldersHelper) && $iOptimizationLimit < \count($aMailFoldersHelper))
@ -2294,15 +2027,7 @@ class MailClient
return $aMailFoldersHelper;
}
/**
* @param string $sParent = ''
* @param string $sListPattern = '*'
* @param bool $bUseListSubscribeStatus = false
* @param int $iOptimizationLimit = 0
*
* @return \MailSo\Mail\FolderCollection|false
*/
public function Folders($sParent = '', $sListPattern = '*', $bUseListSubscribeStatus = true, $iOptimizationLimit = 0)
public function Folders(string $sParent = '', string $sListPattern = '*', bool $bUseListSubscribeStatus = true, int $iOptimizationLimit = 0) : \MailSo\Mail\FolderCollection
{
$oFolderCollection = false;
@ -2313,7 +2038,7 @@ class MailClient
{
$aSubscribedFolders = $this->oImapClient->FolderSubscribeList($sParent, $sListPattern);
}
catch (\Exception $oException)
catch (\Throwable $oException)
{
unset($oException);
}
@ -2393,16 +2118,9 @@ class MailClient
}
/**
* @param string $sFolderNameInUtf8
* @param string $sFolderParentFullNameRaw = ''
* @param bool $bSubscribeOnCreation = true
* @param string $sDelimiter = ''
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderCreate($sFolderNameInUtf8, $sFolderParentFullNameRaw = '', $bSubscribeOnCreation = true, $sDelimiter = '')
public function FolderCreate(string $sFolderNameInUtf8, string $sFolderParentFullNameRaw = '', bool $bSubscribeOnCreation = true, string $sDelimiter = '') : self
{
if (!\MailSo\Base\Validator::NotEmptyString($sFolderNameInUtf8, true) ||
!\is_string($sFolderParentFullNameRaw))
@ -2455,44 +2173,25 @@ class MailClient
}
/**
* @param string $sPrevFolderFullNameRaw
* @param string $sNextFolderFullNameInUtf
* @param bool $bSubscribeOnMove = true
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderMove($sPrevFolderFullNameRaw, $sNextFolderFullNameInUtf, $bSubscribeOnMove = true)
public function FolderMove(string $sPrevFolderFullNameRaw, string $sNextFolderFullNameInUtf, bool $bSubscribeOnMove = true) : self
{
return $this->folderModify($sPrevFolderFullNameRaw, $sNextFolderFullNameInUtf, false, $bSubscribeOnMove);
}
/**
* @param string $sPrevFolderFullNameRaw
* @param string $sNewTopFolderNameInUtf
* @param bool $bSubscribeOnRename = true
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderRename($sPrevFolderFullNameRaw, $sNewTopFolderNameInUtf, $bSubscribeOnRename = true)
public function FolderRename(string $sPrevFolderFullNameRaw, string $sNewTopFolderNameInUtf, bool $bSubscribeOnRename = true) : self
{
return $this->folderModify($sPrevFolderFullNameRaw, $sNewTopFolderNameInUtf, true, $bSubscribeOnRename);
}
/**
* @param string $sPrevFolderFullNameRaw
* @param string $sNextFolderNameInUtf
* @param bool $bRenameOrMove
* @param bool $bSubscribeOnModify
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function folderModify($sPrevFolderFullNameRaw, $sNextFolderNameInUtf, $bRenameOrMove, $bSubscribeOnModify)
public function folderModify(string $sPrevFolderFullNameRaw, string $sNextFolderNameInUtf, bool $bRenameOrMove, bool $bSubscribeOnModify) : self
{
if (0 === \strlen($sPrevFolderFullNameRaw) || 0 === \strlen($sNextFolderNameInUtf))
{
@ -2559,15 +2258,10 @@ class MailClient
}
/**
* @param string $sFolderFullNameRaw
* @param bool $bUnsubscribeOnDeletion = true
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Mail\Exceptions\RuntimeException
*/
public function FolderDelete($sFolderFullNameRaw, $bUnsubscribeOnDeletion = true)
public function FolderDelete(string $sFolderFullNameRaw, bool $bUnsubscribeOnDeletion = true) : self
{
if (0 === \strlen($sFolderFullNameRaw) || 'INBOX' === $sFolderFullNameRaw)
{
@ -2595,13 +2289,9 @@ class MailClient
}
/**
* @param string $sFolderFullNameRaw
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderClear($sFolderFullNameRaw)
public function FolderClear(string $sFolderFullNameRaw) : self
{
$this->oImapClient->FolderSelect($sFolderFullNameRaw);
@ -2620,14 +2310,9 @@ class MailClient
}
/**
* @param string $sFolderFullNameRaw
* @param bool $bSubscribe
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderSubscribe($sFolderFullNameRaw, $bSubscribe)
public function FolderSubscribe(string $sFolderFullNameRaw, bool $bSubscribe) : self
{
if (0 === \strlen($sFolderFullNameRaw))
{
@ -2640,13 +2325,9 @@ class MailClient
}
/**
* @param \MailSo\Log\Logger $oLogger
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function SetLogger($oLogger)
public function SetLogger(\MailSo\Log\Logger $oLogger) : self
{
if (!($oLogger instanceof \MailSo\Log\Logger))
{

View file

@ -187,18 +187,12 @@ class Message
*/
private $bPgpEncrypted;
/**
* @access private
*/
private function __construct()
{
$this->Clear();
}
/**
* @return \MailSo\Mail\Message
*/
public function Clear()
public function Clear() : \MailSo\Mail\Message
{
$this->sFolder = '';
$this->iUid = 0;
@ -246,332 +240,202 @@ class Message
return $this;
}
/**
* @return \MailSo\Mail\Message
*/
public static function NewInstance()
public static function NewInstance() : \MailSo\Mail\Message
{
return new self();
}
/**
* @return string
*/
public function Plain()
public function Plain() : string
{
return $this->sPlain;
}
/**
* @return string
*/
public function Html()
public function Html() : string
{
return $this->sHtml;
}
/**
* @return string
*/
public function PgpSignature()
public function PgpSignature() : string
{
return $this->sPgpSignature;
}
/**
* @return bool
*/
public function PgpSigned()
public function PgpSigned() : bool
{
return $this->bPgpSigned;
}
/**
* @return bool
*/
public function PgpEncrypted()
public function PgpEncrypted() : bool
{
return $this->bPgpEncrypted;
}
/**
* @param string $sHtml
*
* @retun void
*/
public function SetHtml($sHtml)
public function SetHtml(string $sHtml) : void
{
$this->sHtml = $sHtml;
}
/**
* @return string
*/
public function Folder()
public function Folder() : string
{
return $this->sFolder;
}
/**
* @return int
*/
public function Uid()
public function Uid() : int
{
return $this->iUid;
}
/**
* @return string
*/
public function MessageId()
public function MessageId() : string
{
return $this->sMessageId;
}
/**
* @return string
*/
public function Subject()
public function Subject() : string
{
return $this->sSubject;
}
/**
* @return string
*/
public function ContentType()
public function ContentType() : string
{
return $this->sContentType;
}
/**
* @return int
*/
public function Size()
public function Size() : int
{
return $this->iSize;
}
/**
* @return int
*/
public function InternalTimeStampInUTC()
public function InternalTimeStampInUTC() : int
{
return $this->iInternalTimeStampInUTC;
}
/**
* @return int
*/
public function HeaderTimeStampInUTC()
public function HeaderTimeStampInUTC() : int
{
return $this->iHeaderTimeStampInUTC;
}
/**
* @return string
*/
public function HeaderDate()
public function HeaderDate() : string
{
return $this->sHeaderDate;
}
/**
* @return array
*/
public function Flags()
public function Flags() : array
{
return $this->aFlags;
}
/**
* @return array
*/
public function FlagsLowerCase()
public function FlagsLowerCase() : array
{
return $this->aFlagsLowerCase;
}
/**
* @return \MailSo\Mime\EmailCollection
*/
public function From()
public function From() : \MailSo\Mime\EmailCollection
{
return $this->oFrom;
}
/**
* @return int
*/
public function Sensitivity()
public function Sensitivity() : int
{
return $this->iSensitivity;
}
/**
* @return int
*/
public function Priority()
public function Priority() : int
{
return $this->iPriority;
}
/**
* @return \MailSo\Mime\EmailCollection
*/
public function Sender()
public function Sender() : \MailSo\Mime\EmailCollection
{
return $this->oSender;
}
/**
* @return \MailSo\Mime\EmailCollection
*/
public function ReplyTo()
public function ReplyTo() : \MailSo\Mime\EmailCollection
{
return $this->oReplyTo;
}
/**
* @return \MailSo\Mime\EmailCollection
*/
public function DeliveredTo()
public function DeliveredTo() : \MailSo\Mime\EmailCollection
{
return $this->oDeliveredTo;
}
/**
* @return \MailSo\Mime\EmailCollection
*/
public function To()
public function To() : \MailSo\Mime\EmailCollection
{
return $this->oTo;
}
/**
* @return \MailSo\Mime\EmailCollection
*/
public function Cc()
public function Cc() : \MailSo\Mime\EmailCollection
{
return $this->oCc;
}
/**
* @return \MailSo\Mime\EmailCollection
*/
public function Bcc()
public function Bcc() : \MailSo\Mime\EmailCollection
{
return $this->oBcc;
}
/**
* @return \MailSo\Mail\AttachmentCollection
*/
public function Attachments()
public function Attachments() : \MailSo\Mail\AttachmentCollection
{
return $this->oAttachments;
}
/**
* @return string
*/
public function InReplyTo()
public function InReplyTo() : string
{
return $this->sInReplyTo;
}
/**
* @return string
*/
public function References()
public function References() : string
{
return $this->sReferences;
}
/**
* @return string
*/
public function DeliveryReceipt()
public function DeliveryReceipt() : string
{
return $this->sDeliveryReceipt;
}
/**
* @return string
*/
public function ReadReceipt()
public function ReadReceipt() : string
{
return $this->sReadReceipt;
}
/**
* @return array
*/
public function UnsubsribeLinks()
public function UnsubsribeLinks() : array
{
return $this->aUnsubsribeLinks;
}
/**
* @return string
*/
public function ReadingConfirmation()
public function ReadingConfirmation() : string
{
return $this->ReadReceipt();
}
/**
* @return array | null
*/
public function DraftInfo()
public function DraftInfo() : ?array
{
return $this->aDraftInfo;
}
/**
* @return array
*/
public function Threads()
public function Threads() : array
{
return $this->aThreads;
}
/**
* @param array $aThreads
*/
public function SetThreads($aThreads)
public function SetThreads(array $aThreads)
{
$this->aThreads = \is_array($aThreads) ? $aThreads : array();
}
/**
* @return boole
*/
public function TextPartIsTrimmed()
public function TextPartIsTrimmed() : bool
{
return $this->bTextPartIsTrimmed;
}
/**
* @param string $sFolder
* @param \MailSo\Imap\FetchResponse $oFetchResponse
* @param \MailSo\Imap\BodyStructure $oBodyStructure = null
*
* @return \MailSo\Mail\Message
*/
public static function NewFetchResponseInstance($sFolder, $oFetchResponse, $oBodyStructure = null)
public static function NewFetchResponseInstance(string $sFolder, \MailSo\Imap\FetchResponse $oFetchResponse, ?\MailSo\Imap\BodyStructure $oBodyStructure = null) : \MailSo\Mail\Message
{
return self::NewInstance()->InitByFetchResponse($sFolder, $oFetchResponse, $oBodyStructure);
}
/**
* @param string $sFolder
* @param \MailSo\Imap\FetchResponse $oFetchResponse
* @param \MailSo\Imap\BodyStructure $oBodyStructure = null
*
* @return \MailSo\Mail\Message
*/
public function InitByFetchResponse($sFolder, $oFetchResponse, $oBodyStructure = null)
public function InitByFetchResponse(string $sFolder, \MailSo\Imap\FetchResponse $oFetchResponse, ?\MailSo\Imap\BodyStructure $oBodyStructure = null) : \MailSo\Mail\Message
{
if (!$oBodyStructure)
{
@ -775,7 +639,7 @@ class Message
}
$aTextParts = $oBodyStructure ? $oBodyStructure->SearchHtmlOrPlainParts() : null;
if (\is_array($aTextParts) && 0 < \count($aTextParts))
if ($aTextParts)
{
if (0 === \strlen($sCharset))
{

View file

@ -77,9 +77,6 @@ class MessageCollection extends \MailSo\Base\Collection
*/
public $Filtered;
/**
* @access protected
*/
protected function __construct()
{
parent::__construct();
@ -87,10 +84,7 @@ class MessageCollection extends \MailSo\Base\Collection
$this->Clear();
}
/**
* @return \MailSo\Mail\MessageCollection
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}