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

@ -22,9 +22,6 @@ abstract class Collection
*/
protected $aItems;
/**
* @access protected
*/
protected function __construct()
{
$this->aItems = array();
@ -32,9 +29,8 @@ abstract class Collection
/**
* @param mixed $mItem
* @param bool $bToTop = false
*/
public function Add($mItem, $bToTop = false) : self
public function Add($mItem, bool $bToTop = false) : self
{
if ($bToTop)
{
@ -49,10 +45,9 @@ abstract class Collection
}
/**
* @param array $aItems
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function AddArray($aItems) : self
public function AddArray(array $aItems) : self
{
if (!\is_array($aItems))
{
@ -72,10 +67,7 @@ abstract class Collection
$this->aItems = array();
}
/**
* @return array
*/
public function CloneAsArray()
public function CloneAsArray() : array
{
return $this->aItems;
}
@ -85,10 +77,7 @@ abstract class Collection
return \count($this->aItems);
}
/**
* @return array
*/
public function &GetAsArray()
public function &GetAsArray() : array
{
return $this->aItems;
}
@ -112,9 +101,8 @@ abstract class Collection
/**
* @param mixed $mCallback
* @return array
*/
public function FilterList($mCallback)
public function FilterList($mCallback) : array
{
$aResult = array();
if (\is_callable($mCallback))
@ -149,7 +137,7 @@ abstract class Collection
* @return mixed | null
* @return mixed
*/
public function &GetByIndex($iIndex)
public function &GetByIndex(int $iIndex)
{
$mResult = null;
if (\key_exists($iIndex, $this->aItems))
@ -161,10 +149,9 @@ abstract class Collection
}
/**
* @param array $aItems
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function SetAsArray($aItems)
public function SetAsArray(array $aItems)
{
if (!\is_array($aItems))
{

View file

@ -17,14 +17,8 @@ namespace MailSo\Base;
*/
class Crypt
{
/**
*
* @param string $sString
* @param string $sKey
*
* @return string
*/
public static function XxteaEncrypt($sString, $sKey)
public static function XxteaEncrypt(string $sString, string $sKey) : string
{
if (0 === \strlen($sString))
{
@ -67,13 +61,7 @@ class Crypt
return self::long2str($aV, false);
}
/**
* @param string $sEncriptedString
* @param string $sKey
*
* @return string
*/
public static function XxteaDecrypt($sEncriptedString, $sKey)
public static function XxteaDecrypt(string $sEncriptedString, string $sKey) : string
{
if (0 === \strlen($sEncriptedString))
{
@ -118,13 +106,7 @@ class Crypt
return self::long2str($aV, true);
}
/**
* @param array $aV
* @param array $aW
*
* @return string
*/
private static function long2str($aV, $aW)
private static function long2str(array $aV, array $aW) : string
{
$iLen = \count($aV);
$iN = ($iLen - 1) << 2;
@ -152,13 +134,7 @@ class Crypt
}
}
/**
* @param string $sS
* @param string $sW
*
* @return array
*/
private static function str2long($sS, $sW)
private static function str2long(string $sS, string $sW) : array
{
$aV = \unpack('V*', $sS . \str_repeat("\0", (4 - \strlen($sS) % 4) & 3));
$aV = \array_values($aV);
@ -169,12 +145,7 @@ class Crypt
return $aV;
}
/**
* @param int $iN
*
* @return int
*/
private static function int32($iN)
private static function int32(int $iN) : int
{
while ($iN >= 2147483648)
{

View file

@ -15,21 +15,12 @@ namespace MailSo\Base;
* @category MailSo
* @package Base
*/
class DateTimeHelper
abstract class DateTimeHelper
{
/**
* @access private
*/
private function __construct()
{
}
/**
* @staticvar \DateTimeZone $oDateTimeZone
*
* @return \DateTimeZone
*/
public static function GetUtcTimeZoneObject()
public static function GetUtcTimeZoneObject() : \DateTimeZone
{
static $oDateTimeZone = null;
if (null === $oDateTimeZone)
@ -42,12 +33,8 @@ class DateTimeHelper
/**
* Parse date string formated as "Thu, 10 Jun 2010 08:58:33 -0700 (PDT)"
* RFC2822
*
* @param string $sDateTime
*
* @return int
*/
public static function ParseRFC2822DateString($sDateTime)
public static function ParseRFC2822DateString(string $sDateTime) : int
{
$sDateTime = \trim($sDateTime);
if (empty($sDateTime))
@ -63,12 +50,8 @@ class DateTimeHelper
/**
* Parse date string formated as "10-Jan-2012 01:58:17 -0800"
* IMAP INTERNALDATE Format
*
* @param string $sDateTime
*
* @return int
*/
public static function ParseInternalDateString($sDateTime)
public static function ParseInternalDateString(string $sDateTime) : int
{
$sDateTime = \trim($sDateTime);
if (empty($sDateTime))
@ -87,12 +70,8 @@ class DateTimeHelper
/**
* Parse date string formated as "2011-06-14 23:59:59 +0400"
*
* @param string $sDateTime
*
* @return int
*/
public static function ParseDateStringType1($sDateTime)
public static function ParseDateStringType1(string $sDateTime) : int
{
$sDateTime = \trim($sDateTime);
if (empty($sDateTime))
@ -106,12 +85,8 @@ class DateTimeHelper
/**
* Parse date string formated as "2015-05-08T14:32:18.483-07:00"
*
* @param string $sDateTime
*
* @return int
*/
public static function TryToParseSpecEtagFormat($sDateTime)
public static function TryToParseSpecEtagFormat(string $sDateTime) : int
{
$sDateTime = \trim(\preg_replace('/ \([a-zA-Z0-9]+\)$/', '', \trim($sDateTime)));
$sDateTime = \trim(\preg_replace('/(:[\d]{2})\.[\d]{3}/', '$1', \trim($sDateTime)));
@ -121,12 +96,7 @@ class DateTimeHelper
return \MailSo\Base\DateTimeHelper::ParseDateStringType1($sDateTime);
}
/**
* @param string $sTime
*
* @return int
*/
public static function TimeToSec($sTime)
public static function TimeToSec(string $sTime) : int
{
$iMod = 1;
$sTime = \trim($sTime);

View file

@ -15,23 +15,11 @@ namespace MailSo\Base;
* @category MailSo
* @package Base
*/
class HtmlUtils
abstract class HtmlUtils
{
static $KOS = '@@_KOS_@@';
/**
* @access private
*/
private function __construct()
{
}
/**
* @param \DOMElement $oElement
*
* @return array
*/
public static function GetElementAttributesAsArray($oElement)
public static function GetElementAttributesAsArray(?\DOMElement $oElement) : array
{
$aResult = array();
if ($oElement)
@ -52,12 +40,7 @@ class HtmlUtils
return $aResult;
}
/**
* @param string $sText
*
* @return \DOMDocument|bool
*/
public static function GetDomFromText($sText)
public static function GetDomFromText(string $sText) : \DOMDocument
{
$bState = true;
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_use_internal_errors'))
@ -92,10 +75,7 @@ class HtmlUtils
return $oDom;
}
/**
* @return \DOMDocument
*/
private static function createDOMDocument()
private static function createDOMDocument() : \DOMDocument
{
$oDoc = new \DOMDocument('1.0', 'UTF-8');
$oDoc->encoding = 'UTF-8';
@ -106,12 +86,7 @@ class HtmlUtils
return $oDoc;
}
/**
* @param \DOMDocument|\DOMElement $oElem
*
* @return string
*/
private static function domToString($oElem, $oDom = null)
private static function domToString(\DOMNode $oElem, ?\DOMDocument $oDom = null) : string
{
$sResult = '';
if ($oElem instanceof \DOMDocument)
@ -142,13 +117,7 @@ class HtmlUtils
return \trim($sResult);
}
/**
* @param \DOMDocument $oDom
* @param bool $bWrapByFakeHtmlAndBodyDiv = true
*
* @return string
*/
public static function GetTextFromDom_($oDom, $bWrapByFakeHtmlAndBodyDiv = true)
public static function GetTextFromDom_(\DOMDocument $oDom, bool $bWrapByFakeHtmlAndBodyDiv = true) : string
{
$sResult = '';
@ -201,13 +170,7 @@ class HtmlUtils
return $sResult;
}
/**
* @param \DOMDocument $oDom
* @param bool $bWrapByFakeHtmlAndBodyDiv = true
*
* @return string
*/
public static function GetTextFromDom($oDom, $bWrapByFakeHtmlAndBodyDiv = true)
public static function GetTextFromDom(\DOMDocument $oDom, bool $bWrapByFakeHtmlAndBodyDiv = true)
{
$sResult = '';
@ -251,14 +214,7 @@ class HtmlUtils
return $sResult;
}
/**
* @param string $sHtml
* @param string $sHtmlAttrs = ''
* @param string $sBodyAttrs = ''
*
* @return string
*/
public static function ClearBodyAndHtmlTag($sHtml, &$sHtmlAttrs = '', &$sBodyAttrs = '')
public static function ClearBodyAndHtmlTag(string $sHtml, string &$sHtmlAttrs = '', string &$sBodyAttrs = '') : string
{
$aMatch = array();
if (\preg_match('/<html([^>]+)>/im', $sHtml, $aMatch) && !empty($aMatch[1]))
@ -291,13 +247,7 @@ class HtmlUtils
return $sHtml;
}
/**
* @param string $sHtml
* @param bool $bClearEmpty = true
*
* @return string
*/
public static function FixSchemas($sHtml, $bClearEmpty = true)
public static function FixSchemas(string $sHtml, bool $bClearEmpty = true) : string
{
if ($bClearEmpty)
{
@ -310,12 +260,7 @@ class HtmlUtils
return $sHtml;
}
/**
* @param string $sHtml
*
* @return string
*/
public static function ClearFastTags($sHtml)
public static function ClearFastTags(string $sHtml) : string
{
return \preg_replace(array(
'/<p[^>]*><\/p>/i',
@ -354,9 +299,8 @@ class HtmlUtils
/**
* @param mixed $oDom
* @param bool $bClearStyleAndHead = true
*/
public static function ClearTags(&$oDom, $bClearStyleAndHead = true)
public static function ClearTags(&$oDom, bool $bClearStyleAndHead = true)
{
$aRemoveTags = array(
'svg', 'link', 'base', 'meta', 'title', 'x-script', 'script', 'bgsound', 'keygen', 'source',
@ -402,8 +346,8 @@ class HtmlUtils
/*
// public static function ClearStyleUrlValueParserHelper($oUrlValue, $oRule, $oRuleSet,
// $oElem = null,
// &$bHasExternals = false, &$aFoundCIDs = array(),
// $aContentLocationUrls = array(), &$aFoundedContentLocationUrls = array(),
// &$bHasExternals = false, array &$aFoundCIDs = array(),
// $aContentLocationUrls = array(), array &$aFoundedContentLocationUrls = array(),
// $bDoNotReplaceExternalUrl = false, $fAdditionalExternalFilter = null
// )
// {
@ -496,9 +440,9 @@ class HtmlUtils
// }
// }
//
// public static function ClearStyleSmart($sStyle, $oElement = null,
// &$bHasExternals = false, &$aFoundCIDs = array(),
// $aContentLocationUrls = array(), &$aFoundedContentLocationUrls = array(),
// public static function ClearStyleSmart(string $sStyle, $oElement = null,
// &$bHasExternals = false, array &$aFoundCIDs = array(),
// $aContentLocationUrls = array(), array &$aFoundedContentLocationUrls = array(),
// $bDoNotReplaceExternalUrl = false, $fAdditionalExternalFilter = null,
// $sSelectorPrefix = '')
// {
@ -527,7 +471,7 @@ class HtmlUtils
// $oCssParser = new \Sabberworm\CSS\Parser($sStyle, $oSettings);
// $oCss = $oCssParser->parse();
// }
// catch (\Exception $oEception)
// catch (\Throwable $oEception)
// {
// unset($oEception);
// $mResult = false;
@ -611,7 +555,7 @@ class HtmlUtils
// {
// $mResult = $oCss->render(\Sabberworm\CSS\OutputFormat::createCompact());
// }
// catch (\Exception $oEception)
// catch (\Throwable $oEception)
// {
// unset($oEception);
// $mResult = false;
@ -623,20 +567,10 @@ class HtmlUtils
*/
/**
*
* @param string $sStyle
* @param \DOMElement $oElement
* @param bool $bHasExternals
* @param array $aFoundCIDs
* @param array $aContentLocationUrls
* @param array $aFoundedContentLocationUrls
* @param bool $bDoNotReplaceExternalUrl = false
* @param callback|null $fAdditionalExternalFilter = null
*
* @return string
*/
public static function ClearStyle($sStyle, $oElement, &$bHasExternals, &$aFoundCIDs,
$aContentLocationUrls, &$aFoundedContentLocationUrls, $bDoNotReplaceExternalUrl = false, $fAdditionalExternalFilter = null)
public static function ClearStyle(string $sStyle, \DOMElement $oElement, bool &$bHasExternals, array &$aFoundCIDs,
array $aContentLocationUrls, array &$aFoundedContentLocationUrls, bool $bDoNotReplaceExternalUrl = false, $fAdditionalExternalFilter = null)
{
$sStyle = \trim($sStyle);
$aOutStyles = array();
@ -762,10 +696,7 @@ class HtmlUtils
return \implode(';', $aOutStyles);
}
/**
* @param \DOMDocument $oDom
*/
public static function FindLinksInDOM(&$oDom)
public static function FindLinksInDOM(\DOMDocument $oDom)
{
$aNodes = $oDom->getElementsByTagName('*');
foreach ($aNodes as /* @var $oElement \DOMElement */ $oElement)
@ -854,15 +785,7 @@ class HtmlUtils
unset($aNodes);
}
/**
* @param string $sHtml
* @param bool $bDoNotReplaceExternalUrl = false
* @param bool $bFindLinksInHtml = false
* @param bool $bWrapByFakeHtmlAndBodyDiv = true
*
* @return string
*/
public static function ClearHtmlSimple($sHtml, $bDoNotReplaceExternalUrl = false, $bFindLinksInHtml = false, $bWrapByFakeHtmlAndBodyDiv = true)
public static function ClearHtmlSimple(string $sHtml, bool $bDoNotReplaceExternalUrl = false, bool $bFindLinksInHtml = false, bool $bWrapByFakeHtmlAndBodyDiv = true) : string
{
$bHasExternals = false;
$aFoundCIDs = array();
@ -879,25 +802,14 @@ class HtmlUtils
}
/**
* @param string $sHtml
* @param bool $bHasExternals = false
* @param array $aFoundCIDs = array()
* @param array $aContentLocationUrls = array()
* @param array $aFoundedContentLocationUrls = array()
* @param bool $bDoNotReplaceExternalUrl = false
* @param bool $bFindLinksInHtml = false
* @param callback|null $fAdditionalExternalFilter = null
* @param callback|null $fAdditionalDomReader = null
* @param bool $bTryToDetectHiddenImages = false
* @param bool $bWrapByFakeHtmlAndBodyDiv = true
*
* @return string
*/
public static function ClearHtml($sHtml, &$bHasExternals = false, &$aFoundCIDs = array(),
$aContentLocationUrls = array(), &$aFoundedContentLocationUrls = array(),
$bDoNotReplaceExternalUrl = false, $bFindLinksInHtml = false,
public static function ClearHtml(string $sHtml, bool &$bHasExternals = false, array &$aFoundCIDs = array(),
array $aContentLocationUrls = array(), array &$aFoundedContentLocationUrls = array(),
bool $bDoNotReplaceExternalUrl = false, bool $bFindLinksInHtml = false,
$fAdditionalExternalFilter = null, $fAdditionalDomReader = false,
$bTryToDetectHiddenImages = false, $bWrapByFakeHtmlAndBodyDiv = true)
bool $bTryToDetectHiddenImages = false, bool $bWrapByFakeHtmlAndBodyDiv = true)
{
$sResult = '';
@ -1264,15 +1176,7 @@ class HtmlUtils
return $sResult;
}
/**
* @param string $sHtml
* @param array $aFoundCids = array()
* @param array|null $mFoundDataURL = null
* @param array $aFoundedContentLocationUrls = array()
*
* @return string
*/
public static function BuildHtml($sHtml, &$aFoundCids = array(), &$mFoundDataURL = null, &$aFoundedContentLocationUrls = array())
public static function BuildHtml(string $sHtml, array &$aFoundCids = array(), &$mFoundDataURL = null, array &$aFoundedContentLocationUrls = array()) : string
{
$oDom = \MailSo\Base\HtmlUtils::GetDomFromText($sHtml);
@ -1407,13 +1311,7 @@ class HtmlUtils
'<body>'.$sResult.'</body></html>';
}
/**
* @param string $sText
* @param bool $bLinksWithTargetBlank = true
*
* @return string
*/
public static function ConvertPlainToHtml($sText, $bLinksWithTargetBlank = true)
public static function ConvertPlainToHtml(string $sText, bool $bLinksWithTargetBlank = true) : string
{
$sText = \trim($sText);
if (0 === \strlen($sText))
@ -1495,12 +1393,7 @@ class HtmlUtils
return $sText;
}
/**
* @param string $sText
*
* @return string
*/
public static function ConvertHtmlToPlain($sText)
public static function ConvertHtmlToPlain(string $sText) : string
{
$sText = \trim(\stripslashes($sText));
$sText = \MailSo\Base\Utils::StripSpaces($sText);

View file

@ -30,20 +30,15 @@ class Http
$this->bIsMagicQuotesOn = (bool) @\ini_get('magic_quotes_gpc');
}
/**
* @return \MailSo\Base\Http
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @staticvar \MailSo\Base\Http $oInstance;
*
* @return \MailSo\Base\Http
*/
public static function SingletonInstance()
public static function SingletonInstance() : self
{
static $oInstance = null;
if (null === $oInstance)
@ -54,185 +49,124 @@ class Http
return $oInstance;
}
/**
* @param string $sKey
*
* @return bool
*/
public function HasQuery($sKey)
public function HasQuery(string $sKey) : bool
{
return isset($_GET[$sKey]);
}
/**
* @param string $sKey
* @param mixed $mDefault = null
* @param bool $bClearPercZeroZero = true
*
* @return mixed
*/
public function GetQuery($sKey, $mDefault = null, $bClearPercZeroZero = true)
public function GetQuery(string $sKey, $mDefault = null, bool $bClearPercZeroZero = true)
{
return isset($_GET[$sKey]) ? \MailSo\Base\Utils::StripSlashesValue($_GET[$sKey], $bClearPercZeroZero) : $mDefault;
}
/**
* @return array|null
*/
public function GetQueryAsArray()
public function GetQueryAsArray() : ?array
{
return isset($_GET) && \is_array($_GET) ? \MailSo\Base\Utils::StripSlashesValue($_GET, true) : null;
}
/**
* @param string $sKey
*
* @return bool
*/
public function HasPost($sKey)
public function HasPost(string $sKey) : bool
{
return isset($_POST[$sKey]);
}
/**
* @param string $sKey
* @param mixed $mDefault = null
* @param bool $bClearPercZeroZero = false
*
* @return mixed
*/
public function GetPost($sKey, $mDefault = null, $bClearPercZeroZero = false)
public function GetPost(string $sKey, $mDefault = null, bool $bClearPercZeroZero = false)
{
return isset($_POST[$sKey]) ? \MailSo\Base\Utils::StripSlashesValue($_POST[$sKey], $bClearPercZeroZero) : $mDefault;
}
/**
* @return array|null
*/
public function GetPostAsArray()
public function GetPostAsArray() : ?array
{
return isset($_POST) && \is_array($_POST) ? \MailSo\Base\Utils::StripSlashesValue($_POST, false) : null;
}
/**
* @param string $sKey
*
* @return bool
*/
public function HasRequest($sKey)
public function HasRequest(string $sKey) : bool
{
return isset($_REQUEST[$sKey]);
}
/**
* @param string $sKey
* @param mixed $mDefault = null
*
* @return mixed
*/
public function GetRequest($sKey, $mDefault = null)
public function GetRequest(string $sKey, $mDefault = null)
{
return isset($_REQUEST[$sKey]) ? \MailSo\Base\Utils::StripSlashesValue($_REQUEST[$sKey]) : $mDefault;
}
/**
* @param string $sKey
*
* @return bool
*/
public function HasServer($sKey)
public function HasServer(string $sKey) : bool
{
return isset($_SERVER[$sKey]);
}
/**
* @param string $sKey
* @param mixed $mDefault = null
*
* @return mixed
*/
public function GetServer($sKey, $mDefault = null)
public function GetServer(string $sKey, $mDefault = null)
{
return isset($_SERVER[$sKey]) ? $_SERVER[$sKey] : $mDefault;
}
/**
* @param string $sKey
*
* @return bool
*/
public function HasEnv($sKey)
public function HasEnv(string $sKey) : bool
{
return isset($_ENV[$sKey]);
}
/**
* @param string $sKey
* @param mixed $mDefault = null
*
* @return mixed
*/
public function GetEnv($sKey, $mDefault = null)
public function GetEnv(string $sKey, $mDefault = null)
{
return isset($_ENV[$sKey]) ? $_ENV[$sKey] : $mDefault;
}
/**
* @return string
*/
public function ServerProtocol()
public function ServerProtocol() : string
{
return $this->GetServer('SERVER_PROTOCOL', 'HTTP/1.0');
}
/**
* @return string
*/
public function GetMethod()
public function GetMethod() : string
{
return $this->GetServer('REQUEST_METHOD', '');
}
/**
* @return bool
*/
public function IsPost()
public function IsPost() : bool
{
return ('POST' === $this->GetMethod());
}
/**
* @return bool
*/
public function IsGet()
public function IsGet() : bool
{
return ('GET' === $this->GetMethod());
}
/**
* @return string
*/
public function GetQueryString()
public function GetQueryString() : string
{
return $this->GetServer('QUERY_STRING', '');
}
/**
* @return bool
*/
public function CheckLocalhost($sServer)
public function CheckLocalhost(string $sServer) : bool
{
return \in_array(\strtolower(\trim($sServer)), array(
'localhost', '127.0.0.1', '::1', '::1/128', '0:0:0:0:0:0:0:1'
));
}
/**
* @param string $sValueToCheck = ''
*
* @return bool
*/
public function IsLocalhost($sValueToCheck = '')
public function IsLocalhost(string $sValueToCheck = '') : bool
{
if (empty($sValueToCheck))
{
@ -242,10 +176,7 @@ class Http
return $this->CheckLocalhost($sValueToCheck);
}
/**
* @return string
*/
public function GetRawBody()
public function GetRawBody() : string
{
static $sRawBody = null;
if (null === $sRawBody)
@ -256,12 +187,7 @@ class Http
return $sRawBody;
}
/**
* @param string $sHeader
*
* @return string
*/
public function GetHeader($sHeader)
public function GetHeader(string $sHeader) : string
{
$sServerKey = 'HTTP_'.\strtoupper(\str_replace('-', '_', $sHeader));
$sResultHeader = $this->GetServer($sServerKey, '');
@ -279,22 +205,12 @@ class Http
return $sResultHeader;
}
/**
* @param bool $bCheckProxy = true
*
* @return string
*/
public function GetScheme($bCheckProxy = true)
public function GetScheme(bool $bCheckProxy = true) : string
{
return $this->IsSecure($bCheckProxy) ? 'https' : 'http';
}
/**
* @param bool $bCheckProxy = true
*
* @return bool
*/
public function IsSecure($bCheckProxy = true)
public function IsSecure(bool $bCheckProxy = true) : bool
{
$sHttps = \strtolower($this->GetServer('HTTPS', ''));
if ('on' === $sHttps || ('' === $sHttps && '443' === (string) $this->GetServer('SERVER_PORT', '')))
@ -313,14 +229,7 @@ class Http
return false;
}
/**
* @param bool $bWithRemoteUserData = false
* @param bool $bWithoutWWW = true
* @param bool $bWithoutPort = false
*
* @return string
*/
public function GetHost($bWithRemoteUserData = false, $bWithoutWWW = true, $bWithoutPort = false)
public function GetHost(bool $bWithRemoteUserData = false, bool $bWithoutWWW = true, bool $bWithoutPort = false) : string
{
$sHost = $this->GetServer('HTTP_HOST', '');
if (0 === \strlen($sHost))
@ -350,12 +259,7 @@ class Http
return $sHost;
}
/**
* @param bool $bCheckProxy = false
*
* @return string
*/
public function GetClientIp($bCheckProxy = false)
public function GetClientIp(bool $bCheckProxy = false) : string
{
$sIp = '';
if ($bCheckProxy && null !== $this->GetServer('HTTP_CLIENT_IP', null))
@ -374,20 +278,8 @@ class Http
return $sIp;
}
/**
* @param string $sUrl
* @param array $aPost = array()
* @param string $sCustomUserAgent = 'MailSo Http User Agent (v1)'
* @param int $iCode = 0
* @param \MailSo\Log\Logger $oLogger = null
* @param int $iTimeout = 20
* @param string $sProxy = ''
* @param string $sProxyAuth = ''
*
* @return string|bool
*/
public function SendPostRequest($sUrl, $aPost = array(), $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$iCode = 0,
$oLogger = null, $iTimeout = 20, $sProxy = '', $sProxyAuth = '')
public function SendPostRequest(string $sUrl, array $aPost = array(), string $sCustomUserAgent = 'MailSo Http User Agent (v1)', int &$iCode = 0,
?\MailSo\Log\Logger $oLogger = null, int $iTimeout = 20, string $sProxy = '', string $sProxyAuth = '') : string
{
$aOptions = array(
CURLOPT_URL => $sUrl,
@ -444,14 +336,7 @@ class Http
return $mResult;
}
/**
* @param string $sUrl
* @param array $aOptions
* @param \MailSo\Log\Logger $oLogger = null
*
* @return string
*/
static public function DetectAndHackFollowLocationUrl($sUrl, &$aOptions, $oLogger = null)
static public function DetectAndHackFollowLocationUrl(string $sUrl, array &$aOptions, ?\MailSo\Log\Logger $oLogger = null) : string
{
$sSafeMode = \strtolower(\trim(@\ini_get('safe_mode')));
$bSafeMode = 'on' === $sSafeMode || '1' === $sSafeMode;
@ -535,22 +420,10 @@ class Http
}
/**
* @param string $sUrl
* @param resource $rFile
* @param string $sCustomUserAgent = 'MailSo Http User Agent (v1)'
* @param string $sContentType = ''
* @param int $iCode = 0
* @param \MailSo\Log\Logger $oLogger = null
* @param int $iTimeout = 10
* @param string $sProxy = ''
* @param string $sProxyAuth = ''
* @param array $aHttpHeaders = array()
* @param bool $bFollowLocation = true
*
* @return bool
*/
public function SaveUrlToFile($sUrl, $rFile, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0,
$oLogger = null, $iTimeout = 10, $sProxy = '', $sProxyAuth = '', $aHttpHeaders = array(), $bFollowLocation = true)
public function SaveUrlToFile(string $sUrl, $rFile, string $sCustomUserAgent = 'MailSo Http User Agent (v1)', string &$sContentType = '', int &$iCode = 0,
?\MailSo\Log\Logger $oLogger = null, int $iTimeout = 10, string $sProxy = '', string $sProxyAuth = '', array $aHttpHeaders = array(), bool $bFollowLocation = true) : bool
{
if (null === $sCustomUserAgent)
{
@ -613,7 +486,7 @@ class Http
// }
}
\MailSo\Base\Http::DetectAndHackFollowLocationUrl($sUrl, $aOptions, $oLogger);
static::DetectAndHackFollowLocationUrl($sUrl, $aOptions, $oLogger);
$oCurl = \curl_init();
\curl_setopt_array($oCurl, $aOptions);
@ -640,22 +513,8 @@ class Http
return $bResult;
}
/**
* @param string $sUrl
* @param string $sCustomUserAgent = 'MailSo Http User Agent (v1)'
* @param string $sContentType = ''
* @param int $iCode = 0
* @param \MailSo\Log\Logger $oLogger = null
* @param int $iTimeout = 10
* @param string $sProxy = ''
* @param string $sProxyAuth = ''
* @param array $aHttpHeaders = array()
* @param bool $bFollowLocation = true
*
* @return string|bool
*/
public function GetUrlAsString($sUrl, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0,
$oLogger = null, $iTimeout = 10, $sProxy = '', $sProxyAuth = '', $aHttpHeaders = array(), $bFollowLocation = true)
public function GetUrlAsString(string $sUrl, string $sCustomUserAgent = 'MailSo Http User Agent (v1)', string &$sContentType = '', int &$iCode = 0,
?\MailSo\Log\Logger $oLogger = null, int $iTimeout = 10, string $sProxy = '', string $sProxyAuth = '', array $aHttpHeaders = array(), bool $bFollowLocation = true) : string
{
$rMemFile = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
if ($this->SaveUrlToFile($sUrl, $rMemFile, $sCustomUserAgent, $sContentType, $iCode, $oLogger, $iTimeout, $sProxy, $sProxyAuth, $aHttpHeaders, $bFollowLocation) && \is_resource($rMemFile))
@ -667,14 +526,7 @@ class Http
return false;
}
/**
* @param int $iExpireTime
* @param bool $bSetCacheHeader = true
* @param string $sEtag = ''
*
* @return bool
*/
public function ServerNotModifiedCache($iExpireTime, $bSetCacheHeader = true, $sEtag = '')
public function ServerNotModifiedCache(int $iExpireTime, bool $bSetCacheHeader = true, string $sEtag = '') : bool
{
$bResult = false;
if (0 < $iExpireTime)
@ -725,11 +577,8 @@ class Http
/**
* @staticvar boolean $bCache
* @param string $sEtag
* @param int $iLastModified
* @param int $iExpires
*/
public function ServerUseCache($sEtag, $iLastModified, $iExpires)
public function ServerUseCache(string $sEtag, int $iLastModified, int $iExpires)
{
static $bCache = false;
if (false === $bCache)
@ -742,10 +591,7 @@ class Http
}
}
/**
* @param int $iStatus
*/
public function StatusHeader($iStatus, $sCustomStatusText = '') : void
public function StatusHeader(int $iStatus, string $sCustomStatusText = '') : void
{
$iStatus = (int) $iStatus;
if (99 < $iStatus)
@ -771,27 +617,18 @@ class Http
}
}
/**
* @return string
*/
public function GetPath()
public function GetPath() : string
{
$sUrl = \ltrim(\substr($this->GetServer('SCRIPT_NAME', ''), 0, \strrpos($this->GetServer('SCRIPT_NAME', ''), '/')), '/');
return '' === $sUrl ? '/' : '/'.$sUrl.'/';
}
/**
* @return string
*/
public function GetUrl()
{
return $this->GetServer('REQUEST_URI', '');
}
/**
* @return string
*/
public function GetFullUrl()
public function GetFullUrl() : string
{
return $this->GetScheme().'://'.$this->GetHost(true, false).$this->GetPath();
}

View file

@ -53,9 +53,6 @@ class LinkFinder
*/
private $iOptimizationLimit;
/**
* @access private
*/
private function __construct()
{
$this->iHtmlSpecialCharsFlags = (\defined('ENT_QUOTES') && \defined('ENT_SUBSTITUTE') && \defined('ENT_HTML401'))
@ -71,18 +68,12 @@ class LinkFinder
$this->Clear();
}
/**
* @return \MailSo\Base\LinkFinder
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @return \MailSo\Base\LinkFinder
*/
public function Clear()
public function Clear() : self
{
$this->aPrepearPlainStringUrls = array();
$this->fLinkWrapper = null;
@ -92,12 +83,7 @@ class LinkFinder
return $this;
}
/**
* @param string $sText
*
* @return \MailSo\Base\LinkFinder
*/
public function Text($sText)
public function Text(string $sText) : self
{
$this->sText = $sText;
@ -106,10 +92,8 @@ class LinkFinder
/**
* @param mixed $fLinkWrapper
*
* @return \MailSo\Base\LinkFinder
*/
public function LinkWrapper($fLinkWrapper)
public function LinkWrapper($fLinkWrapper) : self
{
$this->fLinkWrapper = $fLinkWrapper;
@ -118,22 +102,15 @@ class LinkFinder
/**
* @param mixed $fMailWrapper
*
* @return \MailSo\Base\LinkFinder
*/
public function MailWrapper($fMailWrapper)
public function MailWrapper($fMailWrapper) : self
{
$this->fMailWrapper = $fMailWrapper;
return $this;
}
/**
* @param bool $bAddTargetBlank = false
*
* @return \MailSo\Base\LinkFinder
*/
public function UseDefaultWrappers($bAddTargetBlank = false)
public function UseDefaultWrappers(bool $bAddTargetBlank = false) : self
{
$this->fLinkWrapper = function ($sLink) use ($bAddTargetBlank) {
@ -153,12 +130,7 @@ class LinkFinder
return $this;
}
/**
* @param bool $bUseHtmlSpecialChars = true
*
* @return string
*/
public function CompileText($bUseHtmlSpecialChars = true)
public function CompileText(bool $bUseHtmlSpecialChars = true) : string
{
$sText = \substr($this->sText, 0, $this->iOptimizationLimit);
$sSubText = \substr($this->sText, $this->iOptimizationLimit);
@ -189,8 +161,8 @@ class LinkFinder
if (0 < \count($this->aPrepearPlainStringUrls))
{
$aPrepearPlainStringUrls = $this->aPrepearPlainStringUrls;
$sResult = \preg_replace_callback('/'.\preg_quote(\MailSo\Base\LinkFinder::OPEN_LINK, '/').
'([\d]+)'.\preg_quote(\MailSo\Base\LinkFinder::CLOSE_LINK, '/').'/',
$sResult = \preg_replace_callback('/'.\preg_quote(static::OPEN_LINK, '/').
'([\d]+)'.\preg_quote(static::CLOSE_LINK, '/').'/',
function ($aMatches) use ($aPrepearPlainStringUrls) {
$iIndex = (int) $aMatches[1];
return isset($aPrepearPlainStringUrls[$iIndex]) ? $aPrepearPlainStringUrls[$iIndex] : '';
@ -203,12 +175,9 @@ class LinkFinder
}
/**
* @param string $sText
* @param mixed $fWrapper
*
* @return string
*/
private function findLinks($sText, $fWrapper)
private function findLinks(string $sText, $fWrapper) : string
{
$sPattern = '/([\W]|^)((?:https?:\/\/)|(?:svn:\/\/)|(?:git:\/\/)|(?:s?ftps?:\/\/)|(?:www\.))'.
'((\S+?)(\\/)?)((?:&gt;)?|[^\w\=\\/;\(\)\[\]]*?)(?=<|\s|$)/imu';
@ -236,9 +205,9 @@ class LinkFinder
{
$aPrepearPlainStringUrls[] = \stripslashes($sLinkWithWrap);
return $aMatch[1].
\MailSo\Base\LinkFinder::OPEN_LINK.
static::OPEN_LINK.
(\count($aPrepearPlainStringUrls) - 1).
\MailSo\Base\LinkFinder::CLOSE_LINK.
static::CLOSE_LINK.
$aMatch[6];
}
@ -258,12 +227,9 @@ class LinkFinder
}
/**
* @param string $sText
* @param mixed $fWrapper
*
* @return string
*/
private function findMails($sText, $fWrapper)
private function findMails(string $sText, $fWrapper) : string
{
$sPattern = '/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/';
@ -276,9 +242,9 @@ class LinkFinder
if (\is_string($sMailWithWrap) && 0 < \strlen($sMailWithWrap))
{
$aPrepearPlainStringUrls[] = \stripslashes($sMailWithWrap);
return \MailSo\Base\LinkFinder::OPEN_LINK.
return static::OPEN_LINK.
(\count($aPrepearPlainStringUrls) - 1).
\MailSo\Base\LinkFinder::CLOSE_LINK;
static::CLOSE_LINK;
}
return $aMatch[1];
@ -295,4 +261,4 @@ class LinkFinder
return $sText;
}
}
}

View file

@ -59,11 +59,7 @@ class Loader
}
}
/**
* @param string $sName
* @param int $iIncSize = 1
*/
public static function IncStatistic($sName, $iIncSize = 1) : void
public static function IncStatistic(string $sName, int $iIncSize = 1) : void
{
if (self::$StoreStatistic)
{
@ -73,10 +69,9 @@ class Loader
}
/**
* @param string $sName
* @param mixed $mValue
*/
public static function SetStatistic($sName, $mValue) : void
public static function SetStatistic(string $sName, $mValue) : void
{
if (self::$StoreStatistic)
{
@ -85,19 +80,14 @@ class Loader
}
/**
* @param string $sName
*
* @return mixed
*/
public static function GetStatistic($sName)
public static function GetStatistic(string $sName)
{
return self::$StoreStatistic && isset(self::$aSetStatistic[$sName]) ? self::$aSetStatistic[$sName] : null;
}
/**
* @return array|null
*/
public static function Statistic()
public static function Statistic() : ?array
{
$aResult = null;
if (self::$StoreStatistic)

View file

@ -15,20 +15,13 @@ namespace MailSo\Base;
* @category MailSo
* @package Base
*/
class ResourceRegistry
abstract class ResourceRegistry
{
/**
* @var array
*/
public static $Resources = array();
/**
* @access private
*/
private function __construct()
{
}
/**
* @staticvar bool $bInited
*/
@ -39,30 +32,28 @@ class ResourceRegistry
{
$bInited = true;
\register_shutdown_function(function () {
if (\is_array(\MailSo\Base\ResourceRegistry::$Resources))
if (\is_array(static::$Resources))
{
foreach (\array_keys(\MailSo\Base\ResourceRegistry::$Resources) as $sKey)
foreach (\array_keys(static::$Resources) as $sKey)
{
if (\is_resource(\MailSo\Base\ResourceRegistry::$Resources[$sKey]))
if (\is_resource(static::$Resources[$sKey]))
{
\MailSo\Base\Loader::IncStatistic('CloseMemoryResource');
\fclose(\MailSo\Base\ResourceRegistry::$Resources[$sKey]);
\fclose(static::$Resources[$sKey]);
}
\MailSo\Base\ResourceRegistry::$Resources[$sKey] = null;
static::$Resources[$sKey] = null;
}
}
\MailSo\Base\ResourceRegistry::$Resources = array();
static::$Resources = array();
});
}
}
/**
* @param int $iMemoryMaxInMb = 5
*
* @return resource | bool
*/
public static function CreateMemoryResource($iMemoryMaxInMb = 5)
public static function CreateMemoryResource(int $iMemoryMaxInMb = 5)
{
self::regResourcesShutdownFunc();
@ -70,7 +61,7 @@ class ResourceRegistry
if (\is_resource($oResult))
{
\MailSo\Base\Loader::IncStatistic('CreateMemoryResource');
\MailSo\Base\ResourceRegistry::$Resources[(string) $oResult] = $oResult;
static::$Resources[(string) $oResult] = $oResult;
return $oResult;
}
@ -78,11 +69,9 @@ class ResourceRegistry
}
/**
* @param string $sString
*
* @return resource | bool
*/
public static function CreateMemoryResourceFromString($sString)
public static function CreateMemoryResourceFromString(string $sString)
{
$oResult = self::CreateMemoryResource();
if (\is_resource($oResult))
@ -102,11 +91,11 @@ class ResourceRegistry
if (\is_resource($rResource))
{
$sKey = (string) $rResource;
if (isset(\MailSo\Base\ResourceRegistry::$Resources[$sKey]))
if (isset(static::$Resources[$sKey]))
{
\fclose(\MailSo\Base\ResourceRegistry::$Resources[$sKey]);
\MailSo\Base\ResourceRegistry::$Resources[$sKey] = null;
unset(\MailSo\Base\ResourceRegistry::$Resources[$sKey]);
\fclose(static::$Resources[$sKey]);
static::$Resources[$sKey] = null;
unset(static::$Resources[$sKey]);
\MailSo\Base\Loader::IncStatistic('CloseMemoryResource');
}

View file

@ -68,13 +68,7 @@ class Binary
*/
private $sReadEndBuffer;
/**
* @param string $sContentTransferEncoding
* @param bool $bDecode = true
*
* @return string
*/
public static function GetInlineDecodeOrEncodeFunctionName($sContentTransferEncoding, $bDecode = true)
public static function GetInlineDecodeOrEncodeFunctionName(string $sContentTransferEncoding, bool $bDecode = true) : string
{
$sFunctionName = '';
switch (strtolower($sContentTransferEncoding))
@ -92,25 +86,13 @@ class Binary
return $sFunctionName;
}
/**
* @param string $sBodyString
* @param string $sEndBuffer
*
* @return string
*/
public static function InlineNullDecode($sBodyString, &$sEndBuffer)
public static function InlineNullDecode(string $sBodyString, string &$sEndBuffer) : string
{
$sEndBuffer = '';
return $sBodyString;
}
/**
* @param string $sBaseString
* @param string $sEndBuffer
*
* @return string
*/
public static function InlineBase64Decode($sBaseString, &$sEndBuffer)
public static function InlineBase64Decode(string $sBaseString, string &$sEndBuffer) : string
{
$sEndBuffer = '';
$sBaseString = str_replace(array("\r", "\n", "\t"), '', $sBaseString);
@ -124,13 +106,7 @@ class Binary
return \MailSo\Base\Utils::Base64Decode($sBaseString);
}
/**
* @param string $sQuotedPrintableString
* @param string $sEndBuffer
*
* @return string
*/
public static function InlineQuotedPrintableDecode($sQuotedPrintableString, &$sEndBuffer)
public static function InlineQuotedPrintableDecode(string $sQuotedPrintableString, string &$sEndBuffer) : string
{
$sEndBuffer = '';
$sQuotedPrintableLen = strlen($sQuotedPrintableString);
@ -143,13 +119,7 @@ class Binary
return quoted_printable_decode($sQuotedPrintableString);
}
/**
* @param string $sEncodedString
* @param string $sEndBuffer
*
* @return string
*/
public static function InlineConvertDecode($sEncodedString, &$sEndBuffer, $sFromEncoding, $sToEncoding)
public static function InlineConvertDecode(string $sEncodedString, string &$sEndBuffer, string $sFromEncoding, string $sToEncoding) : string
{
$sEndBuffer = '';
$sQuotedPrintableLen = strlen($sEncodedString);
@ -164,10 +134,8 @@ class Binary
/**
* @param resource $rStream
*
* @return bool
*/
public static function IsStreamRemembed($rStream)
public static function IsStreamRemembed($rStream) : bool
{
foreach (self::$aRememberStreams as $rRem)
{
@ -193,14 +161,11 @@ class Binary
/**
* @param resource $rStream
* @param string $sUtilsDecodeOrEncodeFunctionName = null
* @param string $sFromEncoding = null
* @param string $sToEncoding = null
*
* @return resource|bool
*/
public static function CreateStream($rStream,
$sUtilsDecodeOrEncodeFunctionName = null, $sFromEncoding = null, $sToEncoding = null)
string $sUtilsDecodeOrEncodeFunctionName = null, string $sFromEncoding = null, string $sToEncoding = null)
{
if (!in_array(self::STREAM_NAME, stream_get_wrappers()))
{
@ -242,12 +207,7 @@ class Binary
return \fopen(self::STREAM_NAME.'://'.$sHashName, 'rb');
}
/**
* @param string $sPath
*
* @return bool
*/
public function stream_open($sPath)
public function stream_open(string $sPath) : bool
{
$this->iPos = 0;
$this->sBuffer = '';
@ -281,12 +241,7 @@ class Binary
return $bResult;
}
/**
* @param int $iCount
*
* @return string
*/
public function stream_read($iCount)
public function stream_read(int $iCount) : string
{
$sReturn = '';
$sFunctionName = $this->sFunctionName;
@ -354,35 +309,22 @@ class Binary
return false;
}
/**
* @return int
*/
public function stream_write()
public function stream_write() : int
{
return 0;
}
/**
* @return int
*/
public function stream_tell()
public function stream_tell() : int
{
return $this->iPos;
}
/**
* @return bool
*/
public function stream_eof()
public function stream_eof() : bool
{
return 0 === strlen($this->sBuffer) && feof($this->rStream);
}
/**
*
* @return array
*/
public function stream_stat()
public function stream_stat() : array
{
return array(
'dev' => 2,
@ -401,10 +343,7 @@ class Binary
);
}
/**
* @return bool
*/
public function stream_seek()
public function stream_seek() : bool
{
return false;
}

View file

@ -45,11 +45,10 @@ class Literal
/**
* @param resource $rStream
* @param int $iLiteralLen
*
* @return resource|bool
*/
public static function CreateStream($rStream, $iLiteralLen)
public static function CreateStream($rStream, int $iLiteralLen)
{
if (!in_array(self::STREAM_NAME, stream_get_wrappers()))
{
@ -65,12 +64,7 @@ class Literal
return fopen(self::STREAM_NAME.'://'.$sHashName, 'rb');
}
/**
* @param string $sPath
*
* @return bool
*/
public function stream_open($sPath)
public function stream_open(string $sPath) : bool
{
$this->iPos = 0;
$this->iSize = 0;
@ -98,12 +92,7 @@ class Literal
return $bResult;
}
/**
* @param int $iCount
*
* @return string
*/
public function stream_read($iCount)
public function stream_read(int $iCount) : string
{
$sResult = false;
if ($this->iSize < $this->iPos + $iCount)
@ -138,34 +127,22 @@ class Literal
return $sResult;
}
/**
* @return int
*/
public function stream_write()
public function stream_write() : int
{
return 0;
}
/**
* @return int
*/
public function stream_tell()
public function stream_tell() : int
{
return $this->iPos;
}
/**
* @return bool
*/
public function stream_eof()
public function stream_eof() : bool
{
return $this->iPos >= $this->iSize;
}
/**
* @return array
*/
public function stream_stat()
public function stream_stat() : array
{
return array(
'dev' => 2,
@ -184,10 +161,7 @@ class Literal
);
}
/**
* @return bool
*/
public function stream_seek()
public function stream_seek() : bool
{
return false;
}

View file

@ -54,11 +54,9 @@ class SubStreams
private $iPos;
/**
* @param array $aSubStreams
*
* @return resource|bool
*/
public static function CreateStream($aSubStreams)
public static function CreateStream(array $aSubStreams)
{
if (!\in_array(self::STREAM_NAME, \stream_get_wrappers()))
{
@ -91,12 +89,7 @@ class SubStreams
return $nNull;
}
/**
* @param string $sPath
*
* @return bool
*/
public function stream_open($sPath)
public function stream_open(string $sPath) : bool
{
$this->aSubStreams = array();
@ -125,12 +118,7 @@ class SubStreams
return $bResult;
}
/**
* @param int $iCount
*
* @return string
*/
public function stream_read($iCount)
public function stream_read(int $iCount) : string
{
$sReturn = '';
$mCurrentPart = null;
@ -194,34 +182,22 @@ class SubStreams
return false;
}
/**
* @return int
*/
public function stream_write()
public function stream_write() : int
{
return 0;
}
/**
* @return int
*/
public function stream_tell()
public function stream_tell() : int
{
return $this->iPos;
}
/**
* @return bool
*/
public function stream_eof()
public function stream_eof() : bool
{
return $this->bIsEnd;
}
/**
* @return array
*/
public function stream_stat()
public function stream_stat() : array
{
return array(
'dev' => 2,
@ -240,10 +216,7 @@ class SubStreams
);
}
/**
* @return bool
*/
public function stream_seek()
public function stream_seek() : bool
{
return false;
}

View file

@ -42,12 +42,9 @@ class TempFile
}
/**
* @param string $sHash
* @param string $sFileName
*
* @return resource|bool
*/
public static function CreateStream($sHash, &$sFileName = '')
public static function CreateStream(string $sHash, string &$sFileName = '')
{
self::Reg();
@ -55,12 +52,7 @@ class TempFile
return fopen($sFileName, 'r+b');
}
/**
* @param string $sPath
*
* @return bool
*/
public function stream_open($sPath)
public function stream_open(string $sPath) : bool
{
$bResult = false;
$aPath = parse_url($sPath);
@ -91,73 +83,42 @@ class TempFile
return $bResult;
}
/**
* @return bool
*/
public function stream_close()
public function stream_close() : bool
{
return true;
}
/**
* @return bool
*/
public function stream_flush()
public function stream_flush() : bool
{
return fflush($this->rSream);
}
/**
* @param int $iLen
*
* @return string
*/
public function stream_read($iLen)
public function stream_read(int $iLen) : string
{
return fread($this->rSream, $iLen);
}
/**
* @param string $sInputString
*
* @return int
*/
public function stream_write($sInputString)
public function stream_write(string $sInputString) : int
{
return fwrite($this->rSream, $sInputString);
}
/**
* @return int
*/
public function stream_tell()
public function stream_tell() : int
{
return ftell($this->rSream);
}
/**
* @return bool
*/
public function stream_eof()
public function stream_eof() : bool
{
return feof($this->rSream);
}
/**
* @return array
*/
public function stream_stat()
public function stream_stat() : array
{
return fstat($this->rSream);
}
/**
* @param int $iOffset
* @param int $iWhence = SEEK_SET
*
* @return int
*/
public function stream_seek($iOffset, $iWhence = SEEK_SET)
public function stream_seek(int $iOffset, int $iWhence = SEEK_SET) : int
{
return fseek($this->rSream, $iOffset, $iWhence);
}

View file

@ -34,11 +34,10 @@ class Test
private $rReadSream;
/**
* @param string $sRawResponse
*
* @return resource|bool
*/
public static function CreateStream($sRawResponse)
public static function CreateStream(string $sRawResponse)
{
if (!in_array(self::STREAM_NAME, stream_get_wrappers()))
{
@ -58,12 +57,7 @@ class Test
return fopen(self::STREAM_NAME.'://'.$sHashName, 'r+b');
}
/**
* @param string $sPath
*
* @return bool
*/
public function stream_open($sPath)
public function stream_open(string $sPath) : bool
{
$bResult = false;
$aPath = parse_url($sPath);
@ -84,54 +78,32 @@ class Test
return $bResult;
}
/**
* @param int $iCount
*
* @return string
*/
public function stream_read($iCount)
public function stream_read(int $iCount) : string
{
return fread($this->rReadSream, $iCount);
}
/**
* @param string $sInputString
*
* @return int
*/
public function stream_write($sInputString)
public function stream_write(string $sInputString) : int
{
return strlen($sInputString);
}
/**
* @return int
*/
public function stream_tell()
public function stream_tell() : int
{
return ftell($this->rReadSream);
}
/**
* @return bool
*/
public function stream_eof()
public function stream_eof() : bool
{
return feof($this->rReadSream);
}
/**
* @return array
*/
public function stream_stat()
public function stream_stat() : array
{
return fstat($this->rReadSream);
}
/**
* @return bool
*/
public function stream_seek()
public function stream_seek() : bool
{
return false;
}

View file

@ -114,10 +114,7 @@ END;
'.949' => 'euc-kr',
);
/**
* @return string
*/
public static function DetectSystemCharset()
public static function DetectSystemCharset() : string
{
$sResult = '';
$sLocale = @\setlocale(LC_ALL, '');
@ -136,10 +133,7 @@ END;
return $sResult;
}
/**
* @return string
*/
public static function ConvertSystemString($sSrt)
public static function ConvertSystemString(string $sSrt) : string
{
$sSrt = \trim($sSrt);
if (!empty($sSrt) && !static::IsUtf8($sSrt))
@ -159,13 +153,7 @@ END;
return $sSrt;
}
/**
* @param string $sEncoding
* @param bool $bAsciAsUtf8 = false
*
* @return string
*/
public static function NormalizeCharset($sEncoding, $bAsciAsUtf8 = false)
public static function NormalizeCharset(string $sEncoding, bool $bAsciAsUtf8 = false) : string
{
$sEncoding = \strtolower($sEncoding);
@ -214,13 +202,7 @@ END;
return $sEncoding;
}
/**
* @param string $sCharset
* @param string $sValue
*
* @return string
*/
public static function NormalizeCharsetByValue($sCharset, $sValue)
public static function NormalizeCharsetByValue(string $sCharset, string $sValue) : string
{
$sCharset = static::NormalizeCharset($sCharset);
@ -236,12 +218,9 @@ END;
}
/**
* @param string $sFilePath
* @param function $fFileExistsCallback = null
*
* @return string
*/
public static function SmartFileExists($sFilePath, $fFileExistsCallback = null)
public static function SmartFileExists(string $sFilePath, $fFileExistsCallback = null) : string
{
$sFilePath = \str_replace('\\', '/', \trim($sFilePath));
if (!$fFileExistsCallback)
@ -285,26 +264,14 @@ END;
return $sFilePath;
}
/**
* @param string $sCharset
*
* @return bool
*/
public static function ValidateCharsetName($sCharset)
public static function ValidateCharsetName(string $sCharset) : bool
{
$sCharset = \strtolower(static::NormalizeCharset($sCharset));
return 0 < \strlen($sCharset) && (\in_array($sCharset, array(\MailSo\Base\Enumerations\Charset::UTF_7_IMAP)) ||
\in_array($sCharset, static::$SuppostedCharsets));
}
/**
* @param string $sInputString
* @param string $sInputFromEncoding
* @param string $sInputToEncoding
*
* @return string|bool
*/
public static function MbConvertEncoding($sInputString, $sInputFromEncoding, $sInputToEncoding)
public static function MbConvertEncoding(string $sInputString, string $sInputFromEncoding, string $sInputToEncoding) : string
{
static $sMbstringSubCh = null;
if (null === $sMbstringSubCh)
@ -319,14 +286,7 @@ END;
return $sResult;
}
/**
* @param string $sInputString
* @param string $sInputFromEncoding
* @param string $sInputToEncoding
*
* @return string
*/
public static function ConvertEncoding($sInputString, $sInputFromEncoding, $sInputToEncoding)
public static function ConvertEncoding(string $sInputString, string $sInputFromEncoding, string $sInputToEncoding) : string
{
$sResult = $sInputString;
@ -403,12 +363,7 @@ END;
return $sResult;
}
/**
* @param string $sValue
*
* @return bool
*/
public static function IsAscii($sValue)
public static function IsAscii(string $sValue) : bool
{
if ('' === \trim($sValue))
{
@ -418,32 +373,17 @@ END;
return !\preg_match('/[^\x09\x10\x13\x0A\x0D\x20-\x7E]/', $sValue);
}
/**
* @param string $sValue
*
* @return string
*/
public static function StrToLowerIfAscii($sValue)
public static function StrToLowerIfAscii(string $sValue) : string
{
return static::IsAscii($sValue) ? \strtolower($sValue) : $sValue;
}
/**
* @param string $sValue
*
* @return string
*/
public static function StrToUpperIfAscii($sValue)
public static function StrToUpperIfAscii(string $sValue) : string
{
return static::IsAscii($sValue) ? \strtoupper($sValue) : $sValue;
}
/**
* @param string $sValue
*
* @return string
*/
public static function StrMailDomainToLowerIfAscii($sValue)
public static function StrMailDomainToLowerIfAscii(string $sValue) : string
{
$aParts = \explode('@', $sValue, 2);
if (!empty($aParts[1]))
@ -454,35 +394,19 @@ END;
return \implode('@', $aParts);
}
/**
* @param string $sValue
*
* @return string
*/
public static function StripSpaces($sValue)
public static function StripSpaces(string $sValue) : string
{
return static::Trim(
\preg_replace('/[\s]+/u', ' ', $sValue));
}
/**
* @param string $sValue
*
* @return bool
*/
public static function IsUtf8($sValue)
public static function IsUtf8(string $sValue) : bool
{
return (bool) (\function_exists('mb_check_encoding') ?
\mb_check_encoding($sValue, 'UTF-8') : \preg_match('//u', $sValue));
}
/**
* @param int $iSize
* @param int $iRound
*
* @return string
*/
public static function FormatFileSize($iSize, $iRound = 0)
public static function FormatFileSize(int $iSize, int $iRound = 0) : string
{
$aSizes = array('B', 'KB', 'MB');
for ($iIndex = 0; $iSize > 1024 && isset($aSizes[$iIndex + 1]); $iIndex++)
@ -492,13 +416,7 @@ END;
return \round($iSize, $iRound).$aSizes[$iIndex];
}
/**
* @param string $sEncodedValue
* @param string $sEncodeingType
*
* @return string
*/
public static function DecodeEncodingValue($sEncodedValue, $sEncodeingType)
public static function DecodeEncodingValue(string $sEncodedValue, string $sEncodeingType) : string
{
$sResult = $sEncodedValue;
switch (\strtolower($sEncodeingType))
@ -516,24 +434,12 @@ END;
return $sResult;
}
/**
* @param string $sInputValue
*
* @return string
*/
public static function DecodeFlowedFormat($sInputValue)
public static function DecodeFlowedFormat(string $sInputValue) : string
{
return \preg_replace('/ ([\r]?[\n])/m', ' ', $sInputValue);
}
/**
* @param string $sEncodedValue
* @param string $sIncomingCharset = ''
* @param string $sForcedIncomingCharset = ''
*
* @return string
*/
public static function DecodeHeaderValue($sEncodedValue, $sIncomingCharset = '', $sForcedIncomingCharset = '')
public static function DecodeHeaderValue(string $sEncodedValue, string $sIncomingCharset = '', string $sForcedIncomingCharset = '') : string
{
$sValue = $sEncodedValue;
if (0 < \strlen($sIncomingCharset))
@ -646,13 +552,7 @@ END;
return $sValue;
}
/**
* @param string $sIncHeaders
* @param string $aHeadersToRemove = array()
*
* @return string
*/
public static function RemoveHeaderFromHeaders($sIncHeaders, $aHeadersToRemove = array())
public static function RemoveHeaderFromHeaders(string $sIncHeaders, array $aHeadersToRemove = array()) : string
{
$sResultHeaders = $sIncHeaders;
@ -704,13 +604,7 @@ END;
return $sResultHeaders;
}
/**
* @param string $sEncodeType
* @param string $sValue
*
* @return string
*/
public static function EncodeUnencodedValue($sEncodeType, $sValue)
public static function EncodeUnencodedValue(string $sEncodeType, string $sValue) : string
{
$sValue = \trim($sValue);
if (0 < \strlen($sValue) && !static::IsAscii($sValue))
@ -736,13 +630,9 @@ END;
/**
* @unused
*
* @param string $sEncodeType
* @param string $sEncodeCharset
* @param string $sValue
*
* @return string
*/
public static function EncodeHeaderValue($sEncodeType, $sEncodeCharset, $sValue)
public static function EncodeHeaderValue(string $sEncodeType, string $sEncodeCharset, string $sValue) : string
{
$sValue = \trim($sValue);
if (0 < \strlen($sValue) && !static::IsAscii($sValue))
@ -764,16 +654,7 @@ END;
return \trim($sValue);
}
/**
* @param string $sAttrName
* @param string $sValue = 'utf-8'
* @param string $sCharset = ''
* @param string $sLang = ''
* @param int $iLen = 78
*
* @return string|bool
*/
public static function AttributeRfc2231Encode($sAttrName, $sValue, $sCharset = 'utf-8', $sLang = '', $iLen = 1000)
public static function AttributeRfc2231Encode(string $sAttrName, string $sValue, string $sCharset = 'utf-8', string $sLang = '', int $iLen = 1000) : string
{
$sValue = \strtoupper($sCharset).'\''.$sLang.'\''.
\preg_replace_callback('/[\x00-\x20*\'%()<>@,;:\\\\"\/[\]?=\x80-\xFF]/', function ($match) {
@ -806,13 +687,8 @@ END;
return $sAttrName.'*='.$sValue;
}
}
/**
* @param string $sAttrName
* @param string $sValue
*
* @return string
*/
public static function EncodeHeaderUtf8AttributeValue($sAttrName, $sValue)
public static function EncodeHeaderUtf8AttributeValue(string $sAttrName, string $sValue) : string
{
$sAttrName = \trim($sAttrName);
$sValue = \trim($sValue);
@ -836,12 +712,7 @@ END;
return \trim($sValue);
}
/**
* @param string $sEmail
*
* @return string
*/
public static function GetAccountNameFromEmail($sEmail)
public static function GetAccountNameFromEmail(string $sEmail) : string
{
$sResult = '';
if (0 < \strlen($sEmail))
@ -853,12 +724,7 @@ END;
return $sResult;
}
/**
* @param string $sEmail
*
* @return string
*/
public static function GetDomainFromEmail($sEmail)
public static function GetDomainFromEmail(string $sEmail) : string
{
$sResult = '';
if (0 < \strlen($sEmail))
@ -873,12 +739,7 @@ END;
return $sResult;
}
/**
* @param string $sDomain
*
* @return string
*/
public static function GetClearDomainName($sDomain)
public static function GetClearDomainName(string $sDomain) : string
{
$sResultDomain = \preg_replace(
'/^(webmail|email|mail|www|imap4|imap|demo|client|ssl|secure|test|cloud|box|m)\./i',
@ -887,23 +748,13 @@ END;
return false === \strpos($sResultDomain, '.') ? $sDomain : $sResultDomain;
}
/**
* @param string $sFileName
*
* @return string
*/
public static function GetFileExtension($sFileName)
public static function GetFileExtension(string $sFileName) : string
{
$iLast = \strrpos($sFileName, '.');
return false === $iLast ? '' : \strtolower(\substr($sFileName, $iLast + 1));
}
/**
* @param string $sFileName
*
* @return string
*/
public static function MimeContentType($sFileName)
public static function MimeContentType(string $sFileName) : string
{
$sResult = 'application/octet-stream';
$sFileName = \trim(\strtolower($sFileName));
@ -1085,13 +936,7 @@ END;
return $sResult;
}
/**
* @param string $sContentType
* @param string $sFileName
*
* @return string
*/
public static function ContentTypeType($sContentType, $sFileName)
public static function ContentTypeType(string $sContentType, string $sFileName) : string
{
$sResult = '';
$sContentType = \strtolower($sContentType);
@ -1151,12 +996,9 @@ END;
/**
* @staticvar bool $bValidateAction
*
* @param int $iTimeToReset = 15
* @param int $iTimeToAdd = 120
*
* @return bool
*/
public static function ResetTimeLimit($iTimeToReset = 15, $iTimeToAdd = 120)
public static function ResetTimeLimit(int $iTimeToReset = 15, int $iTimeToAdd = 120) : bool
{
$iTime = \time();
if ($iTime < \MailSo\Base\Loader::$InitTime + 5)
@ -1193,12 +1035,7 @@ END;
return false;
}
/**
* @param string $sText
*
* @return string
*/
public static function InlineRebuildStringToJsString($sText)
public static function InlineRebuildStringToJsString(string $sText) : string
{
static $aJsonReplaces = array(
array('\\', "\n", "\t", "\r", '\b', "\f", '"'),
@ -1209,10 +1046,7 @@ END;
\str_replace($aJsonReplaces[0], $aJsonReplaces[1], $sText));
}
/**
* @param array $aInput
*/
public static function ClearArrayUtf8Values(&$aInput)
public static function ClearArrayUtf8Values(array &$aInput)
{
if (\is_array($aInput))
{
@ -1233,11 +1067,8 @@ END;
/**
* @param mixed $mInput
* @param \MailSo\Log\Logger|null $oLogger = null
*
* @return string
*/
public static function Php2js($mInput, $oLogger = null)
public static function Php2js($mInput, ?\MailSo\Log\Logger $oLogger = null) : string
{
static $iOpt = null;
if (null === $iOpt)
@ -1283,46 +1114,26 @@ END;
return $sResult;
}
/**
* @param string $sFileName
*
* @return string
*/
public static function ClearFileName($sFileName)
public static function ClearFileName(string $sFileName) : string
{
return static::Trim(static::ClearNullBite(
static::StripSpaces(
\str_replace(array('"', '/', '\\', '*', '?', '<', '>', '|', ':'), ' ', $sFileName))));
}
/**
* @param string $sValue
*
* @return string
*/
public static function ClearXss($sValue)
public static function ClearXss(string $sValue) : string
{
return static::Trim(static::ClearNullBite(
\str_replace(array('"', '/', '\\', '*', '?', '<', '>', '|', ':'), ' ', $sValue)));
}
/**
* @param string $sValue
*
* @return string
*/
public static function Trim($sValue)
public static function Trim(string $sValue) : string
{
return \trim(\preg_replace('/^[\x00-\x1F]+/u', '',
\preg_replace('/[\x00-\x1F]+$/u', '', \trim($sValue))));
}
/**
* @param string $sDir
*
* @return bool
*/
public static function RecRmDir($sDir)
public static function RecRmDir(string $sDir) : bool
{
if (@\is_dir($sDir))
{
@ -1349,11 +1160,7 @@ END;
return false;
}
/**
* @param string $sSource
* @param string $sDestination
*/
public static function CopyDir($sSource, $sDestination)
public static function CopyDir(string $sSource, string $sDestination)
{
if (\is_dir($sSource))
{
@ -1387,14 +1194,7 @@ END;
}
}
/**
* @param string $sTempPath
* @param int $iTime2Kill
* @param int $iNow
*
* @return bool
*/
public static function RecTimeDirRemove($sTempPath, $iTime2Kill, $iNow)
public static function RecTimeDirRemove(string $sTempPath, int $iTime2Kill, int $iNow) : bool
{
$iFileCount = 0;
@ -1444,12 +1244,7 @@ END;
return true;
}
/**
* @param string $sTempPath
* @param int $iTime2Kill
* @param int $iNow
*/
public static function TimeFilesRemove($sTempPath, $iTime2Kill, $iNow)
public static function TimeFilesRemove(string $sTempPath, int $iTime2Kill, int $iNow)
{
$bResult = true;
@ -1481,13 +1276,7 @@ END;
return $bResult;
}
/**
* @param string $sUtfString
* @param int $iLength
*
* @return string
*/
public static function Utf8Truncate($sUtfString, $iLength)
public static function Utf8Truncate(string $sUtfString, int $iLength) : string
{
if (\strlen($sUtfString) <= $iLength)
{
@ -1507,13 +1296,7 @@ END;
return '';
}
/**
* @param string $sUtfString
* @param string $sReplaceOn = ''
*
* @return string
*/
public static function Utf8Clear($sUtfString, $sReplaceOn = '')
public static function Utf8Clear(string $sUtfString, string $sReplaceOn = '') : string
{
if ('' === $sUtfString)
{
@ -1539,12 +1322,7 @@ END;
return $sUtfString;
}
/**
* @param string $sUtfString
*
* @return bool
*/
public static function IsRTL($sUtfString)
public static function IsRTL(string $sUtfString) : bool
{
// \x{0591}-\x{05F4} - Hebrew
// \x{0600}-\x{068F} - Arabic
@ -1554,12 +1332,7 @@ END;
return 0 < (int) preg_match('/[\x{0591}-\x{05F4}\x{0600}-\x{068F}\x{0750}-\x{077F}\x{08A0}-\x{08FF}\x{103A0}-\x{103DF}]/u', $sUtfString);
}
/**
* @param string $sString
*
* @return string
*/
public static function Base64Decode($sString)
public static function Base64Decode(string $sString) : string
{
$sResultString = \base64_decode($sString, true);
if (false === $sResultString)
@ -1587,33 +1360,18 @@ END;
return $sResultString;
}
/**
* @param string $sValue
*
* @return string
*/
public static function UrlSafeBase64Encode($sValue)
public static function UrlSafeBase64Encode(string $sValue) : string
{
return \rtrim(\strtr(\base64_encode($sValue), '+/', '-_'), '=');
}
/**
* @param string $sValue
*
* @return string
*/
public static function UrlSafeBase64Decode($sValue)
public static function UrlSafeBase64Decode(string $sValue) : string
{
$sValue = \rtrim(\strtr($sValue, '-_.', '+/='), '=');
return static::Base64Decode(\str_pad($sValue, \strlen($sValue) + (\strlen($sValue) % 4), '=', STR_PAD_RIGHT));
}
/**
* @param string $sSequence
*
* @return array
*/
public static function ParseFetchSequence($sSequence)
public static function ParseFetchSequence(string $sSequence) : array
{
$aResult = array();
$sSequence = \trim($sSequence);
@ -1641,12 +1399,8 @@ END;
return $aResult;
}
/**
* @param array $aSequence
*
* @return string
*/
public static function PrepearFetchSequence($aSequence)
public static function PrepearFetchSequence(array $aSequence) : string
{
$aResult = array();
if (\is_array($aSequence) && 0 < \count($aSequence))
@ -1693,13 +1447,9 @@ END;
}
/**
*
* @param resource $fResource
* @param int $iBufferLen = 8192
*
* @return bool
*/
public static function FpassthruWithTimeLimitReset($fResource, $iBufferLen = 8192)
public static function FpassthruWithTimeLimitReset($fResource, int $iBufferLen = 8192) : bool
{
$bResult = false;
if (\is_resource($fResource))
@ -1725,15 +1475,8 @@ END;
/**
* @param resource $rRead
* @param array $aWrite
* @param int $iBufferLen = 8192
* @param bool $bResetTimeLimit = true
* @param bool $bFixCrLf = false
* @param bool $bRewindOnComplete = false
*
* @return int|bool
*/
public static function MultipleStreamWriter($rRead, $aWrite, $iBufferLen = 8192, $bResetTimeLimit = true, $bFixCrLf = false, $bRewindOnComplete = false)
public static function MultipleStreamWriter($rRead, array $aWrite, int $iBufferLen = 8192, bool $bResetTimeLimit = true, bool $bFixCrLf = false, bool $bRewindOnComplete = false) : int
{
$mResult = false;
if ($rRead && \is_array($aWrite) && 0 < \count($aWrite))
@ -1791,12 +1534,7 @@ END;
return $mResult;
}
/**
* @param string $sUtfModifiedString
*
* @return string
*/
public static function ModifiedToPlainUtf7($sUtfModifiedString)
public static function ModifiedToPlainUtf7(string $sUtfModifiedString) : string
{
$sUtf = '';
$bBase = false;
@ -1840,12 +1578,7 @@ END;
return $sUtf;
}
/**
* @param string $sStr
*
* @return string|bool
*/
public static function Utf7ModifiedToUtf8($sStr)
public static function Utf7ModifiedToUtf8(string $sStr) : string
{
$aArray = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,62, 63,-1,-1,-1,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,
@ -1942,12 +1675,7 @@ END;
return $sResult;
}
/**
* @param string $sStr
*
* @return string|bool
*/
public static function Utf8ToUtf7Modified($sStr)
public static function Utf8ToUtf7Modified(string $sStr) : string
{
$sArray = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S',
'T','U','V','W','X','Y','Z', 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
@ -2087,12 +1815,7 @@ END;
return $sReturn;
}
/**
* @param string|array $mFunctionNameOrNames
*
* @return bool
*/
public static function FunctionExistsAndEnabled($mFunctionNameOrNames)
public static function FunctionExistsAndEnabled($mFunctionNameOrNames) : bool
{
static $aCache = null;
@ -2141,23 +1864,17 @@ END;
return !\in_array($mFunctionNameOrNames, $aCache);
}
/**
* @param string $mValue
*
* @return string
*/
public static function ClearNullBite($mValue)
public static function ClearNullBite($mValue) : string
{
return \str_replace('%00', '', $mValue);
}
/**
* @param mixed $mValue
* @param bool $bClearNullBite = false
*
* @return mixed
*/
public static function StripSlashesValue($mValue, $bClearNullBite = false)
public static function StripSlashesValue($mValue, bool $bClearNullBite = false)
{
static $bIsMagicQuotesOn = null;
if (null === $bIsMagicQuotesOn)
@ -2190,12 +1907,7 @@ END;
return $mValue;
}
/**
* @param string $sStr
*
* @return string
*/
public static function CharsetDetect($sStr)
public static function CharsetDetect(string $sStr) : string
{
$mResult = '';
if (!static::IsAscii($sStr))
@ -2206,35 +1918,19 @@ END;
return \is_string($mResult) && 0 < \strlen($mResult) ? $mResult : '';
}
/**
* @param string $sAdditionalSalt = ''
*
* @return string
*/
public static function Md5Rand($sAdditionalSalt = '')
public static function Md5Rand(string $sAdditionalSalt = '') : string
{
return \md5(\microtime(true).\rand(10000, 99999).
\md5($sAdditionalSalt).\rand(10000, 99999).\microtime(true));
}
/**
* @param string $sAdditionalSalt = ''
*
* @return string
*/
public static function Sha1Rand($sAdditionalSalt = '')
public static function Sha1Rand(string $sAdditionalSalt = '') : string
{
return \sha1(\microtime(true).\rand(10000, 99999).
\sha1($sAdditionalSalt).\rand(10000, 99999).\microtime(true));
}
/**
* @param string $sData
* @param string $sKey
*
* @return string
*/
public static function Hmac($sData, $sKey)
public static function Hmac(string $sData, string $sKey) : string
{
if (\function_exists('hash_hmac'))
{
@ -2254,13 +1950,7 @@ END;
return \md5(($sKey ^ $sOpad).\pack('H*', \md5(($sKey ^ $sIpad).$sData)));
}
/**
* @param string $sDomain
* @param bool $bSimple = false
*
* @return bool
*/
public static function ValidateDomain($sDomain, $bSimple = false)
public static function ValidateDomain(string $sDomain, bool $bSimple = false) : bool
{
$aMatch = array();
if ($bSimple)
@ -2274,20 +1964,12 @@ END;
));
}
/**
* @param string $sIp
*
* @return bool
*/
public static function ValidateIP($sIp)
public static function ValidateIP(string $sIp) : bool
{
return !empty($sIp) && $sIp === @\filter_var($sIp, FILTER_VALIDATE_IP);
}
/**
* @return \Net_IDNA2
*/
private static function idn()
private static function idn() : \Net
{
static $oIdn = null;
if (null === $oIdn)
@ -2300,13 +1982,7 @@ END;
return $oIdn;
}
/**
* @param string $sStr
* @param bool $bLowerIfAscii = false
*
* @return string
*/
public static function IdnToUtf8($sStr, $bLowerIfAscii = false)
public static function IdnToUtf8(string $sStr, bool $bLowerIfAscii = false) : string
{
if (0 < \strlen($sStr) && \preg_match('/(^|\.|@)xn--/i', $sStr))
{
@ -2314,19 +1990,13 @@ END;
{
$sStr = self::idn()->decode($sStr);
}
catch (\Exception $oException) {}
catch (\Throwable $oException) {}
}
return $bLowerIfAscii ? static::StrMailDomainToLowerIfAscii($sStr) : $sStr;
}
/**
* @param string $sStr
* @param bool $bLowerIfAscii = false
*
* @return string
*/
public static function IdnToAscii($sStr, $bLowerIfAscii = false)
public static function IdnToAscii(string $sStr, bool $bLowerIfAscii = false) : string
{
$sStr = $bLowerIfAscii ? static::StrMailDomainToLowerIfAscii($sStr) : $sStr;
@ -2344,19 +2014,13 @@ END;
{
$sDomain = self::idn()->encode($sDomain);
}
catch (\Exception $oException) {}
catch (\Throwable $oException) {}
}
return ('' === $sUser ? '' : $sUser.'@').$sDomain;
}
/**
* @param string $sHash
* @param string $sSalt
*
* @return int
*/
public static function HashToId($sHash, $sSalt = '')
public static function HashToId(string $sHash, string $sSalt = '') : int
{
$sData = $sHash ? @\MailSo\Base\Crypt::XxteaDecrypt(\hex2bin($sHash), \md5($sSalt)) : null;
@ -2369,25 +2033,14 @@ END;
return null;
}
/**
* @param int $iID
* @param string $sSalt
*
* @return string
*/
public static function IdToHash($iID, $sSalt = '')
public static function IdToHash(int $iID, string $sSalt = '') : string
{
return is_int($iID) ?
\bin2hex(\MailSo\Base\Crypt::XxteaEncrypt('id:'.$iID, \md5($sSalt))) : null
;
}
/**
* @param string $sPassword
*
* @return bool
*/
public static function PasswordWeaknessCheck($sPassword)
public static function PasswordWeaknessCheck(string $sPassword) : bool
{
$sPassword = \trim($sPassword);
if (6 > \strlen($sPassword))

View file

@ -17,13 +17,8 @@ namespace MailSo\Base;
*/
class Validator
{
/**
* @param string $sEmail
* @param array $aAllowedInternalDomains = array('localhost')
*
* @return bool
*/
public static function EmailString($sEmail, $aAllowedInternalDomains = array('localhost'))
public static function EmailString(string $sEmail, array $aAllowedInternalDomains = array('localhost')) : bool
{
$bResult = false;
if (\MailSo\Base\Validator::NotEmptyString($sEmail, true))
@ -41,59 +36,31 @@ class Validator
return $bResult;
}
/**
* @param string $sEmail
*
* @return bool
*/
public static function SimpleEmailString($sEmail)
public static function SimpleEmailString(string $sEmail) : bool
{
return \MailSo\Base\Validator::NotEmptyString($sEmail, true) &&
!!\preg_match('/^[a-zA-Z0-9][a-zA-Z0-9\.\+\-_]*@[a-zA-Z0-9][a-zA-Z0-9\.\+\-_]*$/', $sEmail);
}
/**
* @param string $sString
* @param bool $bTrim = false
*
* @return bool
*/
public static function NotEmptyString($sString, $bTrim = false)
public static function NotEmptyString(string $sString, bool $bTrim = false) : bool
{
return \is_string($sString) &&
(0 < \strlen($bTrim ? \trim($sString) : $sString));
}
/**
* @param array $aList
*
* @return bool
*/
public static function NotEmptyArray($aList)
public static function NotEmptyArray(array $aList) : bool
{
return \is_array($aList) && 0 < \count($aList);
}
/**
* @param int $iNumber
* @param int $iMin = null
* @param int $iMax = null
*
* @return bool
*/
public static function RangeInt($iNumber, $iMin = null, $iMax = null)
public static function RangeInt(int $iNumber, int $iMin = null, int $iMax = null) : bool
{
return \is_int($iNumber) &&
(null !== $iMin && $iNumber >= $iMin || null === $iMin) &&
(null !== $iMax && $iNumber <= $iMax || null === $iMax);
}
/**
* @param int $iPort
*
* @return bool
*/
public static function PortInt($iPort)
public static function PortInt(int $iPort) : bool
{
return \MailSo\Base\Validator::RangeInt($iPort, 0, 65535);
}

View file

@ -27,9 +27,6 @@ class CacheClient
*/
private $sCacheIndex;
/**
* @access private
*/
private function __construct()
{
$this->oDriver = null;
@ -41,53 +38,31 @@ class CacheClient
return new self();
}
/**
* @param string $sKey
* @param string $sValue
*/
public function Set($sKey, $sValue) : bool
public function Set(string $sKey, string $sValue) : bool
{
return $this->oDriver ? $this->oDriver->Set($sKey.$this->sCacheIndex, $sValue) : false;
}
/**
* @param string $sKey
*/
public function SetTimer($sKey) : bool
public function SetTimer(string $sKey) : bool
{
return $this->Set($sKey.'/TIMER', time());
}
/**
* @param string $sKey
*/
public function SetLock($sKey) : bool
public function SetLock(string $sKey) : bool
{
return $this->Set($sKey.'/LOCK', '1');
}
/**
* @param string $sKey
*/
public function RemoveLock($sKey) : bool
public function RemoveLock(string $sKey) : bool
{
return $this->Set($sKey.'/LOCK', '0');
}
/**
* @param string $sKey
*/
public function GetLock($sKey) : bool
public function GetLock(string $sKey) : bool
{
return '1' === $this->Get($sKey.'/LOCK');
}
/**
* @param string $sKey
* @param string $bClearAfterGet = false
*
* @return string
*/
public function Get($sKey, $bClearAfterGet = false)
{
$sValue = '';
@ -105,12 +80,7 @@ class CacheClient
return $sValue;
}
/**
* @param string $sKey
*
* @return int
*/
public function GetTimer($sKey)
public function GetTimer(string $sKey) : int
{
$iTimer = 0;
$sValue = $this->Get($sKey.'/TIMER');
@ -122,10 +92,7 @@ class CacheClient
return $iTimer;
}
/**
* @param string $sKey
*/
public function Delete($sKey) : self
public function Delete(string $sKey) : self
{
if ($this->oDriver)
{
@ -135,43 +102,31 @@ class CacheClient
return $this;
}
/**
* @param \MailSo\Cache\DriverInterface $oDriver
*/
public function SetDriver(\MailSo\Cache\DriverInterface $oDriver) : self
public function SetDriver(DriverInterface $oDriver) : self
{
$this->oDriver = $oDriver;
return $this;
}
/**
* @param int $iTimeToClearInHours = 24
*/
public function GC($iTimeToClearInHours = 24) : bool
public function GC(int $iTimeToClearInHours = 24) : bool
{
return $this->oDriver ? $this->oDriver->GC($iTimeToClearInHours) : false;
}
public function IsInited() : bool
{
return $this->oDriver instanceof \MailSo\Cache\DriverInterface;
return $this->oDriver instanceof DriverInterface;
}
/**
* @param string $sCacheIndex
*/
public function SetCacheIndex($sCacheIndex) : self
public function SetCacheIndex(string $sCacheIndex) : self
{
$this->sCacheIndex = 0 < \strlen($sCacheIndex) ? "\x0".$sCacheIndex : '';
return $this;
}
/**
* @param bool $bCache = false
*/
public function Verify($bCache = false) : bool
public function Verify(bool $bCache = false) : bool
{
if ($this->oDriver)
{

View file

@ -65,7 +65,7 @@ class Redis implements \MailSo\Cache\DriverInterface
$this->oRedis = null;
}
}
catch (\Exception $oExc)
catch (\Throwable $oExc)
{
$this->oRedis = null;
unset($oExc);

View file

@ -21,11 +21,7 @@ class Hooks
*/
static $aCallbacks = array();
/**
* @param string $sName
* @param array $aArg
*/
static public function Run($sName, $aArg = array())
static public function Run(string $sName, array $aArg = array())
{
if (isset(\MailSo\Hooks::$aCallbacks[$sName]))
{
@ -37,10 +33,9 @@ class Hooks
}
/**
* @param string $sName
* @param mixed $mCallback
*/
static public function Add($sName, $mCallback)
static public function Add(string $sName, $mCallback)
{
if (\is_callable($mCallback))
{

View file

@ -92,28 +92,9 @@ class BodyStructure
*/
private $aSubParts;
/**
* @access private
*
* @param string $sContentType
* @param string $sCharset
* @param array $aBodyParams
* @param string $sContentID
* @param string $sDescription
* @param string $sMailEncodingName
* @param string $sDisposition
* @param array $aDispositionParams
* @param string $sFileName
* @param string $sLanguage
* @param string $sLocation
* @param int $iSize
* @param int $iTextLineCount
* @param string $sPartID
* @param array $aSubParts
*/
private function __construct($sContentType, $sCharset, $aBodyParams, $sContentID,
$sDescription, $sMailEncodingName, $sDisposition, $aDispositionParams, $sFileName,
$sLanguage, $sLocation, $iSize, $iTextLineCount, $sPartID, $aSubParts)
private function __construct(string $sContentType, string $sCharset, array $aBodyParams, string $sContentID,
string $sDescription, string $sMailEncodingName, string $sDisposition, array $aDispositionParams, string $sFileName,
string $sLanguage, string $sLocation, int $iSize, int $iTextLineCount, string $sPartID, array $aSubParts)
{
$this->sContentType = $sContentType;
$this->sCharset = $sCharset;
@ -241,35 +222,23 @@ class BodyStructure
return 'archive' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
}
/**
* @return bool
*/
public function IsPdf()
public function IsPdf() : bool
{
return 'pdf' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
}
/**
* @return bool
*/
public function IsDoc()
public function IsDoc() : bool
{
return 'doc' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
}
/**
* @return bool
*/
public function IsPgpSignature()
public function IsPgpSignature() : bool
{
return \in_array(\strtolower($this->ContentType()),
array('application/pgp-signature', 'application/pkcs7-signature'));
}
/**
* @return bool
*/
public function IsAttachBodyPart()
public function IsAttachBodyPart() : bool
{
$bResult = (
(null !== $this->sDisposition && 'attachment' === \strtolower($this->sDisposition))
@ -285,10 +254,7 @@ class BodyStructure
return $bResult;
}
/**
* @return bool
*/
public function IsFlowedFormat()
public function IsFlowedFormat() : bool
{
$bResult = !empty($this->aBodyParams['format']) &&
'flowed' === \strtolower(\trim($this->aBodyParams['format']));
@ -301,10 +267,7 @@ class BodyStructure
return $bResult;
}
/**
* @return array|null
*/
public function SearchPlainParts()
public function SearchPlainParts() : array
{
$aReturn = array();
$aParts = $this->SearchByContentType('text/plain');
@ -318,10 +281,7 @@ class BodyStructure
return $aReturn;
}
/**
* @return array|null
*/
public function SearchHtmlParts()
public function SearchHtmlParts() : array
{
$aReturn = array();
$aParts = $this->SearchByContentType('text/html');
@ -337,10 +297,7 @@ class BodyStructure
return $aReturn;
}
/**
* @return \MailSo\Imap\BodyStructure|null
*/
public function SearchInlineEncryptedPart()
public function SearchInlineEncryptedPart() : ?self
{
if ('multipart/encrypted' === \strtolower($this->ContentType()))
{
@ -357,21 +314,13 @@ class BodyStructure
return null;
}
/**
* @return array|null
*/
public function SearchHtmlOrPlainParts()
public function SearchHtmlOrPlainParts() : array
{
$mResult = $this->SearchHtmlParts();
if (null === $mResult || (\is_array($mResult) && 0 === count($mResult)))
{
$mResult = $this->SearchPlainParts();
}
if (null === $mResult || (\is_array($mResult) && 0 === count($mResult)))
$mResult = $this->SearchHtmlParts() ?: $this->SearchPlainParts();
if (!$mResult)
{
$oPart = $this->SearchInlineEncryptedPart();
if ($oPart instanceof \MailSo\Imap\BodyStructure)
if ($oPart instanceof self)
{
$mResult = array($oPart);
}
@ -380,26 +329,10 @@ class BodyStructure
return $mResult;
}
/**
* @return string
*/
public function SearchCharset()
public function SearchCharset() : string
{
$sResult = '';
$mParts = array();
$mHtmlParts = $this->SearchHtmlParts();
$mPlainParts = $this->SearchPlainParts();
if (\is_array($mHtmlParts) && 0 < \count($mHtmlParts))
{
$mParts = \array_merge($mParts, $mHtmlParts);
}
if (\is_array($mPlainParts) && 0 < \count($mPlainParts))
{
$mParts = \array_merge($mParts, $mPlainParts);
}
$mParts = \array_merge($this->SearchHtmlParts(), $this->SearchPlainParts());
foreach ($mParts as $oPart)
{
@ -432,9 +365,8 @@ class BodyStructure
/**
* @param mixed $fCallback
*
* @return array
*/
public function SearchByCallback($fCallback)
public function SearchByCallback($fCallback) : array
{
$aReturn = array();
if (\call_user_func($fCallback, $this))
@ -453,22 +385,14 @@ class BodyStructure
return $aReturn;
}
/**
* @return array
*/
public function SearchAttachmentsParts()
public function SearchAttachmentsParts() : array
{
return $this->SearchByCallback(function ($oItem) {
return $oItem->IsAttachBodyPart();
});
}
/**
* @param string $sContentType
*
* @return array
*/
public function SearchByContentType($sContentType)
public function SearchByContentType(string $sContentType) : array
{
$sContentType = \strtolower($sContentType);
return $this->SearchByCallback(function ($oItem) use ($sContentType) {
@ -476,12 +400,7 @@ class BodyStructure
});
}
/**
* @param string $sMimeIndex
*
* @return \MailSo\Imap\BodyStructure
*/
public function GetPartByMimeIndex($sMimeIndex)
public function GetPartByMimeIndex(string $sMimeIndex) : self
{
$oPart = null;
if (0 < \strlen($sMimeIndex))
@ -507,14 +426,7 @@ class BodyStructure
return $oPart;
}
/**
* @param array $aParams
* @param string $sParamName
* @param string $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8
*
* @return string
*/
private static function decodeAttrParamenter($aParams, $sParamName, $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8)
private static function decodeAttrParamenter(array $aParams, string $sParamName, string $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8) : string
{
$sResult = '';
if (isset($aParams[$sParamName]))
@ -580,13 +492,7 @@ class BodyStructure
return $sResult;
}
/**
* @param array $aBodyStructure
* @param string $sPartID = ''
*
* @return \MailSo\Imap\BodyStructure
*/
public static function NewInstance(array $aBodyStructure, $sPartID = '')
public static function NewInstance(array $aBodyStructure, string $sPartID = '') : self
{
if (!\is_array($aBodyStructure) || 2 > \count($aBodyStructure))
{
@ -892,13 +798,7 @@ class BodyStructure
}
}
/**
* @param array $aBodyStructure
* @param string $sSubPartID
*
* @return \MailSo\Imap\BodyStructure|null
*/
public static function NewInstanceFromRfc822SubPart(array $aBodyStructure, $sSubPartID)
public static function NewInstanceFromRfc822SubPart(array $aBodyStructure, string $sSubPartID) : ?self
{
$oBody = null;
$aBodySubStructure = self::findPartByIndexInArray($aBodyStructure, $sSubPartID);
@ -910,13 +810,7 @@ class BodyStructure
return $oBody;
}
/**
* @param array $aList
* @param string $sPartID
*
* @return array|null
*/
private static function findPartByIndexInArray(array $aList, $sPartID)
private static function findPartByIndexInArray(array $aList, string $sPartID) : ?array
{
$bFind = false;
$aPath = \explode('.', ''.$sPartID);
@ -939,11 +833,9 @@ class BodyStructure
* Returns dict with key="charset" and value="US-ASCII" for array ("CHARSET" "US-ASCII").
* Keys are lowercased (StringDictionary itself does this), values are not altered.
*
* @param array $aList
*
* @return array
*/
private static function getKeyValueListFromArrayList(array $aList)
private static function getKeyValueListFromArrayList(array $aList) : array
{
$aDict = null;
if (0 === \count($aList) % 2)

View file

@ -40,12 +40,7 @@ class FetchType
const GMAIL_THRID = 'X-GM-THRID';
const GMAIL_LABELS = 'X-GM-LABELS';
/**
* @param array $aReturn
*
* @param string|array $mType
*/
private static function addHelper(&$aReturn, $mType)
private static function addHelper(array &$aReturn, $mType)
{
if (\is_string($mType))
{
@ -58,13 +53,7 @@ class FetchType
}
}
/**
* @param array $aHeaders
* @param bool $bPeek = true
*
* @return string
*/
public static function BuildBodyCustomHeaderRequest(array $aHeaders, $bPeek = true)
public static function BuildBodyCustomHeaderRequest(array $aHeaders, bool $bPeek = true) : string
{
$sResult = '';
if (0 < \count($aHeaders))
@ -79,12 +68,7 @@ class FetchType
return $sResult;
}
/**
* @param array $aFetchItems
*
* @return array
*/
public static function ChangeFetchItemsBefourRequest(array $aFetchItems)
public static function ChangeFetchItemsBefourRequest(array $aFetchItems) : array
{
$aReturn = array();
self::addHelper($aReturn, self::UID);

View file

@ -18,10 +18,8 @@ namespace MailSo\Imap\Exceptions;
*/
class NegativeResponseException extends \MailSo\Imap\Exceptions\ResponseException
{
/**
* @return string
*/
public function getAlertFromStatus()
public function getAlertFromStatus() : string
{
$sResult = '';

View file

@ -38,10 +38,7 @@ class FetchResponse
return new self($oImapResponse);
}
/**
* @return array|null
*/
public function GetEnvelope(bool $bForce = false)
public function GetEnvelope(bool $bForce = false) : ?array
{
if (null === $this->aEnvelopeCache || $bForce)
{
@ -60,10 +57,7 @@ class FetchResponse
return self::findEnvelopeIndex($this->GetEnvelope(), $iIndex, $mNullResult);
}
/**
* @return \MailSo\Mime\EmailCollection|null
*/
public function GetFetchEnvelopeEmailCollection(int $iIndex, string $sParentCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1)
public function GetFetchEnvelopeEmailCollection(int $iIndex, string $sParentCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1) : ?\MailSo\Mime\EmailCollection
{
$oResult = null;
$aEmails = $this->GetFetchEnvelopeValue($iIndex, null);
@ -96,10 +90,7 @@ class FetchResponse
return $oResult;
}
/**
* @return \MailSo\Imap\BodyStructure|null
*/
public function GetFetchBodyStructure(string $sRfc822SubMimeIndex = '')
public function GetFetchBodyStructure(string $sRfc822SubMimeIndex = '') : ?BodyStructure
{
$oBodyStructure = null;
$aBodyStructureArray = $this->GetFetchValue(Enumerations\FetchType::BODYSTRUCTURE);
@ -181,7 +172,7 @@ class FetchResponse
return $sReturn;
}
private static function findFetchUidAndSize($aList)
private static function findFetchUidAndSize(array $aList)
{
$bUid = false;
$bSize = false;
@ -189,11 +180,11 @@ class FetchResponse
{
foreach ($aList as $mItem)
{
if (\MailSo\Imap\Enumerations\FetchType::UID === $mItem)
if (Enumerations\FetchType::UID === $mItem)
{
$bUid = true;
}
else if (\MailSo\Imap\Enumerations\FetchType::RFC822_SIZE === $mItem)
else if (Enumerations\FetchType::RFC822_SIZE === $mItem)
{
$bSize = true;
}
@ -208,7 +199,7 @@ class FetchResponse
return (
$oImapResponse
&& true !== $oImapResponse->IsStatusResponse
&& \MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType
&& Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType
&& 3 < count($oImapResponse->ResponseList) && 'FETCH' === $oImapResponse->ResponseList[2]
&& is_array($oImapResponse->ResponseList[3])
);

View file

@ -48,15 +48,9 @@ class Folder
private $aExtended;
/**
* @access private
*
* @param string $sFullNameRaw
* @param string $sDelimiter
* @param array $aFlags
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
private function __construct($sFullNameRaw, $sDelimiter, array $aFlags)
private function __construct(string $sFullNameRaw, string $sDelimiter, array $aFlags)
{
$this->sNameRaw = '';
$this->sFullNameRaw = '';
@ -104,89 +98,60 @@ class Folder
}
/**
* @param string $sFullNameRaw
* @param string $sDelimiter = '.'
* @param array $aFlags = array()
*
* @return \MailSo\Imap\Folder
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public static function NewInstance($sFullNameRaw, $sDelimiter = '.', $aFlags = array())
public static function NewInstance(string $sFullNameRaw, string $sDelimiter = '.', array $aFlags = array()) : self
{
return new self($sFullNameRaw, $sDelimiter, $aFlags);
}
/**
* @return string
*/
public function NameRaw()
public function NameRaw() : string
{
return $this->sNameRaw;
}
/**
* @return string
*/
public function FullNameRaw()
public function FullNameRaw() : string
{
return $this->sFullNameRaw;
}
/**
* @return string | null
*/
public function Delimiter()
public function Delimiter() : string
{
return $this->sDelimiter;
}
/**
* @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 bool
*/
public function IsSelectable()
public function IsSelectable() : bool
{
return !\in_array('\noselect', $this->aFlagsLowerCase);
}
/**
* @return bool
*/
public function IsInbox()
public function IsInbox() : bool
{
return 'INBOX' === \strtoupper($this->sFullNameRaw) || \in_array('\inbox', $this->aFlagsLowerCase);
}
/**
* @param string $sName
* @param mixed $mData
*/
public function SetExtended($sName, $mData)
public function SetExtended(string $sName, $mData)
{
$this->aExtended[$sName] = $mData;
}
/**
* @param string $sName
* @return mixed
*/
public function GetExtended($sName)
public function GetExtended(string $sName)
{
return isset($this->aExtended[$sName]) ? $this->aExtended[$sName] : null;
}

View file

@ -67,13 +67,7 @@ class FolderInformation
*/
public $HighestModSeq;
/**
* @access private
*
* @param string $sFolderName
* @param bool $bIsWritable
*/
private function __construct($sFolderName, $bIsWritable)
private function __construct(string $sFolderName, bool $bIsWritable)
{
$this->FolderName = $sFolderName;
$this->IsWritable = $bIsWritable;
@ -87,23 +81,12 @@ class FolderInformation
$this->HighestModSeq = null;
}
/**
* @param string $sFolderName
* @param bool $bIsWritable
*
* @return \MailSo\Imap\FolderInformation
*/
public static function NewInstance($sFolderName, $bIsWritable)
public static function NewInstance(string $sFolderName, bool $bIsWritable) : self
{
return new self($sFolderName, $bIsWritable);
}
/**
* @param string $sFlag
*
* @return bool
*/
public function IsFlagSupported($sFlag)
public function IsFlagSupported(string $sFlag) : bool
{
return \in_array('\\*', $this->PermanentFlags) ||
\in_array($sFlag, $this->PermanentFlags) ||

View file

@ -87,9 +87,6 @@ class ImapClient extends \MailSo\Net\NetClient
*/
public $__FORCE_SELECT_ON_EXAMINE__;
/**
* @access protected
*/
protected function __construct()
{
parent::__construct();
@ -115,38 +112,25 @@ class ImapClient extends \MailSo\Net\NetClient
@\ini_set('xdebug.max_nesting_level', 500);
}
/**
* @return \MailSo\Imap\ImapClient
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @return string
*/
public function GetLogginedUser()
public function GetLogginedUser() : string
{
return $this->sLogginedUser;
}
/**
* @param string $sServerName
* @param int $iPort = 143
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param bool $bAllowSelfSigned = true
* @param string $sClientCert = ''
*
* @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 = true,
$sClientCert = '') : void
public function Connect(string $sServerName, int $iPort = 143,
int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
bool $bVerifySsl = false, bool $bAllowSelfSigned = true,
string $sClientCert = '') : void
{
$this->aTagTimeouts['*'] = \microtime(true);
@ -181,20 +165,12 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sLogin
* @param string $sPassword
* @param string $sProxyAuthUser = ''
* @param bool $bUseAuthPlainIfSupported = true
* @param bool $bUseAuthCramMd5IfSupported = true
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
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
{
if (!\MailSo\Base\Validator::NotEmptyString($sLogin, true) ||
!\MailSo\Base\Validator::NotEmptyString($sPassword, true))
@ -319,11 +295,9 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Net\Exceptions\Exception
*/
public function Logout()
public function Logout() : self
{
if ($this->bIsLoggined)
{
@ -334,52 +308,38 @@ class ImapClient extends \MailSo\Net\NetClient
return $this;
}
/**
* @return \MailSo\Imap\ImapClient
*/
public function ForceCloseConnection()
public function ForceCloseConnection() : self
{
$this->Disconnect();
return $this;
}
/**
* @return bool
*/
public function IsLoggined()
public function IsLoggined() : bool
{
return $this->IsConnected() && $this->bIsLoggined;
}
/**
* @return bool
*/
public function IsSelected()
public function IsSelected() : bool
{
return $this->IsLoggined() && $this->bIsSelected;
}
/**
* @return array|null
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Capability()
public function Capability() : ?array
{
$this->SendRequestWithCheck('CAPABILITY', array(), true);
return $this->aCapabilityItems;
}
/**
* @param string $sExtentionName
* @return bool
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function IsSupported($sExtentionName)
public function IsSupported(string $sExtentionName) : bool
{
$bResult = \MailSo\Base\Validator::NotEmptyString($sExtentionName, true);
if ($bResult && null === $this->aCapabilityItems)
@ -392,19 +352,17 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @return \MailSo\Imap\NamespaceResult|null
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function GetNamespace()
public function GetNamespace() : ?\MailSo\Imap\NamespaceResult
{
if (!$this->IsSupported('NAMESPACE'))
{
return null;
}
$oReturn = false;
$oReturn = null;
$this->SendRequest('NAMESPACE');
$aResult = $this->parseResponseWithValidation();
@ -421,7 +379,7 @@ class ImapClient extends \MailSo\Net\NetClient
}
}
if (false === $oReturn)
if (!$oReturn)
{
$this->writeLogException(
new \MailSo\Imap\Exceptions\ResponseException(),
@ -432,99 +390,71 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Noop()
public function Noop() : self
{
return $this->SendRequestWithCheck('NOOP');
}
/**
* @param string $sFolderName
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderCreate($sFolderName)
public function FolderCreate(string $sFolderName) : self
{
return $this->SendRequestWithCheck('CREATE',
array($this->EscapeString($sFolderName)));
}
/**
* @param string $sFolderName
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderDelete($sFolderName)
public function FolderDelete(string $sFolderName) : self
{
return $this->SendRequestWithCheck('DELETE',
array($this->EscapeString($sFolderName)));
}
/**
* @param string $sFolderName
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderSubscribe($sFolderName)
public function FolderSubscribe(string $sFolderName) : self
{
return $this->SendRequestWithCheck('SUBSCRIBE',
array($this->EscapeString($sFolderName)));
}
/**
* @param string $sFolderName
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderUnSubscribe($sFolderName)
public function FolderUnSubscribe(string $sFolderName) : self
{
return $this->SendRequestWithCheck('UNSUBSCRIBE',
array($this->EscapeString($sFolderName)));
}
/**
* @param string $sOldFolderName
* @param string $sNewFolderName
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderRename($sOldFolderName, $sNewFolderName)
public function FolderRename(string $sOldFolderName, string $sNewFolderName) : self
{
return $this->SendRequestWithCheck('RENAME', array(
$this->EscapeString($sOldFolderName),
$this->EscapeString($sNewFolderName)));
}
/**
* @param array $aResult
*
* @return array
*/
protected function getStatusFolderInformation($aResult)
protected function getStatusFolderInformation(array $aResult) : array
{
$aReturn = array();
@ -558,16 +488,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sFolderName
* @param array $aStatusItems
*
* @return array|bool
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderStatus($sFolderName, array $aStatusItems)
public function FolderStatus(string $sFolderName, array $aStatusItems) : array
{
$aResult = false;
if (\count($aStatusItems) > 0)
@ -582,14 +507,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $aResult;
}
/**
* @param array $aResult
* @param string $sStatus
* @param bool $bUseListStatus = false
*
* @return array
*/
private function getFoldersFromResult(array $aResult, $sStatus, $bUseListStatus = false)
private function getFoldersFromResult(array $aResult, string $sStatus, bool $bUseListStatus = false) : array
{
$aReturn = array();
@ -686,17 +604,10 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param bool $bIsSubscribeList
* @param string $sParentFolderName = ''
* @param string $sListPattern = '*'
* @param bool $bUseListStatus = false
*
* @return array
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
private function specificFolderList($bIsSubscribeList, $sParentFolderName = '', $sListPattern = '*', $bUseListStatus = false)
private function specificFolderList(bool $bIsSubscribeList, string $sParentFolderName = '', string $sListPattern = '*', bool $bUseListStatus = false) : array
{
$sCmd = 'LSUB';
if (!$bIsSubscribeList)
@ -739,53 +650,33 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sParentFolderName = ''
* @param string $sListPattern = '*'
*
* @return array
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderList($sParentFolderName = '', $sListPattern = '*')
public function FolderList(string $sParentFolderName = '', string $sListPattern = '*') : array
{
return $this->specificFolderList(false, $sParentFolderName, $sListPattern);
}
/**
* @param string $sParentFolderName = ''
* @param string $sListPattern = '*'
*
* @return array
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderSubscribeList($sParentFolderName = '', $sListPattern = '*')
public function FolderSubscribeList(string $sParentFolderName = '', string $sListPattern = '*') : array
{
return $this->specificFolderList(true, $sParentFolderName, $sListPattern);
}
/**
* @param string $sParentFolderName = ''
* @param string $sListPattern = '*'
*
* @return array
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderStatusList($sParentFolderName = '', $sListPattern = '*')
public function FolderStatusList(string $sParentFolderName = '', string $sListPattern = '*') : array
{
return $this->specificFolderList(false, $sParentFolderName, $sListPattern, true);
}
/**
* @param array $aResult
* @param string $sFolderName
* @param bool $bIsWritable
*/
protected function initCurrentFolderInformation($aResult, $sFolderName, $bIsWritable) : void
protected function initCurrentFolderInformation(array $aResult, string $sFolderName, bool $bIsWritable) : void
{
if (\is_array($aResult))
{
@ -855,17 +746,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sFolderName
* @param bool $bIsWritable
* @param bool $bReSelectSameFolders
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
protected function selectOrExamineFolder($sFolderName, $bIsWritable, $bReSelectSameFolders)
protected function selectOrExamineFolder(string $sFolderName, bool $bIsWritable, bool $bReSelectSameFolders) : self
{
if (!$bReSelectSameFolders)
{
@ -894,42 +779,30 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sFolderName
* @param bool $bReSelectSameFolders = false
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderSelect($sFolderName, $bReSelectSameFolders = false)
public function FolderSelect(string $sFolderName, bool $bReSelectSameFolders = false) : self
{
return $this->selectOrExamineFolder($sFolderName, true, $bReSelectSameFolders);
}
/**
* @param string $sFolderName
* @param bool $bReSelectSameFolders = false
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderExamine($sFolderName, $bReSelectSameFolders = false)
public function FolderExamine(string $sFolderName, bool $bReSelectSameFolders = false) : self
{
return $this->selectOrExamineFolder($sFolderName, $this->__FORCE_SELECT_ON_EXAMINE__, $bReSelectSameFolders);
}
/**
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderUnSelect()
public function FolderUnSelect() : self
{
if ($this->IsSelected() && $this->IsSupported('UNSELECT'))
{
@ -941,17 +814,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param array $aInputFetchItems
* @param string $sIndexRange
* @param bool $bIndexIsUid
*
* @return array
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Fetch(array $aInputFetchItems, $sIndexRange, $bIndexIsUid)
public function Fetch(array $aInputFetchItems, string $sIndexRange, bool $bIndexIsUid) : array
{
$sIndexRange = (string) $sIndexRange;
if (!\MailSo\Base\Validator::NotEmptyString($sIndexRange, true))
@ -1004,12 +871,10 @@ class ImapClient extends \MailSo\Net\NetClient
/**
* @return array|false
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Quota()
public function Quota() : array
{
$aReturn = false;
if ($this->IsSupported('QUOTA'))
@ -1056,17 +921,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param array $aSortTypes
* @param string $sSearchCriterias
* @param bool $bReturnUid
*
* @return array
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleSort($aSortTypes, $sSearchCriterias = 'ALL', $bReturnUid = true)
public function MessageSimpleSort(array $aSortTypes, string $sSearchCriterias = 'ALL', bool $bReturnUid = true) : array
{
$sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = !\MailSo\Base\Validator::NotEmptyString($sSearchCriterias, true) || '*' === $sSearchCriterias
@ -1125,21 +984,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param bool $bSort = false
* @param string $sSearchCriterias = 'ALL'
* @param array $aSearchOrSortReturn = null
* @param bool $bReturnUid = true
* @param string $sLimit = ''
* @param string $sCharset = ''
* @param array $aSortTypes = null
*
* @return array
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
private function simpleESearchOrESortHelper($bSort = false, $sSearchCriterias = 'ALL', $aSearchOrSortReturn = null, $bReturnUid = true, $sLimit = '', $sCharset = '', $aSortTypes = null)
private function simpleESearchOrESortHelper(bool $bSort = false, string $sSearchCriterias = 'ALL', array $aSearchOrSortReturn = null, bool $bReturnUid = true, string $sLimit = '', string $sCharset = '', array $aSortTypes = null) : array
{
$sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = 0 === \strlen($sSearchCriterias) || '*' === $sSearchCriterias
@ -1239,46 +1088,26 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sSearchCriterias = 'ALL'
* @param array $aSearchReturn = null
* @param bool $bReturnUid = true
* @param string $sLimit = ''
* @param string $sCharset = ''
*
* @return array
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleESearch($sSearchCriterias = 'ALL', $aSearchReturn = null, $bReturnUid = true, $sLimit = '', $sCharset = '')
public function MessageSimpleESearch(string $sSearchCriterias = 'ALL', array $aSearchReturn = null, bool $bReturnUid = true, string $sLimit = '', string $sCharset = '') : array
{
return $this->simpleESearchOrESortHelper(false, $sSearchCriterias, $aSearchReturn, $bReturnUid, $sLimit, $sCharset);
}
/**
* @param array $aSortTypes
* @param string $sSearchCriterias = 'ALL'
* @param array $aSearchReturn = null
* @param bool $bReturnUid = true
* @param string $sLimit = ''
*
* @return array
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleESort($aSortTypes, $sSearchCriterias = 'ALL', $aSearchReturn = null, $bReturnUid = true, $sLimit = '')
public function MessageSimpleESort(array $aSortTypes, string $sSearchCriterias = 'ALL', array $aSearchReturn = null, bool $bReturnUid = true, string $sLimit = '') : array
{
return $this->simpleESearchOrESortHelper(true, $sSearchCriterias, $aSearchReturn, $bReturnUid, $sLimit, '', $aSortTypes);
}
/**
* @param array $aResult
* @return \MailSo\Imap\Response
*/
private function findLastResponse($aResult)
private function findLastResponse(array $aResult) : \MailSo\Imap\Response
{
$oResult = null;
if (\is_array($aResult) && 0 < \count($aResult))
@ -1294,17 +1123,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sSearchCriterias
* @param bool $bReturnUid = true
* @param string $sCharset = ''
*
* @return array
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleSearch($sSearchCriterias = 'ALL', $bReturnUid = true, $sCharset = '')
public function MessageSimpleSearch(string $sSearchCriterias = 'ALL', bool $bReturnUid = true, string $sCharset = '') : array
{
$sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = 0 === \strlen($sSearchCriterias) || '*' === $sSearchCriterias
@ -1383,7 +1206,7 @@ class ImapClient extends \MailSo\Net\NetClient
*
* @return mixed
*/
private function validateThreadItem($aValue)
private function validateThreadItem(array $aValue)
{
$mResult = false;
if (\is_numeric($aValue))
@ -1422,17 +1245,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sSearchCriterias = 'ALL'
* @param bool $bReturnUid = true
* @param string $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8
*
* @return array
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleThread($sSearchCriterias = 'ALL', $bReturnUid = true, $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8)
public function MessageSimpleThread(string $sSearchCriterias = 'ALL', bool $bReturnUid = true, string $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8) : array
{
$sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = !\MailSo\Base\Validator::NotEmptyString($sSearchCriterias, true) || '*' === $sSearchCriterias
@ -1502,17 +1319,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sToFolder
* @param string $sIndexRange
* @param bool $bIndexIsUid
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageCopy($sToFolder, $sIndexRange, $bIndexIsUid)
public function MessageCopy(string $sToFolder, string $sIndexRange, bool $bIndexIsUid) : self
{
if (0 === \strlen($sIndexRange))
{
@ -1527,17 +1338,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sToFolder
* @param string $sIndexRange
* @param bool $bIndexIsUid
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageMove($sToFolder, $sIndexRange, $bIndexIsUid)
public function MessageMove(string $sToFolder, string $sIndexRange, bool $bIndexIsUid) : self
{
if (0 === \strlen($sIndexRange))
{
@ -1559,16 +1364,10 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sUidRangeIfSupported = ''
* @param bool $bForceUidExpunge = false
* @param bool $bExpungeAll = false
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageExpunge($sUidRangeIfSupported = '', $bForceUidExpunge = false, $bExpungeAll = false)
public function MessageExpunge(string $sUidRangeIfSupported = '', bool $bForceUidExpunge = false, bool $bExpungeAll = false) : self
{
$sUidRangeIfSupported = \trim($sUidRangeIfSupported);
@ -1585,18 +1384,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sIndexRange
* @param bool $bIndexIsUid
* @param array $aInputStoreItems
* @param string $sStoreAction
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageStoreFlag($sIndexRange, $bIndexIsUid, $aInputStoreItems, $sStoreAction)
public function MessageStoreFlag(string $sIndexRange, bool $bIndexIsUid, array $aInputStoreItems, string $sStoreAction) : self
{
if (!\MailSo\Base\Validator::NotEmptyString($sIndexRange, true) ||
!\MailSo\Base\Validator::NotEmptyString($sStoreAction, true) ||
@ -1610,25 +1402,18 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sFolderName
* @param resource $rMessageAppendStream
* @param int $iStreamSize
* @param array $aAppendFlags = null
* @param int $iUid = null
* @param int $sDateTime = 0
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageAppendStream($sFolderName, $rMessageAppendStream, $iStreamSize, $aAppendFlags = null, &$iUid = null, $sDateTime = 0)
public function MessageAppendStream(string $sFolderName, $rMessageAppendStream, int $iStreamSize, array $aAppendFlags = null, int &$iUid = null, int $iDateTime = 0) : self
{
$aData = array($this->EscapeString($sFolderName), $aAppendFlags);
if (0 < $sDateTime)
if (0 < $iDateTime)
{
$aData[] = $this->EscapeString(\gmdate('d-M-Y H:i:s', $sDateTime).' +0000');
$aData[] = $this->EscapeString(\gmdate('d-M-Y H:i:s', $iDateTime).' +0000');
}
$aData[] = '{'.$iStreamSize.'}';
@ -1666,25 +1451,16 @@ class ImapClient extends \MailSo\Net\NetClient
return $this;
}
/**
* @return \MailSo\Imap\FolderInformation
*/
public function FolderCurrentInformation()
public function FolderCurrentInformation() : \MailSo\Imap\FolderInformation
{
return $this->oCurrentFolderInfo;
}
/**
* @param string $sCommand
* @param array $aParams = array()
* @param bool $bBreakOnLiteral = false
*
* @return string
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
*/
public function SendRequest($sCommand, $aParams = array(), $bBreakOnLiteral = false)
public function SendRequest(string $sCommand, array $aParams = array(), bool $bBreakOnLiteral = false) : string
{
if (!\MailSo\Base\Validator::NotEmptyString($sCommand, true) || !\is_array($aParams))
{
@ -1727,13 +1503,7 @@ class ImapClient extends \MailSo\Net\NetClient
return '';
}
/**
* @param string $sCommand
* @param array $aParams
*
* @return array|null
*/
private function secureRequestParams($sCommand, $aParams)
private function secureRequestParams(string $sCommand, array $aParams) : ?array
{
$aResult = null;
switch ($sCommand)
@ -1751,17 +1521,11 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sCommand
* @param array $aParams = array()
* @param bool $bFindCapa = false
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function SendRequestWithCheck($sCommand, $aParams = array(), $bFindCapa = false)
public function SendRequestWithCheck(string $sCommand, array $aParams = array(), bool $bFindCapa = false) : self
{
$this->SendRequest($sCommand, $aParams);
$this->parseResponseWithValidation(null, $bFindCapa);
@ -1769,10 +1533,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $this;
}
/**
* @return array
*/
public function GetLastResponse()
public function GetLastResponse() : array
{
return $this->aLastResponse;
}
@ -1780,13 +1541,11 @@ class ImapClient extends \MailSo\Net\NetClient
/**
* @param mixed $aResult
*
* @return array
*
* @throws \MailSo\Imap\Exceptions\ResponseNotFoundException
* @throws \MailSo\Imap\Exceptions\InvalidResponseException
* @throws \MailSo\Imap\Exceptions\NegativeResponseException
*/
private function validateResponse($aResult)
private function validateResponse(array $aResult) : array
{
if (!\is_array($aResult) || 0 === $iCnt = \count($aResult))
{
@ -1815,13 +1574,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $aResult;
}
/**
* @param string $sEndTag = null
* @param bool $bFindCapa = false
*
* @return array|bool
*/
protected function parseResponse($sEndTag = null, $bFindCapa = false)
protected function parseResponse(string $sEndTag = null, bool $bFindCapa = false) : array
{
if (\is_resource($this->rConnect))
{
@ -1876,13 +1629,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $this->aLastResponse;
}
/**
* @param string $sEndTag = null
* @param bool $bFindCapa = false
*
* @return array
*/
private function parseResponseWithValidation($sEndTag = null, $bFindCapa = false)
private function parseResponseWithValidation(string $sEndTag = null, bool $bFindCapa = false) : array
{
return $this->validateResponse($this->parseResponse($sEndTag, $bFindCapa));
}
@ -1916,12 +1663,10 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @return array|string
*
* @throws \MailSo\Net\Exceptions\Exception
*/
private function partialParseResponseBranch(&$oImapResponse, $iStackIndex = -1,
$bTreatAsAtom = false, $sParentToken = '', $sOpenBracket = '')
private function partialParseResponseBranch(&$oImapResponse, int $iStackIndex = -1,
bool $bTreatAsAtom = false, string $sParentToken = '', string $sOpenBracket = '') : array
{
$mNull = null;
@ -2394,14 +2139,9 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* @param string $sParent
* @param string $sLiteralAtomUpperCase
* @param resource $rImapStream
* @param int $iLiteralLen
*
* @return bool
*/
private function partialResponseLiteralCallbackCallable($sParent, $sLiteralAtomUpperCase, $rImapStream, $iLiteralLen)
private function partialResponseLiteralCallbackCallable(string $sParent, string $sLiteralAtomUpperCase, $rImapStream, int $iLiteralLen) : bool
{
$sLiteralAtomUpperCasePeek = '';
if (0 === \strpos($sLiteralAtomUpperCase, 'BODY'))
@ -2440,7 +2180,7 @@ class ImapClient extends \MailSo\Net\NetClient
\call_user_func($this->aFetchCallbacks[$sFetchKey],
$sParent, $sLiteralAtomUpperCase, $rImapLiteralStream);
}
catch (\Exception $oException)
catch (\Throwable $oException)
{
$this->writeLog('Callback Exception', \MailSo\Log\Enumerations\Type::NOTICE);
$this->writeLogException($oException);
@ -2500,12 +2240,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $bResult;
}
/**
* @param array $aParams = null
*
* @return string
*/
private function prepearParamLine($aParams = array())
private function prepearParamLine(array $aParams = array()) : string
{
$sReturn = '';
if (\is_array($aParams) && 0 < \count($aParams))
@ -2525,48 +2260,31 @@ class ImapClient extends \MailSo\Net\NetClient
return $sReturn;
}
/**
* @return string
*/
private function getNewTag()
private function getNewTag() : string
{
$this->iTagCount++;
return $this->getCurrentTag();
}
/**
* @return string
*/
private function getCurrentTag()
private function getCurrentTag() : string
{
return self::TAG_PREFIX.$this->iTagCount;
}
/**
* @param string $sStringForEscape
*
* @return string
*/
public function EscapeString($sStringForEscape)
public function EscapeString(string $sStringForEscape) : string
{
return '"'.\str_replace(array('\\', '"'), array('\\\\', '\\"'), $sStringForEscape).'"';
}
/**
* @return string
*/
protected function getLogName()
protected function getLogName() : string
{
return 'IMAP';
}
/**
* @param resource $rConnect
* @param array $aCapabilityItems = array()
*
* @return \MailSo\Imap\ImapClient
*/
public function TestSetValues($rConnect, $aCapabilityItems = array())
public function TestSetValues($rConnect, array $aCapabilityItems = array()) : self
{
$this->rConnect = $rConnect;
$this->aCapabilityItems = $aCapabilityItems;
@ -2574,13 +2292,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $this;
}
/**
* @param string $sEndTag = null
* @param string $bFindCapa = false
*
* @return array
*/
public function TestParseResponseWithValidationProxy($sEndTag = null, $bFindCapa = false)
public function TestParseResponseWithValidationProxy(string $sEndTag = null, bool $bFindCapa = false) : array
{
return $this->parseResponseWithValidation($sEndTag, $bFindCapa);
}

View file

@ -47,9 +47,6 @@ class NamespaceResult
*/
private $sSharedDelimiter;
/**
* @access private
*/
private function __construct()
{
$this->sPersonal = '';
@ -60,20 +57,12 @@ class NamespaceResult
$this->sSharedDelimiter = '';
}
/**
* @return \MailSo\Imap\NamespaceResult
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @param \MailSo\Imap\Response $oImapResponse
*
* @return \MailSo\Imap\NamespaceResult
*/
public function InitByImapResponse($oImapResponse)
public function InitByImapResponse(\MailSo\Imap\Response $oImapResponse) : self
{
if ($oImapResponse && $oImapResponse instanceof \MailSo\Imap\Response)
{
@ -114,18 +103,12 @@ class NamespaceResult
return $this;
}
/**
* @return string
*/
public function GetPersonalNamespace()
public function GetPersonalNamespace() : string
{
return $this->sPersonal;
}
/**
* @return string
*/
public function GetPersonalNamespaceDelimiter()
public function GetPersonalNamespaceDelimiter() : string
{
return $this->sPersonalDelimiter;
}

View file

@ -52,9 +52,6 @@ class Response
*/
public $Tag;
/**
* @access private
*/
private function __construct()
{
$this->ResponseList = array();
@ -66,20 +63,12 @@ class Response
$this->Tag = '';
}
/**
* @return \MailSo\Imap\Response
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @param string $aList
*
* @return string
*/
private function recToLine($aList)
private function recToLine(array $aList) : string
{
$aResult = array();
if (\is_array($aList))
@ -93,11 +82,7 @@ class Response
return \implode(' ', $aResult);
}
/**
* @return string
*/
public function ToLine()
public function ToLine() : string
{
return $this->recToLine($this->ResponseList);
}

View file

@ -82,9 +82,6 @@ abstract class Driver
*/
private $aCache;
/**
* @access protected
*/
protected function __construct()
{
$this->sDatePattern = 'H:i:s';
@ -119,63 +116,37 @@ abstract class Driver
);
}
/**
* @param string $sTimeOffset
*
* @return \MailSo\Log\Driver
*/
public function SetTimeOffset($sTimeOffset)
public function SetTimeOffset(string $sTimeOffset) : self
{
$this->sTimeOffset = (string) $sTimeOffset;
return $this;
}
/**
* @return \MailSo\Log\Driver
*/
public function DisableGuidPrefix()
public function DisableGuidPrefix() : self
{
$this->bGuidPrefix = false;
return $this;
}
/**
* @return \MailSo\Log\Driver
*/
public function DisableTimePrefix()
public function DisableTimePrefix() : self
{
$this->bTimePrefix = false;
return $this;
}
/**
* @param bool $bValue
*
* @return \MailSo\Log\Driver
*/
public function WriteOnErrorOnly($bValue)
public function WriteOnErrorOnly(bool $bValue) : self
{
$this->bWriteOnErrorOnly = !!$bValue;
return $this;
}
/**
* @param bool $bValue
*
* @return \MailSo\Log\Driver
*/
public function WriteOnPhpErrorOnly($bValue)
public function WriteOnPhpErrorOnly(bool $bValue) : self
{
$this->bWriteOnPhpErrorOnly = !!$bValue;
return $this;
}
/**
* @param int $iTimeout
*
* @return \MailSo\Log\Driver
*/
public function WriteOnTimeoutOnly($iTimeout)
public function WriteOnTimeoutOnly(int $iTimeout) : self
{
$this->iWriteOnTimeoutOnly = (int) $iTimeout;
if (0 > $this->iWriteOnTimeoutOnly)
@ -186,39 +157,21 @@ abstract class Driver
return $this;
}
/**
* @return \MailSo\Log\Driver
*/
public function DisableTypedPrefix()
public function DisableTypedPrefix() : self
{
$this->bTypedPrefix = false;
return $this;
}
/**
* @param string|array $mDesc
* @return bool
*/
abstract protected function writeImplementation($mDesc);
abstract protected function writeImplementation($mDesc) : bool;
/**
* @return bool
*/
protected function writeEmptyLineImplementation()
protected function writeEmptyLineImplementation() : bool
{
return $this->writeImplementation('');
}
/**
* @param string $sTimePrefix
* @param string $sDesc
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
* @param array $sName = ''
*
* @return string
*/
protected function loggerLineImplementation($sTimePrefix, $sDesc,
$iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '')
protected function loggerLineImplementation(string $sTimePrefix, string $sDesc,
int $iType = \MailSo\Log\Enumerations\Type::INFO, string $sName = '') : string
{
return \ltrim(
($this->bTimePrefix ? '['.$sTimePrefix.']' : '').
@ -227,43 +180,25 @@ abstract class Driver
).$sDesc;
}
/**
* @return bool
*/
protected function clearImplementation()
protected function clearImplementation() : bool
{
return true;
}
/**
* @return string
*/
protected function getTimeWithMicroSec()
protected function getTimeWithMicroSec() : string
{
$aMicroTimeItems = \explode(' ', \microtime());
return \MailSo\Log\Logger::DateHelper($this->sDatePattern, $this->sTimeOffset, $aMicroTimeItems[1]).'.'.
\str_pad((int) ($aMicroTimeItems[0] * 1000), 3, '0', STR_PAD_LEFT);
}
/**
* @param int $iType
* @param string $sName = ''
*
* @return string
*/
protected function getTypedPrefix($iType, $sName = '')
protected function getTypedPrefix(int $iType, string $sName = '') : string
{
$sName = 0 < \strlen($sName) ? $sName : $this->sName;
return isset($this->aPrefixes[$iType]) ? $sName.$this->aPrefixes[$iType].': ' : '';
}
/**
* @param string|array $mDesc
* @param bool $bDiplayCrLf = false
*
* @return string
*/
protected function localWriteImplementation($mDesc, $bDiplayCrLf = false)
protected function localWriteImplementation($mDesc, bool $bDiplayCrLf = false) : string
{
if ($bDiplayCrLf)
{
@ -285,15 +220,6 @@ abstract class Driver
return $this->writeImplementation($mDesc);
}
/**
* @final
* @param string $sDesc
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
* @param string $sName = ''
* @param bool $bDiplayCrLf = false
*
* @return bool
*/
final public function Write($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '', $bDiplayCrLf = false)
{
$bResult = true;
@ -339,9 +265,9 @@ abstract class Driver
$bResult = $this->localWriteImplementation($this->aCache, $bDiplayCrLf);
$this->aCache = array();
}
else if (0 < $this->iWriteOnTimeoutOnly && \time() - APP_START_TIME > $this->iWriteOnTimeoutOnly)
else if (0 < $this->iWriteOnTimeoutOnly && \time() - $_SERVER['REQUEST_TIME_FLOAT'] > $this->iWriteOnTimeoutOnly)
{
$sFlush = '--- FlushLogCache: WriteOnTimeoutOnly ['.(\time() - APP_START_TIME).'sec]';
$sFlush = '--- FlushLogCache: WriteOnTimeoutOnly ['.(\time() - $_SERVER['REQUEST_TIME_FLOAT']).'sec]';
if (isset($this->aCache[0]) && empty($this->aCache[0]))
{
$this->aCache[0] = $sFlush;
@ -373,26 +299,16 @@ abstract class Driver
return $bResult;
}
/**
* @return string
*/
public function GetNewLine()
public function GetNewLine() : string
{
return $this->sNewLine;
}
/**
* @final
* @return bool
*/
final public function Clear()
final public function Clear() : bool
{
return $this->clearImplementation();
}
/**
* @final
*/
final public function WriteEmptyLine() : void
{
if (!$this->bFlushCache && ($this->bWriteOnErrorOnly || $this->bWriteOnPhpErrorOnly || 0 < $this->iWriteOnTimeoutOnly))

View file

@ -29,8 +29,6 @@ class Callback extends \MailSo\Log\Driver
private $fClearCallback;
/**
* @access protected
*
* @param mixed $fWriteCallback
* @param mixed $fClearCallback
*/
@ -45,20 +43,13 @@ class Callback extends \MailSo\Log\Driver
/**
* @param mixed $fWriteCallback
* @param mixed $fClearCallback = null
*
* @return \MailSo\Log\Drivers\Callback
*/
public static function NewInstance($fWriteCallback, $fClearCallback = null)
public static function NewInstance($fWriteCallback, $fClearCallback = null) : \MailSo\Log\Drivers\Callback
{
return new self($fWriteCallback, $fClearCallback);
}
/**
* @param string|array $mDesc
*
* @return bool
*/
protected function writeImplementation($mDesc)
protected function writeImplementation($mDesc) : bool
{
if ($this->fWriteCallback)
{
@ -68,10 +59,7 @@ class Callback extends \MailSo\Log\Driver
return true;
}
/**
* @return bool
*/
protected function clearImplementation()
protected function clearImplementation() : bool
{
if ($this->fClearCallback)
{

View file

@ -23,12 +23,6 @@ class File extends \MailSo\Log\Driver
*/
private $sLoggerFileName;
/**
* @access protected
*
* @param string $sLoggerFileName
* @param string $sNewLine = "\r\n"
*/
protected function __construct($sLoggerFileName, $sNewLine = "\r\n")
{
parent::__construct();
@ -37,49 +31,27 @@ class File extends \MailSo\Log\Driver
$this->sNewLine = $sNewLine;
}
/**
* @param string $sLoggerFileName
*/
public function SetLoggerFileName($sLoggerFileName)
public function SetLoggerFileName(string $sLoggerFileName)
{
$this->sLoggerFileName = $sLoggerFileName;
}
/**
* @param string $sLoggerFileName
* @param string $sNewLine = "\r\n"
*
* @return \MailSo\Log\Drivers\File
*/
public static function NewInstance($sLoggerFileName, $sNewLine = "\r\n")
public static function NewInstance(string $sLoggerFileName, string $sNewLine = "\r\n") : \MailSo\Log\Drivers\File
{
return new self($sLoggerFileName, $sNewLine);
}
/**
* @param string|array $mDesc
*
* @return bool
*/
protected function writeImplementation($mDesc)
protected function writeImplementation($mDesc) : bool
{
return $this->writeToLogFile($mDesc);
}
/**
* @return bool
*/
protected function clearImplementation()
protected function clearImplementation() : bool
{
return \unlink($this->sLoggerFileName);
}
/**
* @param string|array $mDesc
*
* @return bool
*/
private function writeToLogFile($mDesc)
private function writeToLogFile($mDesc) : bool
{
if (\is_array($mDesc))
{

View file

@ -23,12 +23,6 @@ class Inline extends \MailSo\Log\Driver
*/
private $bHtmlEncodeSpecialChars;
/**
* @access protected
*
* @param string $sNewLine = "\r\n"
* @param bool $bHtmlEncodeSpecialChars = false
*/
protected function __construct($sNewLine = "\r\n", $bHtmlEncodeSpecialChars = false)
{
parent::__construct();
@ -37,23 +31,12 @@ class Inline extends \MailSo\Log\Driver
$this->bHtmlEncodeSpecialChars = $bHtmlEncodeSpecialChars;
}
/**
* @param string $sNewLine = "\r\n"
* @param bool $bHtmlEncodeSpecialChars = false
*
* @return \MailSo\Log\Drivers\Inline
*/
public static function NewInstance($sNewLine = "\r\n", $bHtmlEncodeSpecialChars = false)
public static function NewInstance(string $sNewLine = "\r\n", bool $bHtmlEncodeSpecialChars = false) : \MailSo\Log\Drivers\Inline
{
return new self($sNewLine, $bHtmlEncodeSpecialChars);
}
/**
* @param string $mDesc
*
* @return bool
*/
protected function writeImplementation($mDesc)
protected function writeImplementation($mDesc) : bool
{
if (\is_array($mDesc))
{
@ -74,10 +57,7 @@ class Inline extends \MailSo\Log\Driver
return true;
}
/**
* @return bool
*/
protected function clearImplementation()
protected function clearImplementation() : bool
{
if (\defined('PHP_SAPI') && 'cli' === PHP_SAPI && \MailSo\Base\Utils::FunctionExistsAndEnabled('system'))
{

View file

@ -20,9 +20,6 @@ class Syslog extends \MailSo\Log\Driver
{
private $iLogLevel;
/**
* @access protected
*/
protected function __construct()
{
parent::__construct();
@ -43,20 +40,12 @@ class Syslog extends \MailSo\Log\Driver
}
}
/**
* @return \MailSo\Log\Drivers\Syslog
*/
public static function NewInstance()
public static function NewInstance() : \MailSo\Log\Drivers\Syslog
{
return new self();
}
/**
* @param string|array $mDesc
*
* @return bool
*/
protected function writeImplementation($mDesc)
protected function writeImplementation($mDesc) : bool
{
if (null === $this->iLogLevel)
{
@ -71,10 +60,7 @@ class Syslog extends \MailSo\Log\Driver
return \syslog($this->iLogLevel, $mDesc);
}
/**
* @return bool
*/
protected function clearImplementation()
protected function clearImplementation() : bool
{
return true;
}

View file

@ -42,11 +42,6 @@ class Logger extends \MailSo\Base\Collection
*/
private $bHideErrorNotices;
/**
* @access protected
*
* @param bool $bRegPhpErrorHandler = false
*/
protected function __construct($bRegPhpErrorHandler = true)
{
parent::__construct();
@ -65,22 +60,15 @@ class Logger extends \MailSo\Base\Collection
\register_shutdown_function(array(&$this, '__loggerShutDown'));
}
/**
* @param bool $bRegPhpErrorHandler = false
*
* @return \MailSo\Log\Logger
*/
public static function NewInstance($bRegPhpErrorHandler = false)
public static function NewInstance(bool $bRegPhpErrorHandler = false) : self
{
return new self($bRegPhpErrorHandler);
}
/**
* @staticvar \MailSo\Log\Logger $oInstance;
*
* @return \MailSo\Log\Logger
*/
public static function SingletonInstance()
public static function SingletonInstance() : self
{
static $oInstance = null;
if (null === $oInstance)
@ -91,34 +79,23 @@ class Logger extends \MailSo\Base\Collection
return $oInstance;
}
/**
* @param string $sFormat
* @param string $sTimeOffset = '0'
* @param int $iTimestamp = 0
*
* @return string
*/
public static function DateHelper($sFormat, $sTimeOffset = '0', $iTimestamp = null)
public static function DateHelper(string $sFormat, string $sTimeOffset = '0', int $iTimestamp = null) : string
{
$iTimestamp = null === $iTimestamp ? \time() : (int) $iTimestamp;
return \gmdate($sFormat, $iTimestamp + \MailSo\Base\DateTimeHelper::TimeToSec((string) $sTimeOffset));
}
/**
* @return bool
*/
public static function IsSystemEnabled()
public static function IsSystemEnabled() : bool
{
return !!(\MailSo\Config::$SystemLogger instanceof \MailSo\Log\Logger);
return !!(\MailSo\Config::$SystemLogger instanceof Logger);
}
/**
* @param mixed $mData
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
*/
public static function SystemLog($mData, $iType = \MailSo\Log\Enumerations\Type::INFO)
public static function SystemLog($mData, int $iType = \MailSo\Log\Enumerations\Type::INFO)
{
if (\MailSo\Config::$SystemLogger instanceof \MailSo\Log\Logger)
if (\MailSo\Config::$SystemLogger instanceof Logger)
{
\MailSo\Config::$SystemLogger->WriteMixed($mData, $iType);
}
@ -126,10 +103,8 @@ class Logger extends \MailSo\Base\Collection
/**
* @staticvar string $sCache;
*
* @return string
*/
public static function Guid()
public static function Guid() : string
{
static $sCache = null;
if (null === $sCache)
@ -140,28 +115,17 @@ class Logger extends \MailSo\Base\Collection
return $sCache;
}
/**
* @return bool
*/
public function Ping()
public function Ping() : bool
{
return true;
}
/**
* @return bool
*/
public function IsEnabled()
public function IsEnabled() : bool
{
return 0 < $this->Count();
}
/**
* @param string $sWord
*
* @return bool
*/
public function AddSecret($sWord)
public function AddSecret(string $sWord) : bool
{
if (\is_string($sWord) && 0 < \strlen(\trim($sWord)))
{
@ -170,68 +134,37 @@ class Logger extends \MailSo\Base\Collection
}
}
/**
* @param bool $bShow
*
* @return \MailSo\Log\Logger
*/
public function SetShowSecter($bShow)
public function SetShowSecter(bool $bShow) : self
{
$this->bShowSecter = !!$bShow;
return $this;
}
/**
* @param bool $bValue
*
* @return \MailSo\Log\Logger
*/
public function HideErrorNotices($bValue)
public function HideErrorNotices(bool $bValue) : self
{
$this->bHideErrorNotices = !!$bValue;
return $this;
}
/**
* @return bool
*/
public function IsShowSecter()
public function IsShowSecter() : bool
{
return $this->bShowSecter;
}
/**
* @param int $iType
*
* @return \MailSo\Log\Logger
*/
public function AddForbiddenType($iType)
public function AddForbiddenType(int $iType) : self
{
$this->aForbiddenTypes[$iType] = true;
return $this;
}
/**
* @param int $iType
*
* @return \MailSo\Log\Logger
*/
public function RemoveForbiddenType($iType)
public function RemoveForbiddenType(int $iType) : self
{
$this->aForbiddenTypes[$iType] = false;
return $this;
}
/**
* @param int $iErrNo
* @param string $sErrStr
* @param string $sErrFile
* @param int $iErrLine
*
* @return bool
*/
public function __phpErrorHandler($iErrNo, $sErrStr, $sErrFile, $iErrLine)
public function __phpErrorHandler(int $iErrNo, string $sErrStr, string $sErrFile, int $iErrLine) : bool
{
$iType = \MailSo\Log\Enumerations\Type::NOTICE_PHP;
switch ($iErrNo)
@ -271,10 +204,7 @@ class Logger extends \MailSo\Base\Collection
}
}
/**
* @return bool
*/
public function WriteEmptyLine()
public function WriteEmptyLine() : bool
{
$iResult = 1;
@ -287,17 +217,8 @@ class Logger extends \MailSo\Base\Collection
return (bool) $iResult;
}
/**
* @param string $sDesc
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
* @param string $sName = ''
* @param bool $bSearchSecretWords = true
* @param bool $bDiplayCrLf = false
*
* @return bool
*/
public function Write($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO,
$sName = '', $bSearchSecretWords = true, $bDiplayCrLf = false)
public function Write(string $sDesc, int $iType = \MailSo\Log\Enumerations\Type::INFO,
string $sName = '', bool $bSearchSecretWords = true, bool $bDiplayCrLf = false) : bool
{
if (isset($this->aForbiddenTypes[$iType]) && true === $this->aForbiddenTypes[$iType])
{
@ -326,32 +247,17 @@ class Logger extends \MailSo\Base\Collection
/**
* @param mixed $oValue
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
* @param string $sName = ''
* @param bool $bSearchSecretWords = false
* @param bool $bDiplayCrLf = false
*
* @return bool
*/
public function WriteDump($oValue, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '',
$bSearchSecretWords = false, $bDiplayCrLf = false)
public function WriteDump($oValue, int $iType = \MailSo\Log\Enumerations\Type::INFO, string $sName = '',
bool $bSearchSecretWords = false, bool $bDiplayCrLf = false) : bool
{
return $this->Write(\print_r($oValue, true), $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
}
/**
* @param \Exception $oException
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE
* @param string $sName = ''
* @param bool $bSearchSecretWords = true
* @param bool $bDiplayCrLf = false
*
* @return bool
*/
public function WriteException($oException, $iType = \MailSo\Log\Enumerations\Type::NOTICE, $sName = '',
$bSearchSecretWords = true, $bDiplayCrLf = false)
public function WriteException(\Throwable $oException, int $iType = \MailSo\Log\Enumerations\Type::NOTICE, string $sName = '',
bool $bSearchSecretWords = true, bool $bDiplayCrLf = false) : bool
{
if ($oException instanceof \Exception)
if ($oException instanceof \Throwable)
{
if (isset($oException->__LOGINNED__))
{
@ -366,19 +272,10 @@ class Logger extends \MailSo\Base\Collection
return false;
}
/**
* @param \Exception $oException
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE
* @param string $sName = ''
* @param bool $bSearchSecretWords = true
* @param bool $bDiplayCrLf = false
*
* @return bool
*/
public function WriteExceptionShort($oException, $iType = \MailSo\Log\Enumerations\Type::NOTICE, $sName = '',
$bSearchSecretWords = true, $bDiplayCrLf = false)
public function WriteExceptionShort(\Throwable $oException, int $iType = \MailSo\Log\Enumerations\Type::NOTICE, string $sName = '',
bool $bSearchSecretWords = true, bool $bDiplayCrLf = false) : bool
{
if ($oException instanceof \Exception)
if ($oException instanceof \Throwable)
{
if (isset($oException->__LOGINNED__))
{
@ -395,20 +292,14 @@ class Logger extends \MailSo\Base\Collection
/**
* @param mixed $mData
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE
* @param string $sName = ''
* @param bool $bSearchSecretWords = true
* @param bool $bDiplayCrLf = false
*
* @return bool
*/
public function WriteMixed($mData, $iType = null, $sName = '',
$bSearchSecretWords = true, $bDiplayCrLf = false)
public function WriteMixed($mData, int $iType = null, string $sName = '',
bool $bSearchSecretWords = true, bool $bDiplayCrLf = false) : bool
{
$iType = null === $iType ? \MailSo\Log\Enumerations\Type::INFO : $iType;
if (\is_array($mData) || \is_object($mData))
{
if ($mData instanceof \Exception)
if ($mData instanceof \Throwable)
{
$iType = null === $iType ? \MailSo\Log\Enumerations\Type::NOTICE : $iType;
return $this->WriteException($mData, $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);

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();
}

View file

@ -57,9 +57,6 @@ class Attachment
*/
private $sContentLocation;
/**
* @access private
*/
private function __construct($rResource, $sFileName, $iFileSize, $bIsInline, $bIsLinked, $sCID,
$aCustomContentTypeParams = array(), $sContentLocation = '')
{
@ -75,18 +72,9 @@ class Attachment
/**
* @param resource $rResource
* @param string $sFileName = ''
* @param int $iFileSize = 0
* @param bool $bIsInline = false
* @param bool $bIsLinked = false
* @param string $sCID = ''
* @param array $aCustomContentTypeParams = array()
* @param string $sContentLocation = ''
*
* @return \MailSo\Mime\Attachment
*/
public static function NewInstance($rResource, $sFileName = '', $iFileSize = 0, $bIsInline = false,
$bIsLinked = false, $sCID = '', $aCustomContentTypeParams = array(), $sContentLocation = '')
public static function NewInstance($rResource, string $sFileName = '', int $iFileSize = 0, bool $bIsInline = false,
bool $bIsLinked = false, string $sCID = '', array $aCustomContentTypeParams = array(), string $sContentLocation = '') : self
{
return new self($rResource, $sFileName, $iFileSize, $bIsInline, $bIsLinked, $sCID, $aCustomContentTypeParams, $sContentLocation);
}
@ -99,99 +87,63 @@ class Attachment
return $this->rResource;
}
/**
* @return string
*/
public function ContentType()
public function ContentType() : string
{
return \MailSo\Base\Utils::MimeContentType($this->sFileName);
}
/**
* @return array
*/
public function CustomContentTypeParams()
public function CustomContentTypeParams() : array
{
return $this->aCustomContentTypeParams;
}
/**
* @return string
*/
public function CID()
public function CID() : string
{
return $this->sCID;
}
/**
* @return string
*/
public function ContentLocation()
public function ContentLocation() : string
{
return $this->sContentLocation;
}
/**
* @return string
*/
public function FileName()
public function FileName() : string
{
return $this->sFileName;
}
/**
* @return int
*/
public function FileSize()
public function FileSize() : int
{
return $this->iFileSize;
}
/**
* @return bool
*/
public function IsInline()
public function IsInline() : bool
{
return $this->bIsInline;
}
/**
* @return bool
*/
public function IsImage()
public function IsImage() : bool
{
return 'image' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
}
/**
* @return bool
*/
public function IsArchive()
public function IsArchive() : bool
{
return 'archive' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
}
/**
* @return bool
*/
public function IsPdf()
public function IsPdf() : bool
{
return 'pdf' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
}
/**
* @return bool
*/
public function IsDoc()
public function IsDoc() : bool
{
return 'doc' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
}
/**
* @return bool
*/
public function IsLinked()
public function IsLinked() : bool
{
return $this->bIsLinked && 0 < \strlen($this->sCID);
}
}
}

View file

@ -25,38 +25,26 @@ class AttachmentCollection extends \MailSo\Base\Collection
parent::__construct();
}
/**
* @return \MailSo\Mime\AttachmentCollection
*/
public static function NewInstance()
public static function NewInstance() : \MailSo\Mime\AttachmentCollection
{
return new self();
}
/**
* @return array
*/
public function LinkedAttachments()
public function LinkedAttachments() : array
{
return $this->FilterList(function ($oItem) {
return $oItem && $oItem->IsLinked();
});
}
/**
* @return array
*/
public function UnlinkedAttachments()
public function UnlinkedAttachments() : array
{
return $this->FilterList(function ($oItem) {
return $oItem && !$oItem->IsLinked();
});
}
/**
* @return int
*/
public function SizeOfAttachments()
public function SizeOfAttachments() : int
{
$iResult = 0;
$this->ForeachList(function ($oItem) use (&$iResult) {

View file

@ -38,11 +38,6 @@ class Email
private $sDkimValue;
/**
* @access private
*
* @param string $sEmail
* @param string $sDisplayName = ''
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
private function __construct($sEmail, $sDisplayName = '')
@ -62,25 +57,17 @@ class Email
}
/**
* @param string $sEmail
* @param string $sDisplayName = ''
*
* @return \MailSo\Mime\Email
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public static function NewInstance($sEmail, $sDisplayName = '')
public static function NewInstance(string $sEmail, string $sDisplayName = '') : self
{
return new self($sEmail, $sDisplayName);
}
/**
* @param string $sEmailAddress
* @return \MailSo\Mime\Email
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public static function Parse($sEmailAddress)
public static function Parse(string $sEmailAddress) : self
{
$sEmailAddress = \MailSo\Base\Utils::Trim($sEmailAddress);
if (!\MailSo\Base\Validator::NotEmptyString($sEmailAddress, true))
@ -207,88 +194,50 @@ class Email
return Email::NewInstance($sEmail, $sName);
}
/**
* @param bool $bIdn = false
*
* @return string
*/
public function GetEmail($bIdn = false)
public function GetEmail(bool $bIdn = false) : string
{
return $bIdn ? \MailSo\Base\Utils::IdnToUtf8($this->sEmail) : $this->sEmail;
}
/**
* @return string
*/
public function GetDisplayName()
public function GetDisplayName() : string
{
return $this->sDisplayName;
}
/**
* @return string
*/
public function GetDkimStatus()
public function GetDkimStatus() : string
{
return $this->sDkimStatus;
}
/**
* @return string
*/
public function GetDkimValue()
public function GetDkimValue() : string
{
return $this->sDkimValue;
}
/**
* @return string
*/
public function GetAccountName()
public function GetAccountName() : string
{
return \MailSo\Base\Utils::GetAccountNameFromEmail($this->GetEmail(false));
}
/**
* @param bool $bIdn = false
*
* @return string
*/
public function GetDomain($bIdn = false)
public function GetDomain(bool $bIdn = false) : string
{
return \MailSo\Base\Utils::GetDomainFromEmail($this->GetEmail($bIdn));
}
/**
* @param string $sDkimStatus
* @param string $sDkimValue = ''
*/
public function SetDkimStatusAndValue($sDkimStatus, $sDkimValue = '')
public function SetDkimStatusAndValue(string $sDkimStatus, string $sDkimValue = '')
{
$this->sDkimStatus = \MailSo\Mime\Enumerations\DkimStatus::normalizeValue($sDkimStatus);
$this->sDkimValue = $sDkimValue;
}
/**
* @param bool $bIdn = false
* @param bool $bDkim = true
*
* @return array
*/
public function ToArray($bIdn = false, $bDkim = true)
public function ToArray(bool $bIdn = false, bool $bDkim = true) : array
{
return $bDkim ?
array($this->sDisplayName, $this->GetEmail($bIdn), $this->sDkimStatus, $this->sDkimValue) :
array($this->sDisplayName, $this->GetEmail($bIdn));
}
/**
* @param bool $bConvertSpecialsName = false
* @param bool $bIdn = false
*
* @return string
*/
public function ToString($bConvertSpecialsName = false, $bIdn = false)
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string
{
$sReturn = '';

View file

@ -17,11 +17,6 @@ namespace MailSo\Mime;
*/
class EmailCollection extends \MailSo\Base\Collection
{
/**
* @access protected
*
* @param string $sEmailAddresses = ''
*/
protected function __construct($sEmailAddresses = '')
{
parent::__construct();
@ -33,30 +28,17 @@ class EmailCollection extends \MailSo\Base\Collection
}
}
/**
* @param string $sEmailAddresses = ''
*
* @return \MailSo\Mime\EmailCollection
*/
public static function NewInstance($sEmailAddresses = '')
public static function NewInstance(string $sEmailAddresses = '') : self
{
return new self($sEmailAddresses);
}
/**
* @param string $sEmailAddresses
*
* @return \MailSo\Mime\EmailCollection
*/
public static function Parse($sEmailAddresses)
public static function Parse(string $sEmailAddresses) : self
{
return self::NewInstance($sEmailAddresses);
}
/**
* @return array
*/
public function ToArray()
public function ToArray() : array
{
$aReturn = $aEmails = array();
$aEmails =& $this->GetAsArray();
@ -68,12 +50,7 @@ class EmailCollection extends \MailSo\Base\Collection
return $aReturn;
}
/**
* @param \MailSo\Mime\EmailCollection $oEmails
*
* @return \MailSo\Mime\EmailCollection
*/
public function MergeWithOtherCollection(\MailSo\Mime\EmailCollection $oEmails)
public function MergeWithOtherCollection(EmailCollection $oEmails) : self
{
$aEmails =& $oEmails->GetAsArray();
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
@ -84,10 +61,7 @@ class EmailCollection extends \MailSo\Base\Collection
return $this;
}
/**
* @return \MailSo\Mime\EmailCollection
*/
public function Unique()
public function Unique() : self
{
$aCache = array();
$aReturn = array();
@ -108,13 +82,7 @@ class EmailCollection extends \MailSo\Base\Collection
return $this;
}
/**
* @param bool $bConvertSpecialsName = false
* @param bool $bIdn = false
*
* @return string
*/
public function ToString($bConvertSpecialsName = false, $bIdn = false)
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string
{
$aReturn = $aEmails = array();
$aEmails =& $this->GetAsArray();
@ -126,12 +94,7 @@ class EmailCollection extends \MailSo\Base\Collection
return \implode(', ', $aReturn);
}
/**
* @param string $sRawEmails
*
* @return \MailSo\Mime\EmailCollection
*/
private function parseEmailAddresses($sRawEmails)
private function parseEmailAddresses(string $sRawEmails) : self
{
$this->Clear();

View file

@ -44,12 +44,6 @@ class EmailDep
private $sDkimValue;
/**
* @access private
*
* @param string $sEmail
* @param string $sDisplayName = ''
* @param string $sRemark = ''
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
private function __construct($sEmail, $sDisplayName = '', $sRemark = '')
@ -70,26 +64,17 @@ class EmailDep
}
/**
* @param string $sEmail
* @param string $sDisplayName = ''
* @param string $sRemark = ''
*
* @return \MailSo\Mime\Email
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public static function NewInstance($sEmail, $sDisplayName = '', $sRemark = '')
public static function NewInstance(string $sEmail, string $sDisplayName = '', string $sRemark = '') : \MailSo\Mime\Email
{
return new self($sEmail, $sDisplayName, $sRemark);
}
/**
* @param string $sEmailAddress
* @return \MailSo\Mime\Email
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public static function Parse($sEmailAddress)
public static function Parse(string $sEmailAddress) : \MailSo\Mime\Email
{
$sEmailAddress = \MailSo\Base\Utils::Trim($sEmailAddress);
if (!\MailSo\Base\Validator::NotEmptyString($sEmailAddress, true))
@ -216,95 +201,54 @@ class EmailDep
return Email::NewInstance($sEmail, $sName, $sComment);
}
/**
* @param bool $bIdn = false
*
* @return string
*/
public function GetEmail($bIdn = false)
public function GetEmail(bool $bIdn = false) : string
{
return $bIdn ? \MailSo\Base\Utils::IdnToUtf8($this->sEmail) : $this->sEmail;
}
/**
* @return string
*/
public function GetDisplayName()
public function GetDisplayName() : string
{
return $this->sDisplayName;
}
/**
* @return string
*/
public function GetRemark()
public function GetRemark() : string
{
return $this->sRemark;
}
/**
* @return string
*/
public function GetDkimStatus()
public function GetDkimStatus() : string
{
return $this->sDkimStatus;
}
/**
* @return string
*/
public function GetDkimValue()
public function GetDkimValue() : string
{
return $this->sDkimValue;
}
/**
* @return string
*/
public function GetAccountName()
public function GetAccountName() : string
{
return \MailSo\Base\Utils::GetAccountNameFromEmail($this->GetEmail(false));
}
/**
* @param bool $bIdn = false
*
* @return string
*/
public function GetDomain($bIdn = false)
public function GetDomain(bool $bIdn = false) : string
{
return \MailSo\Base\Utils::GetDomainFromEmail($this->GetEmail($bIdn));
}
/**
* @param string $sDkimStatus
* @param string $sDkimValue = ''
*/
public function SetDkimStatusAndValue($sDkimStatus, $sDkimValue = '')
public function SetDkimStatusAndValue(string $sDkimStatus, string $sDkimValue = '') : void
{
$this->sDkimStatus = \MailSo\Mime\Enumerations\DkimStatus::normalizeValue($sDkimStatus);
$this->sDkimValue = $sDkimValue;
}
/**
* @param bool $bIdn = false
* @param bool $bDkim = true
*
* @return array
*/
public function ToArray($bIdn = false, $bDkim = true)
public function ToArray(bool $bIdn = false, bool $bDkim = true) : array
{
return $bDkim ? array($this->sDisplayName, $this->GetEmail($bIdn), $this->sRemark, $this->sDkimStatus, $this->sDkimValue) :
array($this->sDisplayName, $this->GetEmail($bIdn), $this->sRemark);
}
/**
* @param bool $bConvertSpecialsName = false
* @param bool $bIdn = false
*
* @return string
*/
public function ToString($bConvertSpecialsName = false, $bIdn = false)
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string
{
$sReturn = '';

View file

@ -26,12 +26,7 @@ class DkimStatus
const TEMP_ERROR = 'temperror';
const PREM_ERROR = 'permerror';
/**
* @param string $sStatus
*
* @return bool
*/
public static function verifyValue($sStatus)
public static function verifyValue(string $sStatus) : bool
{
return \in_array($sStatus, array(
self::NONE,
@ -44,12 +39,7 @@ class DkimStatus
));
}
/**
* @param string $sStatus
*
* @return string
*/
public static function normalizeValue($sStatus)
public static function normalizeValue(string $sStatus) : string
{
$sStatus = \strtolower(\trim($sStatus));
return self::verifyValue($sStatus) ? $sStatus : self::NONE;

View file

@ -47,14 +47,6 @@ class Header
*/
private $sParentCharset;
/**
* @access private
*
* @param string $sName
* @param string $sValue
* @param string $sEncodedValueForReparse
* @param string $sParentCharset = ''
*/
private function __construct($sName, $sValue, $sEncodedValueForReparse, $sParentCharset = '')
{
$this->sParentCharset = $sParentCharset;
@ -62,12 +54,7 @@ class Header
$this->initInputData($sName, $sValue, $sEncodedValueForReparse);
}
/**
* @param string $sName
* @param string $sValue
* @param string $sEncodedValueForReparse
*/
private function initInputData($sName, $sValue, $sEncodedValueForReparse) : void
private function initInputData(string $sName, string $sValue, string $sEncodedValueForReparse) : void
{
$this->sName = trim($sName);
$this->sFullValue = trim($sValue);
@ -99,26 +86,12 @@ class Header
}
}
/**
* @param string $sName
* @param string $sValue = ''
* @param string $sEncodedValueForReparse = ''
* @param string $sParentCharset = ''
*
* @return \MailSo\Mime\Header
*/
public static function NewInstance($sName, $sValue = '', $sEncodedValueForReparse = '', $sParentCharset = '')
public static function NewInstance(string $sName, string $sValue = '', string $sEncodedValueForReparse = '', string $sParentCharset = '') : \MailSo\Mime\Header
{
return new self($sName, $sValue, $sEncodedValueForReparse, $sParentCharset);
}
/**
* @param string $sEncodedLines
* @param string $sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1
*
* @return \MailSo\Mime\Header | false
*/
public static function NewInstanceFromEncodedString($sEncodedLines, $sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1)
public static function NewInstanceFromEncodedString(string $sEncodedLines, string $sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1) : \MailSo\Mime\Header
{
if (empty($sIncomingCharset))
{
@ -139,43 +112,27 @@ class Header
return false;
}
/**
* @return string
*/
public function Name()
public function Name() : string
{
return $this->sName;
}
/**
* @return string
*/
public function NameWithDelimitrom()
public function NameWithDelimitrom() : string
{
return $this->Name().': ';
}
/**
* @return string
*/
public function Value()
public function Value() : string
{
return $this->sValue;
}
/**
* @return string
*/
public function FullValue()
public function FullValue() : string
{
return $this->sFullValue;
}
/**
* @param string $sParentCharset
* @return \MailSo\Mime\Header
*/
public function SetParentCharset($sParentCharset)
public function SetParentCharset(string $sParentCharset) : \MailSo\Mime\Header
{
if ($this->sParentCharset !== $sParentCharset && $this->IsReparsed() && 0 < \strlen($this->sEncodedValueForReparse))
{
@ -191,29 +148,19 @@ class Header
return $this;
}
/**
* @return \MailSo\Mime\ParameterCollection | null
*/
public function Parameters()
public function Parameters() : ?\MailSo\Mime\ParameterCollection
{
return $this->oParameters;
}
/**
* @param string $sValue
* @return string
*/
private function wordWrapHelper($sValue, $sGlue = "\r\n ")
private function wordWrapHelper(string $sValue, string $sGlue = "\r\n ") : string
{
return \trim(substr(wordwrap($this->NameWithDelimitrom().$sValue,
\MailSo\Mime\Enumerations\Constants::LINE_LENGTH, $sGlue
), \strlen($this->NameWithDelimitrom())));
}
/**
* @return string
*/
public function EncodedValue()
public function EncodedValue() : string
{
$sResult = $this->sFullValue;
@ -250,18 +197,12 @@ class Header
return $this->NameWithDelimitrom().$this->wordWrapHelper($sResult);
}
/**
* @return bool
*/
public function IsSubject()
public function IsSubject() : bool
{
return \strtolower(\MailSo\Mime\Enumerations\Header::SUBJECT) === \strtolower($this->Name());
}
/**
* @return bool
*/
public function IsParameterized()
public function IsParameterized() : bool
{
return \in_array(\strtolower($this->sName), array(
\strtolower(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE),
@ -269,10 +210,7 @@ class Header
));
}
/**
* @return bool
*/
public function IsEmail()
public function IsEmail() : bool
{
return \in_array(\strtolower($this->sName), array(
\strtolower(\MailSo\Mime\Enumerations\Header::FROM_),
@ -285,10 +223,7 @@ class Header
));
}
/**
* @return string
*/
public function ValueWithCharsetAutoDetect()
public function ValueWithCharsetAutoDetect() : string
{
$sValue = $this->Value();
if (!\MailSo\Base\Utils::IsAscii($sValue) &&
@ -306,10 +241,7 @@ class Header
return $sValue;
}
/**
* @return bool
*/
public function IsReparsed()
public function IsReparsed() : bool
{
return $this->IsEmail() || $this->IsSubject() || $this->IsParameterized();
}

View file

@ -17,9 +17,7 @@ namespace MailSo\Mime;
*/
class HeaderCollection extends \MailSo\Base\Collection
{
/**
* @return string
*/
protected $sRawHeaders;
/**
@ -27,12 +25,6 @@ class HeaderCollection extends \MailSo\Base\Collection
*/
protected $sParentCharset;
/**
* @access protected
*
* @param string $sRawHeaders = ''
* @param bool $bStoreRawHeaders = true
*/
protected function __construct($sRawHeaders = '', $bStoreRawHeaders = true)
{
parent::__construct();
@ -46,73 +38,42 @@ class HeaderCollection extends \MailSo\Base\Collection
}
}
/**
* @param string $sRawHeaders = ''
* @param bool $bStoreRawHeaders = true
*
* @return \MailSo\Mime\HeaderCollection
*/
public static function NewInstance($sRawHeaders = '', $bStoreRawHeaders = true)
public static function NewInstance(string $sRawHeaders = '', bool $bStoreRawHeaders = true) : \MailSo\Mime\HeaderCollection
{
return new self($sRawHeaders, $bStoreRawHeaders);
}
/**
* @param string $sName
* @param string $sValue
* @param bool $bToTop = false
*
* @return \MailSo\Mime\HeaderCollection
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function AddByName($sName, $sValue, $bToTop = false)
public function AddByName(string $sName, string $sValue, bool $bToTop = false) : \MailSo\Mime\HeaderCollection
{
return $this->Add(Header::NewInstance($sName, $sValue), $bToTop);
}
/**
* @param string $sName
* @param string $sValue
* @param bool $bToTop = false
*
* @return \MailSo\Mime\HeaderCollection
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function SetByName($sName, $sValue, $bToTop = false)
public function SetByName(string $sName, string $sValue, bool $bToTop = false) : \MailSo\Mime\HeaderCollection
{
return $this->RemoveByName($sName)->Add(Header::NewInstance($sName, $sValue), $bToTop);
}
/**
* @return \MailSo\Mime\Header | null
*/
public function &GetByIndex($iIndex)
public function &GetByIndex(int $iIndex) : ?\MailSo\Mime\Header
{
$mResult = null;
$mResult =& parent::GetByIndex($iIndex);
return $mResult;
}
/**
* @param string $sHeaderName
* @param bool $bCharsetAutoDetect = false
* @return string
*/
public function ValueByName($sHeaderName, $bCharsetAutoDetect = false)
public function ValueByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : string
{
$oHeader = null;
$oHeader =& $this->GetByName($sHeaderName);
return (null !== $oHeader) ? ($bCharsetAutoDetect ? $oHeader->ValueWithCharsetAutoDetect() : $oHeader->Value()) : '';
}
/**
* @param string $sHeaderName
* @param bool $bCharsetAutoDetect = false
* @return array
*/
public function ValuesByName($sHeaderName, $bCharsetAutoDetect = false)
public function ValuesByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : array
{
$aResult = array();
$oHeader = null;
@ -130,12 +91,7 @@ class HeaderCollection extends \MailSo\Base\Collection
return $aResult;
}
/**
* @param string $sHeaderName
*
* @return \MailSo\Mime\HeaderCollection
*/
public function RemoveByName($sHeaderName)
public function RemoveByName(string $sHeaderName) : \MailSo\Mime\HeaderCollection
{
$aResult = $this->FilterList(function ($oHeader) use ($sHeaderName) {
return $oHeader && \strtolower($oHeader->Name()) !== \strtolower($sHeaderName);
@ -144,13 +100,7 @@ class HeaderCollection extends \MailSo\Base\Collection
return $this;
}
/**
* @param string $sHeaderName
* @param bool $bCharsetAutoDetect = false
*
* @return \MailSo\Mime\EmailCollection|null
*/
public function GetAsEmailCollection($sHeaderName, $bCharsetAutoDetect = false)
public function GetAsEmailCollection(string $sHeaderName, bool $bCharsetAutoDetect = false) : ?\MailSo\Mime\EmailCollection
{
$oResult = null;
$sValue = $this->ValueByName($sHeaderName, $bCharsetAutoDetect);
@ -162,11 +112,7 @@ class HeaderCollection extends \MailSo\Base\Collection
return $oResult && 0 < $oResult->Count() ? $oResult : null;
}
/**
* @param string $sHeaderName
* @return \MailSo\Mime\ParameterCollection|null
*/
public function ParametersByName($sHeaderName)
public function ParametersByName(string $sHeaderName) : ?\MailSo\Mime\ParameterCollection
{
$oParameters = $oHeader = null;
$oHeader =& $this->GetByName($sHeaderName);
@ -178,22 +124,13 @@ class HeaderCollection extends \MailSo\Base\Collection
return $oParameters;
}
/**
* @param string $sHeaderName
* @param string $sParamName
* @return string
*/
public function ParameterValue($sHeaderName, $sParamName)
public function ParameterValue(string $sHeaderName, string $sParamName) : string
{
$oParameters = $this->ParametersByName($sHeaderName);
return (null !== $oParameters) ? $oParameters->ParameterValueByName($sParamName) : '';
}
/**
* @param string $sHeaderName
* @return \MailSo\Mime\Header | false
*/
public function &GetByName($sHeaderName)
public function &GetByName(string $sHeaderName) : \MailSo\Mime\Header
{
$oResult = $oHeader = null;
@ -211,11 +148,7 @@ class HeaderCollection extends \MailSo\Base\Collection
return $oResult;
}
/**
* @param string $sParentCharset
* @return \MailSo\Mime\HeaderCollection
*/
public function SetParentCharset($sParentCharset)
public function SetParentCharset(string $sParentCharset) : \MailSo\Mime\HeaderCollection
{
if (0 < \strlen($sParentCharset))
{
@ -243,14 +176,7 @@ class HeaderCollection extends \MailSo\Base\Collection
$this->sRawHeaders = '';
}
/**
* @param string $sRawHeaders
* @param bool $bStoreRawHeaders = false
* @param string $sParentCharset = ''
*
* @return \MailSo\Mime\HeaderCollection
*/
public function Parse($sRawHeaders, $bStoreRawHeaders = false, $sParentCharset = '')
public function Parse(string $sRawHeaders, bool $bStoreRawHeaders = false, string $sParentCharset = '') : \MailSo\Mime\HeaderCollection
{
$this->Clear();
@ -340,10 +266,7 @@ class HeaderCollection extends \MailSo\Base\Collection
return $this;
}
/**
* @return int
*/
public function DkimStatuses()
public function DkimStatuses() : int
{
$aResult = array();
@ -419,10 +342,7 @@ class HeaderCollection extends \MailSo\Base\Collection
return $aResult;
}
/**
* @return int
*/
public function PopulateEmailColectionByDkim($oEmails)
public function PopulateEmailColectionByDkim($oEmails) : int
{
if ($oEmails && $oEmails instanceof \MailSo\Mime\EmailCollection)
{
@ -447,10 +367,7 @@ class HeaderCollection extends \MailSo\Base\Collection
}
}
/**
* @return string
*/
public function ToEncodedString()
public function ToEncodedString() : string
{
$aResult = array();
$aHeaders =& $this->GetAsArray();

View file

@ -42,9 +42,6 @@ class Message
*/
private $bAddDefaultXMailer;
/**
* @access private
*/
private function __construct()
{
$this->aHeadersValue = array();
@ -54,38 +51,26 @@ class Message
$this->bAddDefaultXMailer = true;
}
/**
* @return \MailSo\Mime\Message
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @return \MailSo\Mime\Message
*/
public function DoesNotCreateEmptyTextPart()
public function DoesNotCreateEmptyTextPart() : self
{
$this->bAddEmptyTextPart = false;
return $this;
}
/**
* @return \MailSo\Mime\Message
*/
public function DoesNotAddDefaultXMailer()
public function DoesNotAddDefaultXMailer() : self
{
$this->bAddDefaultXMailer = false;
return $this;
}
/**
* @return string
*/
public function MessageId()
public function MessageId() : string
{
$sResult = '';
if (!empty($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::MESSAGE_ID]))
@ -95,43 +80,28 @@ class Message
return $sResult;
}
/**
* @param string $sMessageId
*/
public function SetMessageId($sMessageId) : void
public function SetMessageId(string $sMessageId) : void
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::MESSAGE_ID] = $sMessageId;
}
/**
* @param string $sHostName = ''
*/
public function RegenerateMessageId($sHostName = '') : void
public function RegenerateMessageId(string $sHostName = '') : void
{
$this->SetMessageId($this->generateNewMessageId($sHostName));
}
/**
* @return \MailSo\Mime\AttachmentCollection
*/
public function Attachments()
public function Attachments() : \MailSo\Mime\AttachmentCollection
{
return $this->oAttachmentCollection;
}
/**
* @return string
*/
public function GetSubject()
public function GetSubject() : string
{
return isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SUBJECT]) ?
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SUBJECT] : '';
}
/**
* @return \MailSo\Mime\Email|null
*/
public function GetFrom()
public function GetFrom() : ?\MailSo\Mime\Email
{
$oResult = null;
@ -144,10 +114,7 @@ class Message
return $oResult;
}
/**
* @return \MailSo\Mime\EmailCollection
*/
public function GetTo()
public function GetTo() : \MailSo\Mime\EmailCollection
{
$oResult = \MailSo\Mime\EmailCollection::NewInstance();
@ -160,10 +127,7 @@ class Message
return $oResult->Unique();
}
/**
* @return \MailSo\Mime\EmailCollection|null
*/
public function GetBcc()
public function GetBcc() : ?\MailSo\Mime\EmailCollection
{
$oResult = null;
@ -176,10 +140,7 @@ class Message
return $oResult ? $oResult->Unique() : null;
}
/**
* @return \MailSo\Mime\EmailCollection
*/
public function GetRcpt()
public function GetRcpt() : \MailSo\Mime\EmailCollection
{
$oResult = \MailSo\Mime\EmailCollection::NewInstance();
@ -204,13 +165,7 @@ class Message
return $oResult->Unique();
}
/**
* @param string $sHeaderName
* @param string $sValue
*
* @return \MailSo\Mime\Message
*/
public function SetCustomHeader($sHeaderName, $sValue)
public function SetCustomHeader(string $sHeaderName, string $sValue) : self
{
$sHeaderName = \trim($sHeaderName);
if (0 < \strlen($sHeaderName))
@ -221,36 +176,21 @@ class Message
return $this;
}
/**
* @param string $sSubject
*
* @return \MailSo\Mime\Message
*/
public function SetSubject($sSubject)
public function SetSubject(string $sSubject) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SUBJECT] = $sSubject;
return $this;
}
/**
* @param string $sInReplyTo
*
* @return \MailSo\Mime\Message
*/
public function SetInReplyTo($sInReplyTo)
public function SetInReplyTo(string $sInReplyTo) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::IN_REPLY_TO] = $sInReplyTo;
return $this;
}
/**
* @param string $sReferences
*
* @return \MailSo\Mime\Message
*/
public function SetReferences($sReferences)
public function SetReferences(string $sReferences) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::REFERENCES] =
\MailSo\Base\Utils::StripSpaces($sReferences);
@ -258,12 +198,7 @@ class Message
return $this;
}
/**
* @param string $sEmail
*
* @return \MailSo\Mime\Message
*/
public function SetReadReceipt($sEmail)
public function SetReadReceipt(string $sEmail) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::DISPOSITION_NOTIFICATION_TO] = $sEmail;
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_CONFIRM_READING_TO] = $sEmail;
@ -271,22 +206,12 @@ class Message
return $this;
}
/**
* @param string $sEmail
*
* @return \MailSo\Mime\Message
*/
public function SetReadConfirmation($sEmail)
public function SetReadConfirmation(string $sEmail) : self
{
return $this->SetReadReceipt($sEmail);
}
/**
* @param int $iValue
*
* @return \MailSo\Mime\Message
*/
public function SetPriority($iValue)
public function SetPriority(int $iValue) : self
{
$sResult = '';
switch ($iValue)
@ -310,12 +235,7 @@ class Message
return $this;
}
/**
* @param int $iValue
*
* @return \MailSo\Mime\Message
*/
public function SetSensitivity($iValue)
public function SetSensitivity(int $iValue) : self
{
$sResult = '';
switch ($iValue)
@ -339,110 +259,63 @@ class Message
return $this;
}
/**
* @param string $sXMailer
*
* @return \MailSo\Mime\Message
*/
public function SetXMailer($sXMailer)
public function SetXMailer(string $sXMailer) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_MAILER] = $sXMailer;
return $this;
}
/**
* @param \MailSo\Mime\Email $oEmail
*
* @return \MailSo\Mime\Message
*/
public function SetFrom(\MailSo\Mime\Email $oEmail)
public function SetFrom(\MailSo\Mime\Email $oEmail) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::FROM_] = $oEmail;
return $this;
}
/**
* @param \MailSo\Mime\EmailCollection $oEmails
*
* @return \MailSo\Mime\Message
*/
public function SetTo(\MailSo\Mime\EmailCollection $oEmails)
public function SetTo(\MailSo\Mime\EmailCollection $oEmails) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::TO_] = $oEmails;
return $this;
}
/**
* @param int $iDateTime
*
* @return \MailSo\Mime\Message
*/
public function SetDate($iDateTime)
public function SetDate(int $iDateTime) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::DATE] = gmdate('r', $iDateTime);
return $this;
}
/**
* @param \MailSo\Mime\EmailCollection $oEmails
*
* @return \MailSo\Mime\Message
*/
public function SetReplyTo(\MailSo\Mime\EmailCollection $oEmails)
public function SetReplyTo(\MailSo\Mime\EmailCollection $oEmails) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::REPLY_TO] = $oEmails;
return $this;
}
/**
* @param \MailSo\Mime\EmailCollection $oEmails
*
* @return \MailSo\Mime\Message
*/
public function SetCc(\MailSo\Mime\EmailCollection $oEmails)
public function SetCc(\MailSo\Mime\EmailCollection $oEmails) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::CC] = $oEmails;
return $this;
}
/**
* @param \MailSo\Mime\EmailCollection $oEmails
*
* @return \MailSo\Mime\Message
*/
public function SetBcc(\MailSo\Mime\EmailCollection $oEmails)
public function SetBcc(\MailSo\Mime\EmailCollection $oEmails) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC] = $oEmails;
return $this;
}
/**
* @param \MailSo\Mime\EmailCollection $oEmails
*
* @return \MailSo\Mime\Message
*/
public function SetSender(\MailSo\Mime\EmailCollection $oEmails)
public function SetSender(\MailSo\Mime\EmailCollection $oEmails) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SENDER] = $oEmails;
return $this;
}
/**
* @param string $sType
* @param string $sUid
* @param string $sFolder
*
* @return \MailSo\Mime\Message
*/
public function SetDraftInfo($sType, $sUid, $sFolder)
public function SetDraftInfo(string $sType, string $sUid, string $sFolder) : self
{
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_DRAFT_INFO] = \MailSo\Mime\ParameterCollection::NewInstance()
->Add(\MailSo\Mime\Parameter::NewInstance('type', $sType))
@ -453,70 +326,39 @@ class Message
return $this;
}
/**
* @param string $sPlain
*
* @return \MailSo\Mime\Message
*/
public function AddPlain($sPlain)
public function AddPlain(string $sPlain) : self
{
return $this->AddAlternative(
\MailSo\Mime\Enumerations\MimeType::TEXT_PLAIN, trim($sPlain),
\MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER);
}
/**
* @param string $sHtml
*
* @return \MailSo\Mime\Message
*/
public function AddHtml($sHtml)
public function AddHtml(string $sHtml) : self
{
return $this->AddAlternative(
\MailSo\Mime\Enumerations\MimeType::TEXT_HTML, trim($sHtml),
\MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER);
}
/**
* @param string $sHtmlOrPlainText
* @param bool $bIsHtml = false
*
* @return \MailSo\Mime\Message
*/
public function AddText($sHtmlOrPlainText, $bIsHtml = false)
public function AddText(string $sHtmlOrPlainText, bool $bIsHtml = false) : self
{
return $bIsHtml ? $this->AddHtml($sHtmlOrPlainText) : $this->AddPlain($sHtmlOrPlainText);
}
/**
* @param string $sContentType
* @param string|resource $mData
* @param string $sContentTransferEncoding = ''
* @param array $aCustomContentTypeParams = array()
*
* @return \MailSo\Mime\Message
*/
public function AddAlternative($sContentType, $mData, $sContentTransferEncoding = '', $aCustomContentTypeParams = array())
public function AddAlternative(string $sContentType, $mData, string $sContentTransferEncoding = '', array $aCustomContentTypeParams = array()) : self
{
$this->aAlternativeParts[] = array($sContentType, $mData, $sContentTransferEncoding, $aCustomContentTypeParams);
return $this;
}
/**
* @return string
*/
private function generateNewBoundary()
private function generateNewBoundary() : string
{
return '--='.\MailSo\Config::$BoundaryPrefix.
\rand(100, 999).'_'.rand(100000000, 999999999).'.'.\time();
}
/**
* @param string $sHostName = ''
*
* @return string
*/
private function generateNewMessageId($sHostName = '')
private function generateNewMessageId(string $sHostName = '') : string
{
if (0 === \strlen($sHostName))
{
@ -538,12 +380,7 @@ class Message
(\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? @\getmypid() : '')).'@'.$sHostName.'>';
}
/**
* @param \MailSo\Mime\Attachment $oAttachment
*
* @return \MailSo\Mime\Part
*/
private function createNewMessageAttachmentBody($oAttachment)
private function createNewMessageAttachmentBody(\MailSo\Mime\Attachment $oAttachment) : \MailSo\Mime\Part
{
$oAttachmentPart = Part::NewInstance();
@ -621,12 +458,7 @@ class Message
return $oAttachmentPart;
}
/**
* @param array $aAlternativeData
*
* @return \MailSo\Mime\Part
*/
private function createNewMessageAlternativePartBody($aAlternativeData)
private function createNewMessageAlternativePartBody(array $aAlternativeData) : \MailSo\Mime\Part
{
$oAlternativePart = null;
@ -699,13 +531,7 @@ class Message
return $oAlternativePart;
}
/**
* @param \MailSo\Mime\Part $oPlainPart
* @param \MailSo\Mime\Part $oHtmlPart
*
* @return \MailSo\Mime\Part
*/
private function createNewMessageSimpleOrAlternativeBody()
private function createNewMessageSimpleOrAlternativeBody() : \MailSo\Mime\Part
{
$oResultPart = null;
if (1 < count($this->aAlternativeParts))
@ -770,12 +596,7 @@ class Message
return $oResultPart;
}
/**
* @param \MailSo\Mime\Part $oIncPart
*
* @return \MailSo\Mime\Part
*/
private function createNewMessageRelatedBody($oIncPart)
private function createNewMessageRelatedBody(\MailSo\Mime\Part $oIncPart) : \MailSo\Mime\Part
{
$oResultPart = null;
@ -810,12 +631,7 @@ class Message
return $oResultPart;
}
/**
* @param \MailSo\Mime\Part $oIncPart
*
* @return \MailSo\Mime\Part
*/
private function createNewMessageMixedBody($oIncPart)
private function createNewMessageMixedBody(\MailSo\Mime\Part $oIncPart) : \MailSo\Mime\Part
{
$oResultPart = null;
@ -848,13 +664,7 @@ class Message
return $oResultPart;
}
/**
* @param \MailSo\Mime\Part $oIncPart
* @param bool $bWithoutBcc = false
*
* @return \MailSo\Mime\Part
*/
private function setDefaultHeaders($oIncPart, $bWithoutBcc = false)
private function setDefaultHeaders(\MailSo\Mime\Part $oIncPart, bool $bWithoutBcc = false) : \MailSo\Mime\Part
{
if (!isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::DATE]))
{
@ -896,12 +706,7 @@ class Message
return $oIncPart;
}
/**
* @param bool $bWithoutBcc = false
*
* @return \MailSo\Mime\Part
*/
public function ToPart($bWithoutBcc = false)
public function ToPart(bool $bWithoutBcc = false) : \MailSo\Mime\Part
{
$oPart = $this->createNewMessageSimpleOrAlternativeBody();
$oPart = $this->createNewMessageRelatedBody($oPart);
@ -912,21 +717,14 @@ class Message
}
/**
* @param bool $bWithoutBcc = false
*
* @return resource
*/
public function ToStream($bWithoutBcc = false)
public function ToStream(bool $bWithoutBcc = false)
{
return $this->ToPart($bWithoutBcc)->ToStream();
}
/**
* @param bool $bWithoutBcc = false
*
* @return string
*/
public function ToString($bWithoutBcc = false)
public function ToString(bool $bWithoutBcc = false) : string
{
return \stream_get_contents($this->ToStream($bWithoutBcc));
}

View file

@ -27,45 +27,24 @@ class Parameter
*/
private $sValue;
/**
* @access private
*
* @param string $sName
* @param string $sValue
*/
private function __construct($sName, $sValue)
{
$this->sName = $sName;
$this->sValue = $sValue;
}
/**
* @param string $sName
* @param string $sValue = ''
*
* @return \MailSo\Mime\Parameter
*/
public static function NewInstance($sName, $sValue = '')
public static function NewInstance(string $sName, string $sValue = '') : self
{
return new self($sName, $sValue);
}
/**
* @param string $sName
* @param string $sValue = ''
*
* @return \MailSo\Mime\Parameter
*/
public static function CreateFromParameterLine($sRawParam)
public static function CreateFromParameterLine(string $sRawParam) : self
{
$oParameter = self::NewInstance('');
return $oParameter->Parse($sRawParam);
}
/**
* @return \MailSo\Mime\Parameter
*/
public function Reset()
public function Reset() : self
{
$this->sName = '';
$this->sValue = '';
@ -73,29 +52,17 @@ class Parameter
return $this;
}
/**
* @return string
*/
public function Name()
public function Name() : string
{
return $this->sName;
}
/**
* @return string
*/
public function Value()
public function Value() : string
{
return $this->sValue;
}
/**
* @param string $sRawParam
* @param string $sSeparator = '='
*
* @return \MailSo\Mime\Parameter
*/
public function Parse($sRawParam, $sSeparator = '=')
public function Parse(string $sRawParam, string $sSeparator = '=') : self
{
$this->Reset();
@ -110,12 +77,7 @@ class Parameter
return $this;
}
/**
* @param bool $bConvertSpecialsName = false
*
* @return string
*/
public function ToString($bConvertSpecialsName = false)
public function ToString(bool $bConvertSpecialsName = false) : string
{
$sResult = '';
if (0 < strlen($this->sName))

View file

@ -17,11 +17,6 @@ namespace MailSo\Mime;
*/
class ParameterCollection extends \MailSo\Base\Collection
{
/**
* @access protected
*
* @param string $sRawParams = ''
*/
protected function __construct($sRawParams = '')
{
parent::__construct();
@ -32,32 +27,19 @@ class ParameterCollection extends \MailSo\Base\Collection
}
}
/**
* @param string $sRawParams = ''
*
* @return \MailSo\Mime\ParameterCollection
*/
public static function NewInstance($sRawParams = '')
public static function NewInstance(string $sRawParams = '') : self
{
return new self($sRawParams);
}
/**
* @return \MailSo\Mime\Parameter|null
*/
public function &GetByIndex($iIndex)
public function &GetByIndex(int $iIndex) : ?\MailSo\Mime\Parameter
{
$mResult = null;
$mResult =& parent::GetByIndex($iIndex);
return $mResult;
}
/**
* @param string $sName
*
* @return string
*/
public function ParameterValueByName($sName)
public function ParameterValueByName(string $sName) : string
{
$sResult = '';
$sName = \trim($sName);
@ -75,12 +57,7 @@ class ParameterCollection extends \MailSo\Base\Collection
return $sResult;
}
/**
* @param string $sRawParams
*
* @return \MailSo\Mime\ParameterCollection
*/
public function Parse($sRawParams)
public function Parse(string $sRawParams) : self
{
$this->Clear();
@ -96,12 +73,7 @@ class ParameterCollection extends \MailSo\Base\Collection
return $this;
}
/**
* @param bool $bConvertSpecialsName = false
*
* @return string
*/
public function ToString($bConvertSpecialsName = false)
public function ToString(bool $bConvertSpecialsName = false) : string
{
$aResult = array();
$aParams =& $this->GetAsArray();

View file

@ -69,27 +69,18 @@ class Part
*/
private $iParseBuffer;
/**
* @access private
*/
private function __construct()
{
$this->iParseBuffer = \MailSo\Mime\Part::DEFAUL_BUFFER;
$this->Reset();
}
/**
* @return \MailSo\Mime\Part
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @return \MailSo\Mime\Part
*/
public function Reset()
public function Reset() : self
{
\MailSo\Base\ResourceRegistry::CloseMemoryResource($this->Body);
$this->Body = null;
@ -103,117 +94,78 @@ class Part
return $this;
}
/**
* @return string
*/
public function Boundary()
public function Boundary() : string
{
return $this->sBoundary;
}
/**
* @return string
*/
public function ParentCharset()
public function ParentCharset() : string
{
return (0 < \strlen($this->sCharset)) ? $this->sParentCharset : self::$DefaultCharset;
}
/**
* @param string $sParentCharset
* @return \MailSo\Mime\Part
*/
public function SetParentCharset($sParentCharset)
public function SetParentCharset(string $sParentCharset) : self
{
$this->sParentCharset = $sParentCharset;
return $this;
}
/**
* @param string $sBoundary
* @return \MailSo\Mime\Part
*/
public function SetBoundary($sBoundary)
public function SetBoundary(string $sBoundary) : self
{
$this->sBoundary = $sBoundary;
return $this;
}
/**
* @param int $iParseBuffer
* @return \MailSo\Mime\Part
*/
public function SetParseBuffer($iParseBuffer)
public function SetParseBuffer(int $iParseBuffer) : self
{
$this->iParseBuffer = $iParseBuffer;
return $this;
}
/**
* @return string
*/
public function HeaderCharset()
public function HeaderCharset() : string
{
return ($this->Headers) ? trim(strtolower($this->Headers->ParameterValue(
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
\MailSo\Mime\Enumerations\Parameter::CHARSET))) : '';
}
/**
* @return string
*/
public function HeaderBoundary()
public function HeaderBoundary() : string
{
return ($this->Headers) ? trim($this->Headers->ParameterValue(
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
\MailSo\Mime\Enumerations\Parameter::BOUNDARY)) : '';
}
/**
* @return string
*/
public function ContentType()
public function ContentType() : string
{
return ($this->Headers) ?
trim(strtolower($this->Headers->ValueByName(
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE))) : '';
}
/**
* @return string
*/
public function ContentTransferEncoding()
public function ContentTransferEncoding() : string
{
return ($this->Headers) ?
trim(strtolower($this->Headers->ValueByName(
\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING))) : '';
}
/**
* @return string
*/
public function ContentID()
public function ContentID() : string
{
return ($this->Headers) ? trim($this->Headers->ValueByName(
\MailSo\Mime\Enumerations\Header::CONTENT_ID)) : '';
}
/**
* @return string
*/
public function ContentLocation()
public function ContentLocation() : string
{
return ($this->Headers) ? trim($this->Headers->ValueByName(
\MailSo\Mime\Enumerations\Header::CONTENT_LOCATION)) : '';
}
/**
* @return bool
*/
public function IsFlowedFormat()
public function IsFlowedFormat() : bool
{
$bResult = false;
if ($this->Headers)
@ -231,10 +183,7 @@ class Part
return $bResult;
}
/**
* @return string
*/
public function FileName()
public function FileName() : string
{
$sResult = '';
if ($this->Headers)
@ -254,11 +203,7 @@ class Part
return $sResult;
}
/**
* @param string $sFileName
* @return \MailSo\Mime\Part
*/
public function ParseFromFile($sFileName)
public function ParseFromFile(string $sFileName) : self
{
$rStreamHandle = (@file_exists($sFileName)) ? @fopen($sFileName, 'rb') : false;
if (is_resource($rStreamHandle))
@ -274,11 +219,7 @@ class Part
return $this;
}
/**
* @param string $sRawMessage
* @return \MailSo\Mime\Part
*/
public function ParseFromString($sRawMessage)
public function ParseFromString(string $sRawMessage) : self
{
$rStreamHandle = (0 < strlen($sRawMessage)) ?
\MailSo\Base\ResourceRegistry::CreateMemoryResource() : false;
@ -299,9 +240,8 @@ class Part
/**
* @param resource $rStreamHandle
* @return \MailSo\Mime\Part
*/
public function ParseFromStream($rStreamHandle)
public function ParseFromStream($rStreamHandle) : self
{
$this->Reset();
@ -361,10 +301,9 @@ class Part
/**
* @param resource $rStreamHandle
* @return \MailSo\Mime\Part
*/
public function ParseFromStreamRecursion($rStreamHandle, &$oCallbackClass, &$iOffset,
&$sPrevBuffer, &$sBuffer, &$aBoundaryStack, &$bIsOef, $bNotFirstRead = false)
public function ParseFromStreamRecursion($rStreamHandle, &$oCallbackClass, int &$iOffset,
string &$sPrevBuffer, string &$sBuffer, array &$aBoundaryStack, bool &$bIsOef, bool $bNotFirstRead = false) : self
{
$oCallbackClass->StartParseMimePart($this);
@ -610,7 +549,7 @@ class Part
}
/**
* @return resorce
* @return resource
*/
public function Rewind()
{
@ -625,7 +564,7 @@ class Part
}
/**
* @return resorce
* @return resource
*/
public function ToStream()
{

View file

@ -17,28 +17,20 @@ namespace MailSo\Mime;
*/
class PartCollection extends \MailSo\Base\Collection
{
/**
* @access protected
*/
protected function __construct()
{
parent::__construct();
}
/**
* @return \MailSo\Mime\PartCollection
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @param string $sBoundary
*
* @return resorce
* @return resource
*/
public function ToStream($sBoundary)
public function ToStream(string $sBoundary)
{
$rResult = null;
if (0 < \strlen($sBoundary))

View file

@ -23,13 +23,7 @@ class ConnectionSecurityType
const STARTTLS = 2;
const AUTO_DETECT = 9;
/**
* @param int $iPort
* @param int $iSecurityType
*
* @return bool
*/
public static function UseSSL($iPort, $iSecurityType)
public static function UseSSL(int $iPort, int $iSecurityType) : bool
{
$iPort = (int) $iPort;
$iResult = (int) $iSecurityType;
@ -53,14 +47,7 @@ class ConnectionSecurityType
return self::SSL === $iResult;
}
/**
* @param bool $bSupported
* @param int $iSecurityType
* @param bool $bHasSupportedAuth = true
*
* @return bool
*/
public static function UseStartTLS($bSupported, $iSecurityType, $bHasSupportedAuth = true)
public static function UseStartTLS(bool $bSupported, int $iSecurityType, bool $bHasSupportedAuth = true) : bool
{
return ($bSupported &&
(self::STARTTLS === $iSecurityType ||

View file

@ -29,10 +29,6 @@ class SocketCanNotConnectToHostException extends \MailSo\Net\Exceptions\Connecti
private $iSocketCode;
/**
* @param string $sSocketMessage = ''
* @param int $iSocketCode = 0
* @param string $sMessage = ''
* @param int $iCode = 0
* @param \Exception $oPrevious = null
*/
public function __construct($sSocketMessage = '', $iSocketCode = 0, $sMessage = '', $iCode = 0, $oPrevious = null)
@ -43,18 +39,12 @@ class SocketCanNotConnectToHostException extends \MailSo\Net\Exceptions\Connecti
$this->iSocketCode = $iSocketCode;
}
/**
* @return string
*/
public function getSocketMessage()
public function getSocketMessage() : string
{
return $this->sSocketMessage;
}
/**
* @return int
*/
public function getSocketCode()
public function getSocketCode() : int
{
return $this->iSocketCode;
}

View file

@ -82,9 +82,6 @@ abstract class NetClient
*/
public $__AUTOLOGOUT__;
/**
* @access protected
*/
protected function __construct()
{
$this->rConnect = null;
@ -121,7 +118,7 @@ abstract class NetClient
$this->Disconnect();
}
}
catch (\Exception $oException) {}
catch (\Throwable $oException) {}
}
public function Clear() : void
@ -159,35 +156,20 @@ abstract class NetClient
return $this->rConnect;
}
/**
* @param int $iErrNo
* @param string $sErrStr
* @param string $sErrFile
* @param int $iErrLine
*
* @return bool
*/
public function capturePhpErrorWithException($iErrNo, $sErrStr, $sErrFile, $iErrLine)
public function capturePhpErrorWithException(int $iErrNo, string $sErrStr, string $sErrFile, int $iErrLine) : bool
{
throw new \MailSo\Base\Exceptions\Exception($sErrStr, $iErrNo);
}
/**
* @param string $sServerName
* @param int $iPort
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param bool $bAllowSelfSigned = true
* @param string $sClientCert = ''
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\SocketAlreadyConnectedException
* @throws \MailSo\Net\Exceptions\SocketCanNotConnectToHostException
*/
public function Connect($sServerName, $iPort,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true,
$sClientCert = '') : void
public function Connect(string $sServerName, int $iPort,
int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
bool $bVerifySsl = false, bool $bAllowSelfSigned = true,
string $sClientCert = '') : void
{
if (!\MailSo\Base\Validator::NotEmptyString($sServerName, true) || !\MailSo\Base\Validator::PortInt($iPort))
{
@ -261,7 +243,7 @@ abstract class NetClient
$this->rConnect = \stream_socket_client($this->sConnectedHost.':'.$this->iConnectedPort,
$iErrorNo, $sErrorStr, $this->iConnectTimeOut, STREAM_CLIENT_CONNECT, $rStreamContext);
}
catch (\Exception $oExc)
catch (\Throwable $oExc)
{
$sErrorStr = $oExc->getMessage();
$iErrorNo = $oExc->getCode();
@ -354,12 +336,7 @@ abstract class NetClient
$this->Disconnect();
}
/**
* @param bool $bThrowExceptionOnFalse = false
*
* @return bool
*/
public function IsConnected($bThrowExceptionOnFalse = false)
public function IsConnected(bool $bThrowExceptionOnFalse = false) : bool
{
$bResult = \is_resource($this->rConnect);
if (!$bResult && $bThrowExceptionOnFalse)
@ -380,24 +357,17 @@ abstract class NetClient
$this->IsConnected(true);
}
/**
* @return array|bool
*/
public function StreamContextParams()
public function StreamContextParams() : array
{
return \is_resource($this->rConnect) && \MailSo\Base\Utils::FunctionExistsAndEnabled('stream_context_get_options')
? \stream_context_get_params($this->rConnect) : false;
}
/**
* @param string $sRaw
* @param bool $bWriteToLog = true
* @param string $sFakeRaw = ''
*
* @throws \MailSo\Net\Exceptions\SocketConnectionDoesNotAvailableException
* @throws \MailSo\Net\Exceptions\SocketWriteException
*/
protected function sendRaw($sRaw, $bWriteToLog = true, $sFakeRaw = '') : void
protected function sendRaw(string $sRaw, bool $bWriteToLog = true, string $sFakeRaw = '') : void
{
if ($this->bUnreadBuffer)
{
@ -442,12 +412,11 @@ abstract class NetClient
/**
* @param mixed $mReadLen = null
* @param bool $bForceLogin = false
*
* @throws \MailSo\Net\Exceptions\SocketConnectionDoesNotAvailableException
* @throws \MailSo\Net\Exceptions\SocketReadException
*/
protected function getNextBuffer($mReadLen = null, $bForceLogin = false) : void
protected function getNextBuffer($mReadLen = null, bool $bForceLogin = false) : void
{
if (null === $mReadLen)
{
@ -520,19 +489,12 @@ abstract class NetClient
}
}
/**
* @return string
*/
protected function getLogName()
protected function getLogName() : string
{
return 'NET';
}
/**
* @param string $sDesc
* @param int $iDescType = \MailSo\Log\Enumerations\Type::INFO
*/
protected function writeLog($sDesc, $iDescType = \MailSo\Log\Enumerations\Type::INFO, $bDiplayCrLf = false) : void
protected function writeLog(string $sDesc, int $iDescType = \MailSo\Log\Enumerations\Type::INFO, bool $bDiplayCrLf = false) : void
{
if ($this->oLogger)
{
@ -540,22 +502,16 @@ abstract class NetClient
}
}
/**
* @param string $sDesc
* @param int $iDescType = \MailSo\Log\Enumerations\Type::INFO
*/
protected function writeLogWithCrlf($sDesc, $iDescType = \MailSo\Log\Enumerations\Type::INFO) : void
protected function writeLogWithCrlf(string $sDesc, int $iDescType = \MailSo\Log\Enumerations\Type::INFO) : void
{
$this->writeLog($sDesc, $iDescType, true);
}
/**
* @param \Exception $oException
* @param int $iDescType = \MailSo\Log\Enumerations\Type::NOTICE
* @param bool $bThrowException = false
*/
protected function writeLogException($oException,
$iDescType = \MailSo\Log\Enumerations\Type::NOTICE, $bThrowException = false) : void
int $iDescType = \MailSo\Log\Enumerations\Type::NOTICE, bool $bThrowException = false) : void
{
if ($this->oLogger)
{
@ -573,25 +529,12 @@ abstract class NetClient
}
}
/**
* @param \MailSo\Log\Logger $oLogger
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function SetLogger($oLogger) : void
public function SetLogger(\MailSo\Log\Logger $oLogger) : void
{
if (!($oLogger instanceof \MailSo\Log\Logger))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
$this->oLogger = $oLogger;
}
/**
* @return \MailSo\Log\Logger|null
*/
public function Logger()
public function Logger() : ?\MailSo\Log\Logger
{
return $this->oLogger;
}

View file

@ -24,9 +24,6 @@ class ResponseException extends \MailSo\Sieve\Exceptions\Exception
private $aResponses;
/**
* @param array $aResponses = array
* @param string $sMessage = ''
* @param int $iCode = 0
* @param \Exception $oPrevious = null
*/
public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null)
@ -39,18 +36,12 @@ class ResponseException extends \MailSo\Sieve\Exceptions\Exception
}
}
/**
* @return array
*/
public function GetResponses()
public function GetResponses() : array
{
return $this->aResponses;
}
/**
* @return \MailSo\Sieve\Response | null
*/
public function GetLastResponse()
public function GetLastResponse() : ?\MailSo\Sieve\Response
{
return 0 < count($this->aResponses) ? $this->aResponses[count($this->aResponses) - 1] : null;
}

View file

@ -37,9 +37,6 @@ class ManageSieveClient extends \MailSo\Net\NetClient
*/
public $__USE_INITIAL_AUTH_PLAIN_COMMAND;
/**
* @access protected
*/
protected function __construct()
{
parent::__construct();
@ -52,66 +49,39 @@ class ManageSieveClient extends \MailSo\Net\NetClient
$this->__USE_INITIAL_AUTH_PLAIN_COMMAND = true;
}
/**
* @return \MailSo\Sieve\ManageSieveClient
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @param string $sCapa
*
* @return bool
*/
public function IsSupported($sCapa)
public function IsSupported(string $sCapa) : bool
{
return isset($this->aCapa[\strtoupper($sCapa)]);
}
/**
* @param string $sModule
*
* @return bool
*/
public function IsModuleSupported($sModule)
public function IsModuleSupported(string $sModule) : bool
{
return $this->IsSupported('SIEVE') && \in_array(\strtolower(\trim($sModule)), $this->aModules);
}
/**
* @return array
*/
public function Modules()
public function Modules() : array
{
return $this->aModules;
}
/**
* @param string $sAuth
*
* @return bool
*/
public function IsAuthSupported($sAuth)
public function IsAuthSupported(string $sAuth) : bool
{
return $this->IsSupported('SASL') && \in_array(\strtoupper($sAuth), $this->aAuth);
}
/**
* @param string $sServerName
* @param int $iPort
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param bool $bAllowSelfSigned = true
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Sieve\Exceptions\ResponseException
*/
public function Connect($sServerName, $iPort,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true, $sClientCert = '') : void
public function Connect(string $sServerName, int $iPort,
int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
bool $bVerifySsl = false, bool $bAllowSelfSigned = true, string $sClientCert = '') : void
{
$this->iRequestTime = \microtime(true);
@ -140,17 +110,11 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @param string $sLogin
* @param string $sPassword
* @param string $sLoginAuthKey = ''
*
* @return \MailSo\Sieve\ManageSieveClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Sieve\Exceptions\LoginException
*/
public function Login($sLogin, $sPassword, $sLoginAuthKey = '')
public function Login(string $sLogin, string $sPassword, string $sLoginAuthKey = '') : self
{
if (!\MailSo\Base\Validator::NotEmptyString($sLogin, true) ||
!\MailSo\Base\Validator::NotEmptyString($sPassword, true))
@ -229,12 +193,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @return \MailSo\Sieve\ManageSieveClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function Logout()
public function Logout() : self
{
if ($this->bIsLoggined)
{
@ -246,12 +208,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @return array
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function ListScripts()
public function ListScripts() : array
{
$this->sendRequest('LISTSCRIPTS');
$mResponse = $this->parseResponse();
@ -276,12 +236,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @return array
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function Capability()
public function Capability() : array
{
$this->sendRequest('CAPABILITY');
$mResponse = $this->parseResponse();
@ -292,12 +250,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @return \MailSo\Sieve\ManageSieveClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function Noop()
public function Noop() : self
{
$this->sendRequestWithCheck('NOOP');
@ -305,14 +261,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @param string $sScriptName
*
* @return string
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function GetScript($sScriptName)
public function GetScript(string $sScriptName) : string
{
$this->sendRequest('GETSCRIPT "'.$sScriptName.'"');
$mResponse = $this->parseResponse();
@ -338,15 +290,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @param string $sScriptName
* @param string $sScriptSource
*
* @return \MailSo\Sieve\ManageSieveClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function PutScript($sScriptName, $sScriptSource)
public function PutScript(string $sScriptName, string $sScriptSource) : self
{
$this->sendRequest('PUTSCRIPT "'.$sScriptName.'" {'.\strlen($sScriptSource).'+}');
$this->sendRequestWithCheck($sScriptSource);
@ -355,14 +302,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @param string $sScriptSource
*
* @return \MailSo\Sieve\ManageSieveClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function CheckScript($sScriptSource)
public function CheckScript(string $sScriptSource) : self
{
$this->sendRequest('CHECKSCRIPT {'.\strlen($sScriptSource).'+}');
$this->sendRequestWithCheck($sScriptSource);
@ -371,14 +314,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @param string $sScriptName
*
* @return \MailSo\Sieve\ManageSieveClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function SetActiveScript($sScriptName)
public function SetActiveScript(string $sScriptName) : self
{
$this->sendRequestWithCheck('SETACTIVE "'.$sScriptName.'"');
@ -386,14 +325,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @param string $sScriptName
*
* @return \MailSo\Sieve\ManageSieveClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function DeleteScript($sScriptName)
public function DeleteScript(string $sScriptName) : self
{
$this->sendRequestWithCheck('DELETESCRIPT "'.$sScriptName.'"');
@ -401,12 +336,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @return string
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function GetActiveScriptName()
public function GetActiveScriptName() : string
{
$aList = $this->ListScripts();
if (\is_array($aList) && 0 < \count($aList))
@ -424,23 +357,15 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @param string $sScriptName
*
* @return bool
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
public function IsActiveScript($sScriptName)
public function IsActiveScript(string $sScriptName) : bool
{
return $sScriptName === $this->GetActiveScriptName();
}
/**
* @param string $sLine
* @return array|false
*/
private function parseLine($sLine)
private function parseLine(string $sLine) : array
{
if (false === $sLine || null === $sLine || \in_array(\substr($sLine, 0, 2), array('OK', 'NO')))
{
@ -472,8 +397,6 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @param string $mResponse
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
*/
@ -507,12 +430,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @param string $sRequest
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
*/
private function sendRequest($sRequest) : void
private function sendRequest(string $sRequest) : void
{
if (!\MailSo\Base\Validator::NotEmptyString($sRequest, true))
{
@ -527,24 +448,16 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
/**
* @param string $sRequest
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
private function sendRequestWithCheck($sRequest) : void
private function sendRequestWithCheck(string $sRequest) : void
{
$this->sendRequest($sRequest);
$this->validateResponse($this->parseResponse());
}
/**
* @param string $sLine
*
* @return string
*/
private function convertEndOfLine($sLine)
private function convertEndOfLine(string $sLine) : string
{
$sLine = \trim($sLine);
if ('}' === \substr($sLine, -1))
@ -570,10 +483,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
return $sLine;
}
/**
* @return array|bool
*/
private function parseResponse()
private function parseResponse() : array
{
$this->iRequestTime = \microtime(true);
@ -608,7 +518,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
/**
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/
private function validateResponse($aResponse)
private function validateResponse(array $aResponse)
{
if (!\is_array($aResponse) || 0 === \count($aResponse) ||
'OK' !== \substr($aResponse[\count($aResponse) - 1], 0, 2))
@ -619,10 +529,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
}
}
/**
* @return string
*/
protected function getLogName()
protected function getLogName() : string
{
return 'SIEVE';
}

View file

@ -24,9 +24,6 @@ class ResponseException extends \MailSo\Smtp\Exceptions\Exception
private $aResponses;
/**
* @param array $aResponses = array
* @param string $sMessage = ''
* @param int $iCode = 0
* @param \Exception $oPrevious = null
*/
public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null)
@ -39,18 +36,12 @@ class ResponseException extends \MailSo\Smtp\Exceptions\Exception
}
}
/**
* @return array
*/
public function GetResponses()
public function GetResponses() : array
{
return $this->aResponses;
}
/**
* @return \MailSo\Smtp\Response | null
*/
public function GetLastResponse()
public function GetLastResponse() : ?\MailSo\Smtp\Response
{
return 0 < count($this->aResponses) ? $this->aResponses[count($this->aResponses) - 1] : null;
}

View file

@ -67,9 +67,6 @@ class SmtpClient extends \MailSo\Net\NetClient
*/
public $__USE_SINGLE_LINE_AUTH_PLAIN_COMMAND = false;
/**
* @access protected
*/
protected function __construct()
{
parent::__construct();
@ -87,42 +84,27 @@ class SmtpClient extends \MailSo\Net\NetClient
$this->bData = false;
}
/**
* @return \MailSo\Smtp\SmtpClient
*/
public static function NewInstance()
public static function NewInstance() : self
{
return new self();
}
/**
* @return bool
*/
public function IsSupported($sCapa)
public function IsSupported(string $sCapa) : bool
{
return in_array(strtoupper($sCapa), $this->aCapa);
}
/**
* @return bool
*/
public function IsAuthSupported($sAuth)
public function IsAuthSupported(string $sAuth) : bool
{
return in_array(strtoupper($sAuth), $this->aAuthTypes);
}
/**
* @return bool
*/
public function HasSupportedAuth()
public function HasSupportedAuth() : bool
{
return $this->IsAuthSupported('PLAIN') || $this->IsAuthSupported('LOGIN');
}
/**
* @return string
*/
public static function EhloHelper()
public static function EhloHelper() : string
{
$sEhloHost = empty($_SERVER['SERVER_NAME']) ? '' : \trim($_SERVER['SERVER_NAME']);
if (empty($sEhloHost))
@ -146,20 +128,14 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @param string $sServerName
* @param int $iPort = 25
* @param string $sEhloHost = '[127.0.0.1]'
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
* @param bool $bAllowSelfSigned = true
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\ResponseException
*/
public function Connect($sServerName, $iPort = 25, $sEhloHost = '[127.0.0.1]',
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true) : void
public function Connect(string $sServerName, int $iPort = 25,
int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
bool $bVerifySsl = false, bool $bAllowSelfSigned = true,
string $sClientCert = '', string $sEhloHost = '[127.0.0.1]') : void
{
$this->iRequestTime = microtime(true);
@ -171,18 +147,11 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @param string $sLogin
* @param string $sPassword
* @param boolean $bUseAuthPlainIfSupported = true
* @param boolean $bUseAuthCramMd5IfSupported = true
*
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function Login($sLogin, $sPassword, $bUseAuthPlainIfSupported = true, $bUseAuthCramMd5IfSupported = true)
public function Login(string $sLogin, string $sPassword, bool $bUseAuthPlainIfSupported = true, bool $bUseAuthCramMd5IfSupported = true) : self
{
$sLogin = \MailSo\Base\Utils::IdnToAscii(\MailSo\Base\Utils::Trim($sLogin));
@ -310,16 +279,10 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @param string $sFrom
* @param string $sSizeIfSupported = ''
* @param bool $bDsn = false
*
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function MailFrom($sFrom, $sSizeIfSupported = '', $bDsn = false)
public function MailFrom(string $sFrom, string $sSizeIfSupported = '', bool $bDsn = false) : self
{
$sFrom = \MailSo\Base\Utils::IdnToAscii(
\MailSo\Base\Utils::Trim($sFrom), true);
@ -347,15 +310,10 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @param string $sTo
* @param bool $bDsn = false
*
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function Rcpt($sTo, $bDsn = false)
public function Rcpt(string $sTo, bool $bDsn = false) : self
{
if (!$this->bMail)
{
@ -385,27 +343,19 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @param string $sTo
*
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function MailTo($sTo)
public function MailTo(string $sTo) : self
{
return $this->Rcpt($sTo);
}
/**
* @param string $sData
*
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function Data($sData)
public function Data(string $sData) : self
{
if (!\MailSo\Base\Validator::NotEmptyString($sData, true))
{
@ -423,13 +373,11 @@ class SmtpClient extends \MailSo\Net\NetClient
/**
* @param resource $rDataStream
*
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function DataWithStream($rDataStream)
public function DataWithStream($rDataStream) : self
{
if (!\is_resource($rDataStream))
{
@ -484,12 +432,10 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function Rset()
public function Rset() : self
{
$this->sendRequestWithCheck('RSET', array(250, 220));
@ -501,12 +447,10 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function Vrfy($sUser)
public function Vrfy(string $sUser) : self
{
$sUser = \MailSo\Base\Utils::IdnToAscii(
\MailSo\Base\Utils::Trim($sUser));
@ -517,12 +461,10 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function Noop()
public function Noop() : self
{
$this->sendRequestWithCheck('NOOP', 250);
@ -530,12 +472,10 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
public function Logout()
public function Logout() : self
{
if ($this->IsConnected())
{
@ -550,10 +490,7 @@ class SmtpClient extends \MailSo\Net\NetClient
return $this;
}
/**
* @param string $sEhloHost
*/
private function preLoginStartTLSAndEhloProcess($sEhloHost) : void
private function preLoginStartTLSAndEhloProcess(string $sEhloHost) : void
{
if ($this->bHelo)
{
@ -583,14 +520,10 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @param string $sCommand
* @param string $sAddToCommand = ''
* @param bool $bSecureLog = false
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
*/
private function sendRequest($sCommand, $sAddToCommand = '', $bSecureLog = false) : void
private function sendRequest(string $sCommand, string $sAddToCommand = '', bool $bSecureLog = false) : void
{
if (!\MailSo\Base\Validator::NotEmptyString($sCommand, true))
{
@ -611,38 +544,29 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @param string $sCommand
* @param int|array $mExpectCode
* @param string $sAddToCommand = ''
* @param bool $bSecureLog = false
* @param string $sErrorPrefix = ''
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
private function sendRequestWithCheck($sCommand, $mExpectCode, $sAddToCommand = '', $bSecureLog = false, $sErrorPrefix = '') : void
private function sendRequestWithCheck(string $sCommand, $mExpectCode, string $sAddToCommand = '', bool $bSecureLog = false, string $sErrorPrefix = '') : void
{
$this->sendRequest($sCommand, $sAddToCommand, $bSecureLog);
$this->validateResponse($mExpectCode, $sErrorPrefix);
}
/**
* @param string $sHost
*/
private function ehloOrHelo($sHost) : void
private function ehloOrHelo(string $sHost) : void
{
try
{
$this->ehlo($sHost);
}
catch (\Exception $oException)
catch (\Throwable $oException)
{
try
{
$this->helo($sHost);
}
catch (\Exception $oException)
catch (\Throwable $oException)
{
throw $oException;
}
@ -650,8 +574,6 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @param string $sHost
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
@ -692,12 +614,10 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @param string $sHost
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception
*/
private function helo($sHost) : void
private function helo(string $sHost) : void
{
$this->sendRequestWithCheck('HELO', 250, $sHost);
$this->aAuthTypes = array();
@ -706,12 +626,9 @@ class SmtpClient extends \MailSo\Net\NetClient
}
/**
* @param int|array $mExpectCode
* @param string $sErrorPrefix = ''
*
* @throws \MailSo\Smtp\Exceptions\ResponseException
*/
private function validateResponse($mExpectCode, $sErrorPrefix = '') : void
private function validateResponse($mExpectCode, string $sErrorPrefix = '') : void
{
if (!\is_array($mExpectCode))
{
@ -757,10 +674,7 @@ class SmtpClient extends \MailSo\Net\NetClient
\MailSo\Log\Enumerations\Type::TIME);
}
/**
* @return string
*/
protected function getLogName()
protected function getLogName() : string
{
return 'SMTP';
}

View file

@ -65,9 +65,7 @@ class Net_IDNA2
* These Unicode codepoints are
* mapped to nothing, See RFC3454 for details
*
* @static
* @var array
* @access private
*/
private static $_np_map_nothing = array(
0xAD,
@ -102,9 +100,7 @@ class Net_IDNA2
/**
* Prohibited codepints
*
* @static
* @var array
* @access private
*/
private static $_general_prohibited = array(
0,
@ -175,9 +171,7 @@ class Net_IDNA2
/**
* Codepints prohibited by Nameprep
* @static
* @var array
* @access private
*/
private static $_np_prohibit = array(
0xA0,
@ -269,9 +263,7 @@ class Net_IDNA2
/**
* Codepoint ranges prohibited by nameprep
*
* @static
* @var array
* @access private
*/
private static $_np_prohibit_ranges = array(
array(0x80, 0x9F ),
@ -289,9 +281,7 @@ class Net_IDNA2
/**
* Replacement mappings (casemapping, replacement sequences, ...)
*
* @static
* @var array
* @access private
*/
private static $_np_replacemaps = array(
0x41 => array(0x61),
@ -1702,9 +1692,7 @@ class Net_IDNA2
* Normalization Combining Classes; Code Points not listed
* got Combining Class 0.
*
* @static
* @var array
* @access private
*/
private static $_np_norm_combcls = array(
0x334 => 1,
@ -2054,103 +2042,85 @@ class Net_IDNA2
// {{{ properties
/**
* @var string
* @access private
*/
private $_punycode_prefix = 'xn--';
/**
* @access private
*/
private $_invalid_ucs = 0x80000000;
/**
* @access private
*/
private $_max_ucs = 0x10FFFF;
/**
* @var int
* @access private
*/
private $_base = 36;
/**
* @var int
* @access private
*/
private $_tmin = 1;
/**
* @var int
* @access private
*/
private $_tmax = 26;
/**
* @var int
* @access private
*/
private $_skew = 38;
/**
* @var int
* @access private
*/
private $_damp = 700;
/**
* @var int
* @access private
*/
private $_initial_bias = 72;
/**
* @var int
* @access private
*/
private $_initial_n = 0x80;
/**
* @var int
* @access private
*/
private $_slast;
/**
* @access private
*/
private $_sbase = 0xAC00;
/**
* @access private
*/
private $_lbase = 0x1100;
/**
* @access private
*/
private $_vbase = 0x1161;
/**
* @access private
*/
private $_tbase = 0x11a7;
/**
* @var int
* @access private
*/
private $_lcount = 19;
/**
* @var int
* @access private
*/
private $_vcount = 21;
/**
* @var int
* @access private
*/
private $_tcount = 28;
@ -2158,7 +2128,6 @@ class Net_IDNA2
* vcount * tcount
*
* @var int
* @access private
*/
private $_ncount = 588;
@ -2166,7 +2135,6 @@ class Net_IDNA2
* lcount * tcount * vcount
*
* @var int
* @access private
*/
private $_scount = 11172;
@ -2176,7 +2144,6 @@ class Net_IDNA2
* See {@link setParams()} for how to select these
*
* @var bool
* @access private
*/
private $_api_encoding = 'utf8';
@ -2184,7 +2151,6 @@ class Net_IDNA2
* Overlong UTF-8 encodings are forbidden
*
* @var bool
* @access private
*/
private $_allow_overlong = false;
@ -2192,7 +2158,6 @@ class Net_IDNA2
* Behave strict or not
*
* @var bool
* @access private
*/
private $_strict_mode = false;
@ -2206,7 +2171,6 @@ class Net_IDNA2
* please switch to 2008 first before encoding.
*
* @var bool
* @access private
*/
private $_version = '2003';
@ -2227,9 +2191,6 @@ class Net_IDNA2
/**
* Constructor
*
* @param array $options Options to initialise the object with
*
* @access public
* @see setParams()
*/
public function __construct($options = null)
@ -2262,12 +2223,9 @@ class Net_IDNA2
* by silently ignoring errors and returning the original input instead]
*
* @param mixed $option Parameter to set (string: single parameter; array of Parameter => Value pairs)
* @param string $value Value to use (if parameter 1 is a string)
*
* @return boolean true on success, false otherwise
* @access public
*/
public function setParams($option, $value = false)
public function setParams($option, $value = false) : bool
{
if (!is_array($option)) {
$option = array($option => $value);
@ -2316,14 +2274,10 @@ class Net_IDNA2
/**
* Encode a given UTF-8 domain name.
*
* @param string $decoded Domain name (UTF-8 or UCS-4)
* @param string $one_time_encoding Desired input encoding, see {@link set_parameter}
* If not given will use default-encoding
*
* @return string Encoded Domain name (ACE string)
* @return mixed processed string
* @throws Exception
* @access public
*/
public function encode($decoded, $one_time_encoding = false)
{
@ -2406,12 +2360,7 @@ class Net_IDNA2
/**
* Decode a given ACE domain name.
*
* @param string $input Domain name (ACE string)
* @param string $one_time_encoding Desired output encoding, see {@link set_parameter}
*
* @return string Decoded Domain name (UTF-8 or UCS-4)
* @throws Exception
* @access public
*/
public function decode($input, $one_time_encoding = false)
{
@ -2495,13 +2444,8 @@ class Net_IDNA2
* Opposite function to parse_url()
*
* Inspired by code from comments of php.net-documentation for parse_url()
*
* @param array $parts_arr parts (strings) as returned by parse_url()
*
* @return string
* @access private
*/
private function _unparse_url($parts_arr)
private function _unparse_url($parts_arr) : string
{
if (!empty($parts_arr['scheme'])) {
$ret_url = $parts_arr['scheme'];
@ -2530,13 +2474,9 @@ class Net_IDNA2
/**
* The actual encoding algorithm.
*
* @param string $decoded Decoded string which should be encoded
*
* @return string Encoded string
* @throws Exception
* @access private
*/
private function _encode($decoded)
private function _encode($decoded) : string
{
// We cannot encode a domain name containing the Punycode prefix
$extract = self::_byteLength($this->_punycode_prefix);
@ -2661,13 +2601,9 @@ class Net_IDNA2
/**
* The actual decoding algorithm.
*
* @param string $encoded Encoded string which should be decoded
*
* @return string Decoded string
* @throws Exception
* @access private
*/
private function _decode($encoded)
private function _decode($encoded) : string
{
// We do need to find the Punycode prefix
if (!preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $encoded)) {
@ -2737,15 +2673,8 @@ class Net_IDNA2
/**
* Adapt the bias according to the current code point and position.
*
* @param int $delta ...
* @param int $npoints ...
* @param boolean $is_first ...
*
* @return int
* @access private
*/
private function _adapt($delta, $npoints, $is_first)
private function _adapt($delta, $npoints, $is_first) : int
{
$delta = (int) ($is_first ? ($delta / $this->_damp) : ($delta / 2));
$delta += (int) ($delta / $npoints);
@ -2760,10 +2689,7 @@ class Net_IDNA2
/**
* Encoding a certain digit.
*
* @param int $d One digit to encode
*
* @return char Encoded digit
* @access private
*/
private function _encodeDigit($d)
{
@ -2774,11 +2700,8 @@ class Net_IDNA2
* Decode a certain digit.
*
* @param char $cp One digit (character) to decode
*
* @return int Decoded digit
* @access private
*/
private function _decodeDigit($cp)
private function _decodeDigit($cp) : int
{
$cp = ord($cp);
return ($cp - 48 < 10)? $cp - 22 : (($cp - 65 < 26)? $cp - 65 : (($cp - 97 < 26)? $cp - 97 : $this->_base));
@ -2787,13 +2710,9 @@ class Net_IDNA2
/**
* Do Nameprep according to RFC3491 and RFC3454.
*
* @param array $input Unicode Characters
*
* @return string Unicode Characters, Nameprep'd
* @throws Exception
* @access private
*/
private function _nameprep($input)
private function _nameprep($input) : string
{
$output = array();
@ -2885,13 +2804,9 @@ class Net_IDNA2
* Decomposes a Hangul syllable
* (see http://www.unicode.org/unicode/reports/tr15/#Hangul).
*
* @param integer $char 32bit UCS4 code point
*
* @return array Either Hangul Syllable decomposed or original 32bit
* value as one value array
* @access private
*/
private function _hangulDecompose($char)
private function _hangulDecompose($char) : array
{
$sindex = $char - $this->_sbase;
@ -2914,13 +2829,8 @@ class Net_IDNA2
/**
* Ccomposes a Hangul syllable
* (see http://www.unicode.org/unicode/reports/tr15/#Hangul).
*
* @param array $input Decomposed UCS4 sequence
*
* @return array UCS4 sequence with syllables composed
* @access private
*/
private function _hangulCompose($input)
private function _hangulCompose($input) : array
{
$inp_len = count($input);
@ -2979,26 +2889,16 @@ class Net_IDNA2
/**
* Returns the combining class of a certain wide char.
*
* @param integer $char Wide char to check (32bit integer)
*
* @return integer Combining class if found, else 0
* @access private
*/
private function _getCombiningClass($char)
private function _getCombiningClass($char) : int
{
return isset(self::$_np_norm_combcls[$char])? self::$_np_norm_combcls[$char] : 0;
}
/**
* Apllies the cannonical ordering of a decomposed UCS4 sequence.
*
* @param array $input Decomposed UCS4 sequence
*
* @return array Ordered USC4 sequence
* @access private
*/
private function _applyCannonicalOrdering($input)
private function _applyCannonicalOrdering($input) : array
{
$swap = true;
$size = count($input);
@ -3036,13 +2936,8 @@ class Net_IDNA2
/**
* Do composition of a sequence of starter and non-starter.
*
* @param array $input UCS4 Decomposed sequence
*
* @return array Ordered USC4 sequence
* @access private
*/
private function _combine($input)
private function _combine($input) : array
{
$inp_len = count($input);
@ -3101,13 +2996,9 @@ class Net_IDNA2
*
* Each x represents a bit that can be used to store character data.
*
* @param string $input utf8-encoded string
*
* @return array ucs4-encoded array
* @throws Exception
* @access private
*/
private function _utf8_to_ucs4($input)
private function _utf8_to_ucs4($input) : array
{
$output = array();
$out_len = 0;
@ -3178,13 +3069,9 @@ class Net_IDNA2
/**
* Convert UCS-4 array into UTF-8 string
*
* @param array $input ucs4-encoded array
*
* @return string utf8-encoded string
* @throws Exception
* @access private
*/
private function _ucs4_to_utf8($input)
private function _ucs4_to_utf8($input) : string
{
$output = '';
@ -3235,13 +3122,9 @@ class Net_IDNA2
/**
* Convert UCS-4 array into UCS-4 string
*
* @param array $input ucs4-encoded array
*
* @return string ucs4-encoded string
* @throws Exception
* @access private
*/
private function _ucs4_to_ucs4_string($input)
private function _ucs4_to_ucs4_string($input) : string
{
$output = '';
// Take array values and split output to 4 bytes per value
@ -3255,13 +3138,9 @@ class Net_IDNA2
/**
* Convert UCS-4 string into UCS-4 array
*
* @param string $input ucs4-encoded string
*
* @return array ucs4-encoded array
* @throws InvalidArgumentException
* @access private
*/
private function _ucs4_string_to_ucs4($input)
private function _ucs4_string_to_ucs4($input) : array
{
$output = array();
@ -3289,9 +3168,6 @@ class Net_IDNA2
/**
* Echo hex representation of UCS4 sequence.
*
* @param array $input UCS4 sequence
* @param boolean $include_bit Include bitmask in output
*/
private static function _showHex($input, $include_bit = false) : void
{
@ -3309,14 +3185,8 @@ class Net_IDNA2
/**
* Gives you a bit representation of given Byte (8 bits), Word (16 bits) or DWord (32 bits)
* Output width is automagically determined
*
* @param int $octet ...
*
* @return string Bitmask-representation
* @static
* @access private
*/
private static function _showBitmask($octet)
private static function _showBitmask($octet) : string
{
if ($octet >= (1 << 16)) {
$w = 31;
@ -3339,13 +3209,9 @@ class Net_IDNA2
* Gets the length of a string in bytes even if mbstring function
* overloading is turned on
*
* @param string $string the string for which to get the length.
*
* @return integer the length of the string in bytes.
*
* @see Net_IDNA2::$_mb_string_overload
*/
private static function _byteLength($string)
private static function _byteLength($string) : int
{
if (self::$_mb_string_overload) {
return mb_strlen($string, '8bit');
@ -3359,10 +3225,7 @@ class Net_IDNA2
/**
* Attempts to return a concrete IDNA instance for either php4 or php5.
*
* @param array $params Set of paramaters
*
* @return Net_IDNA2
* @access public
*/
function getInstance($params = array())
{
@ -3376,10 +3239,7 @@ class Net_IDNA2
* only creating a new instance if no IDNA instance with the same
* parameters currently exists.
*
* @param array $params Set of paramaters
*
* @return object Net_IDNA2
* @access public
*/
function singleton($params = array())
{

View file

@ -204,10 +204,7 @@ class Actions
return '';
}
/**
* @return \RainLoop\Config\Application
*/
public function Config()
public function Config() : \RainLoop\Config\Application
{
if (null === $this->oConfig)
{
@ -532,37 +529,34 @@ class Actions
public function SetAuthLogoutToken() : void
{
@\header('X-RainLoop-Action: Logout');
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY, \md5(APP_START_TIME), 0);
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY, \md5($_SERVER['REQUEST_TIME_FLOAT']), 0);
}
public function SetAuthToken(?\RainLoop\Model\Account $oAccount) : void
public function SetAuthToken(\RainLoop\Model\Account $oAccount) : void
{
if ($oAccount)
$sSpecAuthToken = '_'.$oAccount->GetAuthTokenQ();
$this->SetSpecAuthToken($sSpecAuthToken);
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, $sSpecAuthToken, 0);
if ($oAccount->SignMe() && 0 < \strlen($oAccount->SignMeToken()))
{
$sSpecAuthToken = '_'.$oAccount->GetAuthTokenQ();
\RainLoop\Utils::SetCookie(self::AUTH_SIGN_ME_TOKEN_KEY,
\RainLoop\Utils::EncodeKeyValuesQ(array(
'e' => $oAccount->Email(),
't' => $oAccount->SignMeToken()
)),
\time() + 60 * 60 * 24 * 30);
$this->SetSpecAuthToken($sSpecAuthToken);
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, $sSpecAuthToken, 0);
if ($oAccount->SignMe() && 0 < \strlen($oAccount->SignMeToken()))
{
\RainLoop\Utils::SetCookie(self::AUTH_SIGN_ME_TOKEN_KEY,
\RainLoop\Utils::EncodeKeyValuesQ(array(
'e' => $oAccount->Email(),
't' => $oAccount->SignMeToken()
)),
\time() + 60 * 60 * 24 * 30);
$this->StorageProvider()->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'sign_me',
\RainLoop\Utils::EncodeKeyValuesQ(array(
'Time' => \time(),
'AuthToken' => $oAccount->GetAuthTokenQ(),
'SignMetToken' => $oAccount->SignMeToken()
))
);
}
$this->StorageProvider()->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'sign_me',
\RainLoop\Utils::EncodeKeyValuesQ(array(
'Time' => \time(),
'AuthToken' => $oAccount->GetAuthTokenQ(),
'SignMetToken' => $oAccount->SignMeToken()
))
);
}
}
@ -635,18 +629,14 @@ class Actions
}
/**
* @return \RainLoop\Model\Account|bool
* @throws \RainLoop\Exceptions\ClientException
*/
public function GetAccount(bool $bThrowExceptionOnFalse = false)
public function GetAccount(bool $bThrowExceptionOnFalse = false) : \RainLoop\Model\Account
{
return $this->getAccountFromToken($bThrowExceptionOnFalse);
}
/**
* @return \MailSo\Base\Http
*/
public function Http()
public function Http() : \MailSo\Base\Http
{
if (null === $this->oHttp)
{
@ -656,10 +646,7 @@ class Actions
return $this->oHttp;
}
/**
* @return \MailSo\Mail\MailClient
*/
public function MailClient()
public function MailClient() : \MailSo\Mail\MailClient
{
if (null === $this->oMailClient)
{
@ -670,10 +657,7 @@ class Actions
return $this->oMailClient;
}
/**
* @return \RainLoop\Providers\Filters
*/
public function FiltersProvider()
public function FiltersProvider() : \RainLoop\Providers\Filters
{
if (null === $this->oFiltersProvider)
{
@ -684,10 +668,7 @@ class Actions
return $this->oFiltersProvider;
}
/**
* @return \RainLoop\Providers\TwoFactorAuth
*/
public function TwoFactorAuthProvider()
public function TwoFactorAuthProvider() : \RainLoop\Providers\TwoFactorAuth
{
if (null === $this->oTwoFactorAuthProvider)
{
@ -699,10 +680,7 @@ class Actions
return $this->oTwoFactorAuthProvider;
}
/**
* @return \RainLoop\Providers\Storage
*/
public function StorageProvider(bool $bLocal = false)
public function StorageProvider(bool $bLocal = false) : \RainLoop\Providers\Storage
{
if ($bLocal)
{
@ -728,10 +706,7 @@ class Actions
return null;
}
/**
* @return \RainLoop\Providers\Settings
*/
public function SettingsProvider(bool $bLocal = false)
public function SettingsProvider(bool $bLocal = false) : \RainLoop\Providers\Settings
{
if ($bLocal)
{
@ -757,10 +732,7 @@ class Actions
return null;
}
/**
* @return \RainLoop\Providers\Files
*/
public function FilesProvider()
public function FilesProvider() : \RainLoop\Providers\Files
{
if (null === $this->oFilesProvider)
{
@ -771,10 +743,7 @@ class Actions
return $this->oFilesProvider;
}
/**
* @return \RainLoop\Providers\Domain
*/
public function DomainProvider()
public function DomainProvider() : \RainLoop\Providers\Domain
{
if (null === $this->oDomainProvider)
{
@ -785,10 +754,7 @@ class Actions
return $this->oDomainProvider;
}
/**
* @return \RainLoop\Providers\Suggestions
*/
public function SuggestionsProvider()
public function SuggestionsProvider() : \RainLoop\Providers\Suggestions
{
if (null === $this->oSuggestionsProvider)
{
@ -799,10 +765,7 @@ class Actions
return $this->oSuggestionsProvider;
}
/**
* @return \RainLoop\Providers\AddressBook
*/
public function AddressBookProvider(?\RainLoop\Model\Account $oAccount = null, bool $bForceEnable = false)
public function AddressBookProvider(?\RainLoop\Model\Account $oAccount = null, bool $bForceEnable = false) : \RainLoop\Providers\AddressBook
{
if (null === $this->oAddressBookProvider)
{
@ -822,10 +785,7 @@ class Actions
return $this->oAddressBookProvider;
}
/**
* @return \MailSo\Cache\CacheClient
*/
public function Cacher(?\RainLoop\Model\Account $oAccount = null, bool $bForceFile = false)
public function Cacher(?\RainLoop\Model\Account $oAccount = null, bool $bForceFile = false) : \MailSo\Cache\CacheClient
{
$sKey = '';
if ($oAccount)
@ -892,10 +852,7 @@ class Actions
return $this->aCachers[$sIndexKey];
}
/**
* @return \RainLoop\Plugins\Manager
*/
public function Plugins()
public function Plugins() : \RainLoop\Plugins\Manager
{
if (null === $this->oPlugins)
{
@ -906,10 +863,7 @@ class Actions
return $this->oPlugins;
}
/**
* @return \MailSo\Log\Logger
*/
public function Logger()
public function Logger() : \MailSo\Log\Logger
{
if (null === $this->oLogger)
{
@ -999,10 +953,7 @@ class Actions
return $this->oLogger;
}
/**
* @return \MailSo\Log\Logger
*/
public function LoggerAuth()
public function LoggerAuth() : \MailSo\Log\Logger
{
if (null === $this->oLoggerAuth)
{
@ -1096,10 +1047,7 @@ class Actions
}
}
/**
* @return \RainLoop\Model\Account|null
*/
public function LoginProvide(string $sEmail, string $sLogin, string $sPassword, string $sSignMeToken = '', string $sClientCert = '', bool $bThrowProvideException = false)
public function LoginProvide(string $sEmail, string $sLogin, string $sPassword, string $sSignMeToken = '', string $sClientCert = '', bool $bThrowProvideException = false) : ?\RainLoop\Model\Account
{
$oAccount = null;
if (0 < \strlen($sEmail) && 0 < \strlen($sLogin) && 0 < \strlen($sPassword))
@ -1132,10 +1080,9 @@ class Actions
}
/**
* @return \RainLoop\Model\Account|bool
* @throws \RainLoop\Exceptions\ClientException
*/
public function GetAccountFromCustomToken(string $sToken, bool $bThrowExceptionOnFalse = true, bool $bValidateShortToken = true, bool $bQ = false)
public function GetAccountFromCustomToken(string $sToken, bool $bThrowExceptionOnFalse = true, bool $bValidateShortToken = true, bool $bQ = false) : \RainLoop\Model\Account
{
$oResult = false;
if (!empty($sToken))
@ -1180,10 +1127,7 @@ class Actions
return $oResult;
}
/**
* @return \RainLoop\Model\Account|bool
*/
public function GetAccountFromSignMeToken()
public function GetAccountFromSignMeToken() : \RainLoop\Model\Account
{
$oAccount = false;
@ -1220,10 +1164,9 @@ class Actions
}
/**
* @return \RainLoop\Model\Account|bool
* @throws \RainLoop\Exceptions\ClientException
*/
public function getAccountFromToken(bool $bThrowExceptionOnFalse = true)
public function getAccountFromToken(bool $bThrowExceptionOnFalse = true) : \RainLoop\Model\Account
{
return $this->GetAccountFromCustomToken($this->getLocalAuthToken(), $bThrowExceptionOnFalse, true, true);
}
@ -1738,7 +1681,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
{
if (0 < $iDelay && 0 < $iWait)
{
if ($iWait > \time() - APP_START_TIME)
if ($iWait > \time() - $_SERVER['REQUEST_TIME_FLOAT'])
{
\sleep($iDelay);
}
@ -1754,18 +1697,15 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
}
public function AuthToken(?\RainLoop\Model\Account $oAccount) : void
public function AuthToken(\RainLoop\Model\Account $oAccount) : void
{
if ($oAccount)
{
$this->SetAuthToken($oAccount);
$this->SetAuthToken($oAccount);
$aAccounts = $this->GetAccounts($oAccount);
if (\is_array($aAccounts) && isset($aAccounts[$oAccount->Email()]))
{
$aAccounts[$oAccount->Email()] = $oAccount->GetAuthToken();
$this->SetAccounts($oAccount, $aAccounts);
}
$aAccounts = $this->GetAccounts($oAccount);
if (\is_array($aAccounts) && isset($aAccounts[$oAccount->Email()]))
{
$aAccounts[$oAccount->Email()] = $oAccount->GetAuthToken();
$this->SetAccounts($oAccount, $aAccounts);
}
}
@ -1824,11 +1764,10 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
/**
* @return \RainLoop\Model\Account
* @throws \RainLoop\Exceptions\ClientException
*/
public function LoginProcess(string &$sEmail, string &$sPassword, string $sSignMeToken = '',
string $sAdditionalCode = '', bool $bAdditionalCodeSignMe = false, bool $bSkipTwoFactorAuth = false)
string $sAdditionalCode = '', bool $bAdditionalCodeSignMe = false, bool $bSkipTwoFactorAuth = false) : \RainLoop\Model\Account
{
$sInputEmail = $sEmail;
@ -2205,10 +2144,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
return $aTemplates;
}
/**
* @return \RainLoop\Model\Identity
*/
public function GetTemplateByID(\RainLoop\Model\Account $oAccount, string $sID)
public function GetTemplateByID(\RainLoop\Model\Account $oAccount, string $sID) : ?\RainLoop\Model\Identity
{
$aTemplates = $this->GetTemplates($oAccount);
if (\is_array($aTemplates))
@ -2307,10 +2243,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
return $aIdentities;
}
/**
* @return \RainLoop\Model\Identity
*/
public function GetIdentityByID(\RainLoop\Model\Account $oAccount, string $sID, bool $bFirstOnEmpty = false)
public function GetIdentityByID(\RainLoop\Model\Account $oAccount, string $sID, bool $bFirstOnEmpty = false) : ?\RainLoop\Model\Identity
{
$aIdentities = $this->GetIdentities($oAccount);
@ -2327,10 +2260,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
return $bFirstOnEmpty && \is_array($aIdentities) && isset($aIdentities[0]) ? $aIdentities[0] : null;
}
/**
* @return \RainLoop\Model\Identity
*/
public function GetAccountIdentity(\RainLoop\Model\Account $oAccount)
public function GetAccountIdentity(\RainLoop\Model\Account $oAccount) : ?\RainLoop\Model\Identity
{
return $this->GetIdentityByID($oAccount, '', true);
}
@ -3102,7 +3033,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$this->SettingsProvider(true)->Save($oAccount, $oSettingsLocal));
}
public function setConfigFromParams(\RainLoop\Config\Application &$oConfig, string $sParamName, string $sConfigSector, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null) : void
public function setConfigFromParams(\RainLoop\Config\Application $oConfig, string $sParamName, string $sConfigSector, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null) : void
{
$sValue = $this->GetActionParam($sParamName, '');
if ($this->HasActionParam($sParamName))
@ -3140,7 +3071,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
}
private function setCapaFromParams(\RainLoop\Config\Application &$oConfig, string $sParamName, string $sCapa) : void
private function setCapaFromParams(\RainLoop\Config\Application $oConfig, string $sParamName, string $sCapa) : void
{
switch ($sCapa)
{
@ -3174,7 +3105,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
}
private function setSettingsFromParams(\RainLoop\Settings &$oSettings, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null) : void
private function setSettingsFromParams(\RainLoop\Settings $oSettings, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null) : void
{
if ($this->HasActionParam($sConfigName))
{
@ -3523,10 +3454,10 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$oSmtpClient->SetTimeOuts($iConnectionTimeout);
$iTime = \microtime(true);
$oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(),
\MailSo\Smtp\SmtpClient::EhloHelper(), $oDomain->OutSecure(),
$oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(), $oDomain->OutSecure(),
!!$this->Config()->Get('ssl', 'verify_certificate', false),
!!$this->Config()->Get('ssl', 'allow_self_signed', true)
!!$this->Config()->Get('ssl', 'allow_self_signed', true),
'', \MailSo\Smtp\SmtpClient::EhloHelper()
);
$iSmtpTime = \microtime(true) - $iTime;
@ -4030,7 +3961,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$bResult = $oArchive->extractTo(APP_PLUGINS_PATH);
if (!$bResult)
{
$this->Logger()->Write('Cannot extract package files: '.$oArchive->errorInfo(), \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
$this->Logger()->Write('Cannot extract package files: '.$oArchive->getStatusString(), \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
}
}
}
@ -5004,10 +4935,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
return $this->DefaultResponse(__FUNCTION__, $oMessageList);
}
/**
* @return \MailSo\Mime\Message
*/
private function buildMessage(\RainLoop\Model\Account $oAccount, bool $bWithDraftInfo = true)
private function buildMessage(\RainLoop\Model\Account $oAccount, bool $bWithDraftInfo = true) : \MailSo\Mime\Message
{
$sIdentityID = $this->GetActionParam('IdentityID', '');
$sTo = $this->GetActionParam('To', '');
@ -5195,10 +5123,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
}
/**
* @return \MailSo\Mime\Message
*/
private function buildReadReceiptMessage(\RainLoop\Model\Account $oAccount)
private function buildReadReceiptMessage(\RainLoop\Model\Account $oAccount) : \MailSo\Mime\Message
{
$sReadReceipt = $this->GetActionParam('ReadReceipt', '');
$sSubject = $this->GetActionParam('Subject', '');
@ -7362,10 +7287,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
}
/**
* @return \Imagine\Image\AbstractImage
*/
public function correctImageOrientation(\Imagine\Image\AbstractImage $oImage, bool $bDetectImageOrientation = true, int $iThumbnailBoxSize = 0)
public function correctImageOrientation(\Imagine\Image\AbstractImage $oImage, bool $bDetectImageOrientation = true, int $iThumbnailBoxSize = 0) : \Imagine\Image\AbstractImage
{
$iOrientation = 1;
if ($bDetectImageOrientation && \MailSo\Base\Utils::FunctionExistsAndEnabled('exif_read_data') &&
@ -7770,10 +7692,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$this->AddressBookProvider($oAccount)->Export($oAccount->ParentEmailHelper(), 'csv') : false;
}
/**
* @return \RainLoop\Model\Account|bool
*/
private function initMailClientConnection()
private function initMailClientConnection() : ?\RainLoop\Model\Account
{
$oAccount = null;

View file

@ -4,6 +4,7 @@ namespace RainLoop;
class Api
{
private function __construct()
{
}
@ -38,18 +39,12 @@ class Api
return $oActions;
}
/**
* @return \RainLoop\Config\Application
*/
public static function Config()
public static function Config() : \RainLoop\Config\Application
{
return static::Actions()->Config();
}
/**
* @return \MailSo\Log\Logger
*/
public static function Logger()
public static function Logger() : \MailSo\Log\Logger
{
return static::Actions()->Logger();
}

View file

@ -51,11 +51,10 @@ abstract class PdoAbstract
}
/**
* @return \PDO
*
* @throws \Exception
*/
protected function getPDO()
protected function getPDO() : \PDO
{
if ($this->oPDO)
{
@ -153,10 +152,7 @@ abstract class PdoAbstract
return $this->getPDO()->rollBack();
}
/**
* @return \PDOStatement|null
*/
protected function prepareAndExecute(string $sSql, array $aParams = array(), bool $bMultiplyParams = false, bool $bLogParams = false)
protected function prepareAndExecute(string $sSql, array $aParams = array(), bool $bMultiplyParams = false, bool $bLogParams = false) : ?\PDOStatement
{
if ($this->bExplain && !$bMultiplyParams)
{
@ -292,10 +288,7 @@ abstract class PdoAbstract
return $oPdo ? $oPdo->quote((string) $sValue, \PDO::PARAM_STR) : '\'\'';
}
/**
* @return int|string|bool
*/
protected function getSystemValue(string $sName, bool $bReturnIntValue = true)
protected function getSystemValue(string $sName, bool $bReturnIntValue = true) : int
{
$oPdo = $this->getPDO();
if ($oPdo)
@ -328,10 +321,7 @@ abstract class PdoAbstract
return false;
}
/**
* @return int|string|bool
*/
protected function getVersion(string $sName)
protected function getVersion(string $sName) : int
{
return $this->getSystemValue($sName.'_version', true);
}

View file

@ -81,7 +81,7 @@ class Application extends \RainLoop\Config\AbstractConfig
return $mResult;
}
public function SetPassword(string $sPassword)
public function SetPassword(string $sPassword) : void
{
$this->Set('security', 'admin_password', \password_hash($sPassword, PASSWORD_DEFAULT));
}

View file

@ -4,6 +4,7 @@ namespace RainLoop;
class KeyPathHelper
{
static public function PublicFile(string $sHash) : string
{
return '/Public/Files/'.sha1($sHash).'/Data/';

View file

@ -153,10 +153,7 @@ class Account
return $this->sSignMeToken;
}
/**
* @return \RainLoop\Model\Domain
*/
public function Domain()
public function Domain() : \RainLoop\Model\Domain
{
return $this->oDomain;
}
@ -377,8 +374,9 @@ class Account
if ($aSmtpCredentials['UseConnect'] && !$aSmtpCredentials['UsePhpMail'] && $oSmtpClient)
{
$oSmtpClient->Connect($aSmtpCredentials['Host'], $aSmtpCredentials['Port'], $aSmtpCredentials['Ehlo'],
$aSmtpCredentials['Secure'], $aSmtpCredentials['VerifySsl'], $aSmtpCredentials['AllowSelfSigned']
$oSmtpClient->Connect($aSmtpCredentials['Host'], $aSmtpCredentials['Port'],
$aSmtpCredentials['Secure'], $aSmtpCredentials['VerifySsl'], $aSmtpCredentials['AllowSelfSigned'],
'', $aSmtpCredentials['Ehlo']
);
}

View file

@ -141,13 +141,7 @@ class Domain
$sWhiteList);
}
/**
* @param string $sName
* @param array $aDomain
*
* @return \RainLoop\Model\Domain|null
*/
public static function NewInstanceFromDomainConfigArray(string $sName, $aDomain)
public static function NewInstanceFromDomainConfigArray(string $sName, array $aDomain) : ?\RainLoop\Model\Domain
{
$oDomain = null;

View file

@ -138,7 +138,7 @@ class Notifications
self::UnknownError => 'UnknownError'
);
if (self::ClientViewError === $iCode && $oPrevious instanceof \Throwable)
if (self::ClientViewError === $iCode && $oPrevious)
{
return $oPrevious->getMessage();
}

View file

@ -57,10 +57,7 @@ abstract class AbstractPlugin
$this->bLangs = false;
}
/**
* @return \RainLoop\Config\Plugin
*/
public function Config()
public function Config() : \RainLoop\Config\Plugin
{
if (!$this->bPluginConfigLoaded && $this->oPluginConfig)
{
@ -77,10 +74,7 @@ abstract class AbstractPlugin
return $this->oPluginConfig;
}
/**
* @return \RainLoop\Plugins\Manager
*/
public function Manager()
public function Manager() : \RainLoop\Plugins\Manager
{
return $this->oPluginManager;
}
@ -125,9 +119,6 @@ abstract class AbstractPlugin
return '';
}
/**
* @final
*/
final public function ConfigMap() : array
{
if (null === $this->aConfigMap)

View file

@ -595,18 +595,8 @@ class Manager
return $this->bIsEnabled ? \count($this->aPlugins) : 0;
}
/**
* @param \MailSo\Log\Logger $oLogger
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function SetLogger($oLogger) : self
public function SetLogger(\MailSo\Log\Logger $oLogger) : self
{
if (!($oLogger instanceof \MailSo\Log\Logger))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
$this->oLogger = $oLogger;
return $this;

View file

@ -29,10 +29,7 @@ abstract class AbstractProvider
$this->oLogger = $oLogger;
}
/**
* @return \MailSo\Log\Logger|null
*/
public function Logger()
public function Logger() : ?\MailSo\Log\Logger
{
return $this->oLogger;
}

View file

@ -72,12 +72,7 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider
$iOffset, $iLimit, $sSearch, $iResultCount) : array();
}
/**
* @param string $mID
*
* @return \RainLoop\Providers\AddressBook\Classes\Contact|null
*/
public function GetContactByID(string $sEmail, $mID, bool $bIsStrID = false)
public function GetContactByID(string $sEmail, $mID, bool $bIsStrID = false) : ?\RainLoop\Providers\AddressBook\Classes\Contact
{
return $this->IsActive() ? $this->oDriver->GetContactByID($sEmail, $mID, $bIsStrID) : null;
}

View file

@ -56,12 +56,12 @@ class PdoAddressBook
));
}
private function updateContactEtagAndTime(int $iUserID, int $mID, string $sEtag, int $iChanged)
private function updateContactEtagAndTime(int $iUserID, int $iID, string $sEtag, int $iChanged)
{
return !!$this->prepareAndExecute('UPDATE rainloop_ab_contacts SET changed = :changed, etag = :etag '.
'WHERE id_user = :id_user AND id_contact = :id_contact', array(
':id_user' => array($iUserID, \PDO::PARAM_INT),
':id_contact' => array($mID, \PDO::PARAM_INT),
':id_contact' => array($iID, \PDO::PARAM_INT),
':changed' => array($iChanged, \PDO::PARAM_INT),
':etag' => array($sEtag, \PDO::PARAM_STR)
)
@ -239,7 +239,7 @@ class PdoAddressBook
return $aResponse;
}
private function getContactsPaths(\SabreForRainLoop\DAV\Client &$oClient, string $sUser, string $sPassword, string $sProxy = '') : array
private function getContactsPaths(\SabreForRainLoop\DAV\Client $oClient, string $sUser, string $sPassword, string $sProxy = '') : array
{
$aContactsPaths = array();
@ -425,7 +425,7 @@ class PdoAddressBook
return $aContactsPaths;
}
private function checkContactsPath(\SabreForRainLoop\DAV\Client &$oClient, string $sPath) : bool
private function checkContactsPath(\SabreForRainLoop\DAV\Client $oClient, string $sPath) : bool
{
if (!$oClient)
{
@ -475,7 +475,7 @@ class PdoAddressBook
return $bGood;
}
public function getDavClientFromUrl(string $sUrl, string $sUser, string $sPassword, string $sProxy = '')
public function getDavClientFromUrl(string $sUrl, string $sUser, string $sPassword, string $sProxy = '') : \SabreForRainLoop\DAV\Client
{
if (!\preg_match('/^http[s]?:\/\//i', $sUrl))
{
@ -527,11 +527,11 @@ class PdoAddressBook
return $oClient;
}
public function getDavClient(string $sUrl, string $sUser, string $sPassword, string $sProxy = '') : bool
public function getDavClient(string $sUrl, string $sUser, string $sPassword, string $sProxy = '') : ?\SabreForRainLoop\DAV\Client
{
if (!\class_exists('SabreForRainLoop\DAV\Client'))
{
return false;
return null;
}
$aMatch = array();
@ -548,7 +548,7 @@ class PdoAddressBook
$oClient = $this->getDavClientFromUrl($sUrl, $sUser, $sPassword, $sProxy);
if (!$oClient)
{
return false;
return null;
}
$bGood = false;
@ -1168,10 +1168,8 @@ class PdoAddressBook
/**
* @param mixed $mID
*
* @return \RainLoop\Providers\AddressBook\Classes\Contact|null
*/
public function GetContactByID(string $sEmail, $mID, bool $bIsStrID = false)
public function GetContactByID(string $sEmail, $mID, bool $bIsStrID = false) : ?\RainLoop\Providers\AddressBook\Classes\Contact
{
$mID = \trim($mID);

View file

@ -1,81 +0,0 @@
<?php
namespace RainLoop\Providers;
class ChangePassword extends \RainLoop\Providers\AbstractProvider
{
/**
* @var \RainLoop\Actions
*/
private $oActions;
/**
* @var \RainLoop\Providers\ChangePassword\ChangePasswordInterface
*/
private $oDriver;
/**
* @var bool
*/
private $bCheckWeak;
public function __construct(\RainLoop\Actions $oActions, ?\RainLoop\Providers\ChangePassword\ChangePasswordInterface $oDriver = null, bool $bCheckWeak = true)
{
$this->oActions = $oActions;
$this->oDriver = $oDriver;
$this->bCheckWeak = $bCheckWeak;
}
public function PasswordChangePossibility(\RainLoop\Model\Account $oAccount) : bool
{
return $this->IsActive() &&
$this->oDriver && $this->oDriver->PasswordChangePossibility($oAccount)
;
}
public function ChangePassword(\RainLoop\Model\Account $oAccount, string $sPrevPassword, string $sNewPassword)
{
$mResult = false;
if ($this->oDriver instanceof \RainLoop\Providers\ChangePassword\ChangePasswordInterface &&
$this->PasswordChangePossibility($oAccount))
{
if ($sPrevPassword !== $oAccount->Password())
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CurrentPasswordIncorrect);
}
$sPasswordForCheck = \trim($sNewPassword);
if (6 > \strlen($sPasswordForCheck))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::NewPasswordShort);
}
if (!\MailSo\Base\Utils::PasswordWeaknessCheck($sPasswordForCheck))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::NewPasswordWeak);
}
if (!$this->oDriver->ChangePassword($oAccount, $sPrevPassword, $sNewPassword))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CouldNotSaveNewPassword);
}
$oAccount->SetPassword($sNewPassword);
$this->oActions->SetAuthToken($oAccount);
$mResult = $this->oActions->GetSpecAuthToken();
}
else
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CouldNotSaveNewPassword);
}
return $mResult;
}
public function IsActive() : bool
{
return $this->oDriver instanceof \RainLoop\Providers\ChangePassword\ChangePasswordInterface;
}
}

View file

@ -32,10 +32,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
return $this->bAdmin;
}
/**
* @return \RainLoop\Model\Domain|null
*/
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true)
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true) : ?\RainLoop\Model\Domain
{
$oDomain = $this->oDriver->Load($sName, $bFindWithWildCard, $bCheckDisabled, $bCheckAliases);
if ($oDomain instanceof \RainLoop\Model\Domain)
@ -93,10 +90,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
return $this->oDriver->Count($sSearch);
}
/**
* @return \RainLoop\Model\Domain | null
*/
public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '')
public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '') : ?\RainLoop\Model\Domain
{
$oDomain = null;
@ -163,10 +157,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
return $oDomain;
}
/**
* @return \RainLoop\Model\Domain | null
*/
public function CreateNewAliasFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '')
public function CreateNewAliasFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '') : ?\RainLoop\Model\Domain
{
$oDomain = null;

View file

@ -86,10 +86,7 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
return $sResult;
}
/**
* @return \RainLoop\Model\Domain|null
*/
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true)
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true) : ?\RainLoop\Model\Domain
{
$mResult = null;

View file

@ -7,10 +7,7 @@ interface DomainAdminInterface extends DomainInterface
public function Disable(string $sName, bool $bDisable) : bool;
/**
* @return \RainLoop\Model\Domain|null
*/
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true);
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true) : ?\RainLoop\Model\Domain;
public function Save(\RainLoop\Model\Domain $oDomain) : bool;

View file

@ -32,10 +32,7 @@ class Files extends \RainLoop\Providers\AbstractProvider
return $this->oDriver->GetFile($oAccount, $sKey, $sOpenMode);
}
/**
* @return string | bool
*/
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey)
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey) : string
{
return $this->oDriver->GetFileName($oAccount, $sKey);
}
@ -45,10 +42,7 @@ class Files extends \RainLoop\Providers\AbstractProvider
return $this->oDriver->Clear($oAccount, $sKey);
}
/**
* @return int|bool
*/
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey)
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey) : int
{
return $this->oDriver->FileSize($oAccount, $sKey);
}

View file

@ -68,10 +68,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
return $mResult;
}
/**
* @return string|bool
*/
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey)
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey) : string
{
$mResult = false;
$sFileName = $this->generateFullFileName($oAccount, $sKey);
@ -100,10 +97,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
return $mResult;
}
/**
* @return int|bool
*/
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey)
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey) : int
{
$mResult = false;
$sFileName = $this->generateFullFileName($oAccount, $sKey);

View file

@ -86,7 +86,7 @@ class FilterCondition
);
}
public static function CollectionFromJSON($aCollection) : array
public static function CollectionFromJSON(array $aCollection) : array
{
$aResult = array();
if (\is_array($aCollection) && 0 < \count($aCollection))

View file

@ -9,30 +9,18 @@ class Settings extends \RainLoop\Providers\AbstractProvider
*/
private $oDriver;
/**
* @param \RainLoop\Providers\Settings\ISettings $oDriver
*/
public function __construct(\RainLoop\Providers\Settings\ISettings $oDriver)
{
$this->oDriver = $oDriver;
}
/**
* @param \RainLoop\Model\Account $oAccount
*
* @return \RainLoop\Settings
*/
public function Load(\RainLoop\Model\Account $oAccount)
public function Load(\RainLoop\Model\Account $oAccount) : \RainLoop\Settings
{
$oSettings = new \RainLoop\Settings();
$oSettings->InitData($this->oDriver->Load($oAccount));
return $oSettings;
}
/**
* @param \RainLoop\Model\Account $oAccount
* @param \RainLoop\Settings $oSettings
*/
public function Save(\RainLoop\Model\Account $oAccount, \RainLoop\Settings $oSettings) : bool
{
return $this->oDriver->Save($oAccount, $oSettings->DataAsArray());

View file

@ -32,7 +32,7 @@ class Storage extends \RainLoop\Providers\AbstractProvider
* @param \RainLoop\Model\Account|string|null $oAccount
* @param mixed $sValue
*/
public function Put($oAccount, int $iStorageType, string $sKey, $sValue) : bool
public function Put($oAccount, int $iStorageType, string $sKey, string $sValue) : bool
{
if (!$this->verifyAccount($oAccount, $iStorageType))
{

View file

@ -28,9 +28,8 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
/**
* @param \RainLoop\Model\Account|string|null $oAccount
* @param mixed $sValue
*/
public function Put($oAccount, int $iStorageType, string $sKey, $sValue) : bool
public function Put($oAccount, int $iStorageType, string $sKey, string $sValue) : bool
{
return false !== @\file_put_contents(
$this->generateFileName($oAccount, $iStorageType, $sKey, true), $sValue);
@ -166,9 +165,6 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
return $sFilePath;
}
/**
* @param \MailSo\Log\Logger $oLogger
*/
public function SetLogger(?\MailSo\Log\Logger $oLogger)
{
$this->oLogger = $oLogger;

View file

@ -6,9 +6,8 @@ interface IStorage
{
/**
* @param \RainLoop\Model\Account|null $oAccount
* @param mixed $sValue
*/
public function Put($oAccount, int $iStorageType, string $sKey, $sValue) : bool;
public function Put($oAccount, int $iStorageType, string $sKey, string $sValue) : bool;
/**
* @param \RainLoop\Model\Account|null $oAccount

View file

@ -6,9 +6,8 @@ class TemproryApcStorage extends \RainLoop\Providers\Storage\FileStorage
{
/**
* @param \RainLoop\Model\Account|string|null $oAccount
* @param mixed $sValue
*/
public function Put($oAccount, int $iStorageType, string $sKey, $sValue) : bool
public function Put($oAccount, int $iStorageType, string $sKey, string $sValue) : bool
{
return !!@\apc_store($this->generateFileName($oAccount, $iStorageType, $sKey, true), $sValue);
}

View file

@ -4,8 +4,5 @@ namespace RainLoop\Providers\Suggestions;
interface ISuggestions
{
/**
* @return array [['email@1', 'name_1'], ['email@2', 'name_2']]
*/
public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20);
public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20) : array;
}

View file

@ -4,11 +4,6 @@ namespace RainLoop\Providers\Suggestions;
class TestSuggestions implements \RainLoop\Providers\Suggestions\ISuggestions
{
/**
* @param \RainLoop\Model\Account $oAccount
* @param string $sQuery
* @param int $iLimit = 20
*/
public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20) : array
{
return array(

View file

@ -4,6 +4,7 @@ namespace RainLoop\Providers\TwoFactorAuth;
abstract class AbstractTwoFactorAuth
{
public function Label() : string
{
return 'Two Factor Authenticator Code';

View file

@ -4,5 +4,6 @@ namespace RainLoop\Providers\TwoFactorAuth;
interface TwoFactorAuthInterface
{
public function VerifyCode(string $sSecret, string $sCode) : bool;
}

View file

@ -32,50 +32,32 @@ class ServiceActions
$this->sQuery = '';
}
/**
* @return \MailSo\Log\Logger
*/
public function Logger()
public function Logger() : \MailSo\Log\Logger
{
return $this->oActions->Logger();
}
/**
* @return \RainLoop\Plugins\Manager
*/
public function Plugins()
public function Plugins() : \RainLoop\Plugins\Manager
{
return $this->oActions->Plugins();
}
/**
* @return \RainLoop\Config\Application
*/
public function Config()
public function Config() : \RainLoop\Config\Application
{
return $this->oActions->Config();
}
/**
* @return \MailSo\Cache\CacheClient
*/
public function Cacher()
public function Cacher() : \MailSo\Cache\CacheClient
{
return $this->oActions->Cacher();
}
/**
* @return \RainLoop\Providers\Storage
*/
public function StorageProvider()
public function StorageProvider() : \RainLoop\Providers\Storage
{
return $this->oActions->StorageProvider();
}
/**
* @return \RainLoop\Providers\Settings
*/
public function SettingsProvider()
public function SettingsProvider() : \RainLoop\Providers\Settings
{
return $this->oActions->SettingsProvider();
}

View file

@ -51,7 +51,7 @@ class VCalendar extends VObject\Document {
'DATE' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Date',
'DATE-TIME' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\DateTime',
'DURATION' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Duration',
'FLOAT' => 'SabreForRainLoop\\VObject\\Property\\Number',
'FLOAT' => 'SabreForRainLoop\\VObject\\Property\\FloatValue',
'INTEGER' => 'SabreForRainLoop\\VObject\\Property\\Integer',
'PERIOD' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Period',
'RECUR' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Recur',
@ -80,7 +80,7 @@ class VCalendar extends VObject\Document {
'CLASS' => 'SabreForRainLoop\\VObject\\Property\\FlatText',
'COMMENT' => 'SabreForRainLoop\\VObject\\Property\\FlatText',
'DESCRIPTION' => 'SabreForRainLoop\\VObject\\Property\\FlatText',
'GEO' => 'SabreForRainLoop\\VObject\\Property\\Number',
'GEO' => 'SabreForRainLoop\\VObject\\Property\\FloatValue',
'LOCATION' => 'SabreForRainLoop\\VObject\\Property\\FlatText',
'PERCENT-COMPLETE' => 'SabreForRainLoop\\VObject\\Property\\Integer',
'PRIORITY' => 'SabreForRainLoop\\VObject\\Property\\Integer',

View file

@ -45,7 +45,7 @@ class VCard extends VObject\Document {
'DATE' => 'SabreForRainLoop\\VObject\\Property\\VCard\\Date',
'DATE-TIME' => 'SabreForRainLoop\\VObject\\Property\\VCard\\DateTime',
'DATE-AND-OR-TIME' => 'SabreForRainLoop\\VObject\\Property\\VCard\\DateAndOrTime', // vCard only
'FLOAT' => 'SabreForRainLoop\\VObject\\Property\\Number',
'FLOAT' => 'SabreForRainLoop\\VObject\\Property\\FloatValue',
'INTEGER' => 'SabreForRainLoop\\VObject\\Property\\Integer',
'LANGUAGE-TAG' => 'SabreForRainLoop\\VObject\\Property\\VCard\\LanguageTag',
'TIMESTAMP' => 'SabreForRainLoop\\VObject\\Property\\VCard\\TimeStamp',

View file

@ -6,7 +6,7 @@ use
SabreForRainLoop\VObject\Property;
/**
* Number property
* Float property
*
* This object represents FLOAT values. These can be 1 or more floating-point
* numbers.
@ -15,7 +15,7 @@ use
* @author Evert Pot (http://evertpot.com/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
class Number extends Property {
class FloatValue extends Property {
/**
* In case this is a multi-value property. This string will be used as a

View file

@ -2,14 +2,13 @@
if (defined('APP_VERSION'))
{
if (!defined('APP_START_TIME'))
if (!defined('APP_REQUEST_RND'))
{
@ini_set('register_globals', 0);
@ini_set('zend.ze1_compatibility_mode', 0);
@ini_set('magic_quotes_gpc', 0);
@ini_set('magic_quotes_runtime', 0);
define('APP_START_TIME', time());
define('APP_REQUEST_RND', function_exists('uuid_create') ? md5(uuid_create(UUID_TYPE_DEFAULT)) : bin2hex(random_bytes(16)));
define('APP_VERSION_ROOT_PATH', APP_INDEX_ROOT_PATH.'rainloop/v/'.APP_VERSION.'/');