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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -87,9 +87,6 @@ class ImapClient extends \MailSo\Net\NetClient
*/ */
public $__FORCE_SELECT_ON_EXAMINE__; public $__FORCE_SELECT_ON_EXAMINE__;
/**
* @access protected
*/
protected function __construct() protected function __construct()
{ {
parent::__construct(); parent::__construct();
@ -115,38 +112,25 @@ class ImapClient extends \MailSo\Net\NetClient
@\ini_set('xdebug.max_nesting_level', 500); @\ini_set('xdebug.max_nesting_level', 500);
} }
/** public static function NewInstance() : self
* @return \MailSo\Imap\ImapClient
*/
public static function NewInstance()
{ {
return new self(); return new self();
} }
/** public function GetLogginedUser() : string
* @return string
*/
public function GetLogginedUser()
{ {
return $this->sLogginedUser; 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function Connect($sServerName, $iPort = 143, public function Connect(string $sServerName, int $iPort = 143,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true, bool $bVerifySsl = false, bool $bAllowSelfSigned = true,
$sClientCert = '') : void string $sClientCert = '') : void
{ {
$this->aTagTimeouts['*'] = \microtime(true); $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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function Login($sLogin, $sPassword, $sProxyAuthUser = '', public function Login(string $sLogin, string $sPassword, string $sProxyAuthUser = '',
$bUseAuthPlainIfSupported = true, $bUseAuthCramMd5IfSupported = true) bool $bUseAuthPlainIfSupported = true, bool $bUseAuthCramMd5IfSupported = true) : self
{ {
if (!\MailSo\Base\Validator::NotEmptyString($sLogin, true) || if (!\MailSo\Base\Validator::NotEmptyString($sLogin, true) ||
!\MailSo\Base\Validator::NotEmptyString($sPassword, 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 * @throws \MailSo\Net\Exceptions\Exception
*/ */
public function Logout() public function Logout() : self
{ {
if ($this->bIsLoggined) if ($this->bIsLoggined)
{ {
@ -334,52 +308,38 @@ class ImapClient extends \MailSo\Net\NetClient
return $this; return $this;
} }
/** public function ForceCloseConnection() : self
* @return \MailSo\Imap\ImapClient
*/
public function ForceCloseConnection()
{ {
$this->Disconnect(); $this->Disconnect();
return $this; return $this;
} }
/** public function IsLoggined() : bool
* @return bool
*/
public function IsLoggined()
{ {
return $this->IsConnected() && $this->bIsLoggined; return $this->IsConnected() && $this->bIsLoggined;
} }
/** public function IsSelected() : bool
* @return bool
*/
public function IsSelected()
{ {
return $this->IsLoggined() && $this->bIsSelected; return $this->IsLoggined() && $this->bIsSelected;
} }
/** /**
* @return array|null
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function Capability() public function Capability() : ?array
{ {
$this->SendRequestWithCheck('CAPABILITY', array(), true); $this->SendRequestWithCheck('CAPABILITY', array(), true);
return $this->aCapabilityItems; return $this->aCapabilityItems;
} }
/** /**
* @param string $sExtentionName
* @return bool
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function IsSupported($sExtentionName) public function IsSupported(string $sExtentionName) : bool
{ {
$bResult = \MailSo\Base\Validator::NotEmptyString($sExtentionName, true); $bResult = \MailSo\Base\Validator::NotEmptyString($sExtentionName, true);
if ($bResult && null === $this->aCapabilityItems) 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\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function GetNamespace() public function GetNamespace() : ?\MailSo\Imap\NamespaceResult
{ {
if (!$this->IsSupported('NAMESPACE')) if (!$this->IsSupported('NAMESPACE'))
{ {
return null; return null;
} }
$oReturn = false; $oReturn = null;
$this->SendRequest('NAMESPACE'); $this->SendRequest('NAMESPACE');
$aResult = $this->parseResponseWithValidation(); $aResult = $this->parseResponseWithValidation();
@ -421,7 +379,7 @@ class ImapClient extends \MailSo\Net\NetClient
} }
} }
if (false === $oReturn) if (!$oReturn)
{ {
$this->writeLogException( $this->writeLogException(
new \MailSo\Imap\Exceptions\ResponseException(), 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\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function Noop() public function Noop() : self
{ {
return $this->SendRequestWithCheck('NOOP'); return $this->SendRequestWithCheck('NOOP');
} }
/** /**
* @param string $sFolderName
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function FolderCreate($sFolderName) public function FolderCreate(string $sFolderName) : self
{ {
return $this->SendRequestWithCheck('CREATE', return $this->SendRequestWithCheck('CREATE',
array($this->EscapeString($sFolderName))); array($this->EscapeString($sFolderName)));
} }
/** /**
* @param string $sFolderName
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function FolderDelete($sFolderName) public function FolderDelete(string $sFolderName) : self
{ {
return $this->SendRequestWithCheck('DELETE', return $this->SendRequestWithCheck('DELETE',
array($this->EscapeString($sFolderName))); array($this->EscapeString($sFolderName)));
} }
/** /**
* @param string $sFolderName
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function FolderSubscribe($sFolderName) public function FolderSubscribe(string $sFolderName) : self
{ {
return $this->SendRequestWithCheck('SUBSCRIBE', return $this->SendRequestWithCheck('SUBSCRIBE',
array($this->EscapeString($sFolderName))); array($this->EscapeString($sFolderName)));
} }
/** /**
* @param string $sFolderName
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function FolderUnSubscribe($sFolderName) public function FolderUnSubscribe(string $sFolderName) : self
{ {
return $this->SendRequestWithCheck('UNSUBSCRIBE', return $this->SendRequestWithCheck('UNSUBSCRIBE',
array($this->EscapeString($sFolderName))); array($this->EscapeString($sFolderName)));
} }
/** /**
* @param string $sOldFolderName
* @param string $sNewFolderName
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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( return $this->SendRequestWithCheck('RENAME', array(
$this->EscapeString($sOldFolderName), $this->EscapeString($sOldFolderName),
$this->EscapeString($sNewFolderName))); $this->EscapeString($sNewFolderName)));
} }
/** protected function getStatusFolderInformation(array $aResult) : array
* @param array $aResult
*
* @return array
*/
protected function getStatusFolderInformation($aResult)
{ {
$aReturn = 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function FolderStatus($sFolderName, array $aStatusItems) public function FolderStatus(string $sFolderName, array $aStatusItems) : array
{ {
$aResult = false; $aResult = false;
if (\count($aStatusItems) > 0) if (\count($aStatusItems) > 0)
@ -582,14 +507,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $aResult; return $aResult;
} }
/** private function getFoldersFromResult(array $aResult, string $sStatus, bool $bUseListStatus = false) : array
* @param array $aResult
* @param string $sStatus
* @param bool $bUseListStatus = false
*
* @return array
*/
private function getFoldersFromResult(array $aResult, $sStatus, $bUseListStatus = false)
{ {
$aReturn = 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\Net\Exceptions\Exception
* @throws \MailSo\Imap\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'; $sCmd = 'LSUB';
if (!$bIsSubscribeList) 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\Net\Exceptions\Exception
* @throws \MailSo\Imap\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); return $this->specificFolderList(false, $sParentFolderName, $sListPattern);
} }
/** /**
* @param string $sParentFolderName = ''
* @param string $sListPattern = '*'
*
* @return array
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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); return $this->specificFolderList(true, $sParentFolderName, $sListPattern);
} }
/** /**
* @param string $sParentFolderName = ''
* @param string $sListPattern = '*'
*
* @return array
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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); return $this->specificFolderList(false, $sParentFolderName, $sListPattern, true);
} }
/** protected function initCurrentFolderInformation(array $aResult, string $sFolderName, bool $bIsWritable) : void
* @param array $aResult
* @param string $sFolderName
* @param bool $bIsWritable
*/
protected function initCurrentFolderInformation($aResult, $sFolderName, $bIsWritable) : void
{ {
if (\is_array($aResult)) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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); return $this->selectOrExamineFolder($sFolderName, true, $bReSelectSameFolders);
} }
/** /**
* @param string $sFolderName
* @param bool $bReSelectSameFolders = false
*
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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 $this->selectOrExamineFolder($sFolderName, $this->__FORCE_SELECT_ON_EXAMINE__, $bReSelectSameFolders);
} }
/** /**
* @return \MailSo\Imap\ImapClient
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function FolderUnSelect() public function FolderUnSelect() : self
{ {
if ($this->IsSelected() && $this->IsSupported('UNSELECT')) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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; $sIndexRange = (string) $sIndexRange;
if (!\MailSo\Base\Validator::NotEmptyString($sIndexRange, true)) 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\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function Quota() public function Quota() : array
{ {
$aReturn = false; $aReturn = false;
if ($this->IsSupported('QUOTA')) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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 ' : ''; $sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = !\MailSo\Base\Validator::NotEmptyString($sSearchCriterias, true) || '*' === $sSearchCriterias $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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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 ' : ''; $sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = 0 === \strlen($sSearchCriterias) || '*' === $sSearchCriterias $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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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); 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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); return $this->simpleESearchOrESortHelper(true, $sSearchCriterias, $aSearchReturn, $bReturnUid, $sLimit, '', $aSortTypes);
} }
/** private function findLastResponse(array $aResult) : \MailSo\Imap\Response
* @param array $aResult
* @return \MailSo\Imap\Response
*/
private function findLastResponse($aResult)
{ {
$oResult = null; $oResult = null;
if (\is_array($aResult) && 0 < \count($aResult)) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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 ' : ''; $sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = 0 === \strlen($sSearchCriterias) || '*' === $sSearchCriterias $sSearchCriterias = 0 === \strlen($sSearchCriterias) || '*' === $sSearchCriterias
@ -1383,7 +1206,7 @@ class ImapClient extends \MailSo\Net\NetClient
* *
* @return mixed * @return mixed
*/ */
private function validateThreadItem($aValue) private function validateThreadItem(array $aValue)
{ {
$mResult = false; $mResult = false;
if (\is_numeric($aValue)) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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 ' : ''; $sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
$sSearchCriterias = !\MailSo\Base\Validator::NotEmptyString($sSearchCriterias, true) || '*' === $sSearchCriterias $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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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)) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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)) 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\Net\Exceptions\Exception
* @throws \MailSo\Imap\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); $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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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) || if (!\MailSo\Base\Validator::NotEmptyString($sIndexRange, true) ||
!\MailSo\Base\Validator::NotEmptyString($sStoreAction, true) || !\MailSo\Base\Validator::NotEmptyString($sStoreAction, true) ||
@ -1610,25 +1402,18 @@ class ImapClient extends \MailSo\Net\NetClient
} }
/** /**
* @param string $sFolderName
* @param resource $rMessageAppendStream * @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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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); $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.'}'; $aData[] = '{'.$iStreamSize.'}';
@ -1666,25 +1451,16 @@ class ImapClient extends \MailSo\Net\NetClient
return $this; return $this;
} }
/** public function FolderCurrentInformation() : \MailSo\Imap\FolderInformation
* @return \MailSo\Imap\FolderInformation
*/
public function FolderCurrentInformation()
{ {
return $this->oCurrentFolderInfo; return $this->oCurrentFolderInfo;
} }
/** /**
* @param string $sCommand
* @param array $aParams = array()
* @param bool $bBreakOnLiteral = false
*
* @return string
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @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)) if (!\MailSo\Base\Validator::NotEmptyString($sCommand, true) || !\is_array($aParams))
{ {
@ -1727,13 +1503,7 @@ class ImapClient extends \MailSo\Net\NetClient
return ''; return '';
} }
/** private function secureRequestParams(string $sCommand, array $aParams) : ?array
* @param string $sCommand
* @param array $aParams
*
* @return array|null
*/
private function secureRequestParams($sCommand, $aParams)
{ {
$aResult = null; $aResult = null;
switch ($sCommand) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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->SendRequest($sCommand, $aParams);
$this->parseResponseWithValidation(null, $bFindCapa); $this->parseResponseWithValidation(null, $bFindCapa);
@ -1769,10 +1533,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $this; return $this;
} }
/** public function GetLastResponse() : array
* @return array
*/
public function GetLastResponse()
{ {
return $this->aLastResponse; return $this->aLastResponse;
} }
@ -1780,13 +1541,11 @@ class ImapClient extends \MailSo\Net\NetClient
/** /**
* @param mixed $aResult * @param mixed $aResult
* *
* @return array
*
* @throws \MailSo\Imap\Exceptions\ResponseNotFoundException * @throws \MailSo\Imap\Exceptions\ResponseNotFoundException
* @throws \MailSo\Imap\Exceptions\InvalidResponseException * @throws \MailSo\Imap\Exceptions\InvalidResponseException
* @throws \MailSo\Imap\Exceptions\NegativeResponseException * @throws \MailSo\Imap\Exceptions\NegativeResponseException
*/ */
private function validateResponse($aResult) private function validateResponse(array $aResult) : array
{ {
if (!\is_array($aResult) || 0 === $iCnt = \count($aResult)) if (!\is_array($aResult) || 0 === $iCnt = \count($aResult))
{ {
@ -1815,13 +1574,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $aResult; return $aResult;
} }
/** protected function parseResponse(string $sEndTag = null, bool $bFindCapa = false) : array
* @param string $sEndTag = null
* @param bool $bFindCapa = false
*
* @return array|bool
*/
protected function parseResponse($sEndTag = null, $bFindCapa = false)
{ {
if (\is_resource($this->rConnect)) if (\is_resource($this->rConnect))
{ {
@ -1876,13 +1629,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $this->aLastResponse; return $this->aLastResponse;
} }
/** private function parseResponseWithValidation(string $sEndTag = null, bool $bFindCapa = false) : array
* @param string $sEndTag = null
* @param bool $bFindCapa = false
*
* @return array
*/
private function parseResponseWithValidation($sEndTag = null, $bFindCapa = false)
{ {
return $this->validateResponse($this->parseResponse($sEndTag, $bFindCapa)); 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 * @throws \MailSo\Net\Exceptions\Exception
*/ */
private function partialParseResponseBranch(&$oImapResponse, $iStackIndex = -1, private function partialParseResponseBranch(&$oImapResponse, int $iStackIndex = -1,
$bTreatAsAtom = false, $sParentToken = '', $sOpenBracket = '') bool $bTreatAsAtom = false, string $sParentToken = '', string $sOpenBracket = '') : array
{ {
$mNull = null; $mNull = null;
@ -2394,14 +2139,9 @@ class ImapClient extends \MailSo\Net\NetClient
} }
/** /**
* @param string $sParent
* @param string $sLiteralAtomUpperCase
* @param resource $rImapStream * @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 = ''; $sLiteralAtomUpperCasePeek = '';
if (0 === \strpos($sLiteralAtomUpperCase, 'BODY')) if (0 === \strpos($sLiteralAtomUpperCase, 'BODY'))
@ -2440,7 +2180,7 @@ class ImapClient extends \MailSo\Net\NetClient
\call_user_func($this->aFetchCallbacks[$sFetchKey], \call_user_func($this->aFetchCallbacks[$sFetchKey],
$sParent, $sLiteralAtomUpperCase, $rImapLiteralStream); $sParent, $sLiteralAtomUpperCase, $rImapLiteralStream);
} }
catch (\Exception $oException) catch (\Throwable $oException)
{ {
$this->writeLog('Callback Exception', \MailSo\Log\Enumerations\Type::NOTICE); $this->writeLog('Callback Exception', \MailSo\Log\Enumerations\Type::NOTICE);
$this->writeLogException($oException); $this->writeLogException($oException);
@ -2500,12 +2240,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $bResult; return $bResult;
} }
/** private function prepearParamLine(array $aParams = array()) : string
* @param array $aParams = null
*
* @return string
*/
private function prepearParamLine($aParams = array())
{ {
$sReturn = ''; $sReturn = '';
if (\is_array($aParams) && 0 < \count($aParams)) if (\is_array($aParams) && 0 < \count($aParams))
@ -2525,48 +2260,31 @@ class ImapClient extends \MailSo\Net\NetClient
return $sReturn; return $sReturn;
} }
/** private function getNewTag() : string
* @return string
*/
private function getNewTag()
{ {
$this->iTagCount++; $this->iTagCount++;
return $this->getCurrentTag(); return $this->getCurrentTag();
} }
/** private function getCurrentTag() : string
* @return string
*/
private function getCurrentTag()
{ {
return self::TAG_PREFIX.$this->iTagCount; return self::TAG_PREFIX.$this->iTagCount;
} }
/** public function EscapeString(string $sStringForEscape) : string
* @param string $sStringForEscape
*
* @return string
*/
public function EscapeString($sStringForEscape)
{ {
return '"'.\str_replace(array('\\', '"'), array('\\\\', '\\"'), $sStringForEscape).'"'; return '"'.\str_replace(array('\\', '"'), array('\\\\', '\\"'), $sStringForEscape).'"';
} }
/** protected function getLogName() : string
* @return string
*/
protected function getLogName()
{ {
return 'IMAP'; return 'IMAP';
} }
/** /**
* @param resource $rConnect * @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->rConnect = $rConnect;
$this->aCapabilityItems = $aCapabilityItems; $this->aCapabilityItems = $aCapabilityItems;
@ -2574,13 +2292,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $this; return $this;
} }
/** public function TestParseResponseWithValidationProxy(string $sEndTag = null, bool $bFindCapa = false) : array
* @param string $sEndTag = null
* @param string $bFindCapa = false
*
* @return array
*/
public function TestParseResponseWithValidationProxy($sEndTag = null, $bFindCapa = false)
{ {
return $this->parseResponseWithValidation($sEndTag, $bFindCapa); return $this->parseResponseWithValidation($sEndTag, $bFindCapa);
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -27,9 +27,6 @@ class MailClient
*/ */
private $oImapClient; private $oImapClient;
/**
* @access private
*/
private function __construct() private function __construct()
{ {
$this->oLogger = null; $this->oLogger = null;
@ -38,114 +35,77 @@ class MailClient
$this->oImapClient->SetTimeOuts(10, \MailSo\Config::$ImapTimeout); $this->oImapClient->SetTimeOuts(10, \MailSo\Config::$ImapTimeout);
} }
/** public static function NewInstance() : self
* @return \MailSo\Mail\MailClient
*/
public static function NewInstance()
{ {
return new self(); return new self();
} }
/** public function ImapClient() : \MailSo\Imap\ImapClient
* @return \MailSo\Imap\ImapClient
*/
public function ImapClient()
{ {
return $this->oImapClient; 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function Connect($sServerName, $iPort = 143, public function Connect(string $sServerName, int $iPort = 143,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bVerifySsl = false, $bAllowSelfSigned = false, $sClientCert = '') 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); $this->oImapClient->Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl, $bAllowSelfSigned, $sClientCert);
return $this; 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\LoginException * @throws \MailSo\Imap\Exceptions\LoginException
*/ */
public function Login($sLogin, $sPassword, $sProxyAuthUser = '', public function Login(string $sLogin, string $sPassword, string $sProxyAuthUser = '',
$bUseAuthPlainIfSupported = true, $bUseAuthCramMd5IfSupported = true) bool $bUseAuthPlainIfSupported = true, bool $bUseAuthCramMd5IfSupported = true) : self
{ {
$this->oImapClient->Login($sLogin, $sPassword, $sProxyAuthUser, $bUseAuthPlainIfSupported, $bUseAuthCramMd5IfSupported); $this->oImapClient->Login($sLogin, $sPassword, $sProxyAuthUser, $bUseAuthPlainIfSupported, $bUseAuthCramMd5IfSupported);
return $this; return $this;
} }
/** /**
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
*/ */
public function Logout() public function Logout() : self
{ {
$this->oImapClient->Logout(); $this->oImapClient->Logout();
return $this; return $this;
} }
/** /**
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
*/ */
public function Disconnect() public function Disconnect() : self
{ {
$this->oImapClient->Disconnect(); $this->oImapClient->Disconnect();
return $this; return $this;
} }
/** /**
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
*/ */
public function LogoutAndDisconnect() public function LogoutAndDisconnect() : self
{ {
return $this->Logout()->Disconnect(); return $this->Logout()->Disconnect();
} }
/** public function IsConnected() : bool
* @return bool
*/
public function IsConnected()
{ {
return $this->oImapClient->IsConnected(); return $this->oImapClient->IsConnected();
} }
/** public function IsLoggined() : bool
* @return bool
*/
public function IsLoggined()
{ {
return $this->oImapClient->IsLoggined(); return $this->oImapClient->IsLoggined();
} }
/** private function getEnvelopeOrHeadersRequestStringForSimpleList() : string
* @return string
*/
private function getEnvelopeOrHeadersRequestStringForSimpleList()
{ {
return \MailSo\Imap\Enumerations\FetchType::BuildBodyCustomHeaderRequest(array( return \MailSo\Imap\Enumerations\FetchType::BuildBodyCustomHeaderRequest(array(
\MailSo\Mime\Enumerations\Header::RETURN_PATH, \MailSo\Mime\Enumerations\Header::RETURN_PATH,
@ -163,9 +123,6 @@ class MailClient
), true); ), true);
} }
/**
* @return string
*/
private function getEnvelopeOrHeadersRequestString() private function getEnvelopeOrHeadersRequestString()
{ {
if (\MailSo\Config::$MessageAllHeaders) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
* @throws \MailSo\Mail\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); $this->oImapClient->FolderSelect($sFolderName);
$oFolderInfo = $this->oImapClient->FolderCurrentInformation(); $oFolderInfo = $this->oImapClient->FolderCurrentInformation();
if (!$oFolderInfo || !$oFolderInfo->IsFlagSupported($sMessageFlag)) if (!$oFolderInfo || !$oFolderInfo->IsFlagSupported($sMessageFlag))
{ {
if (!$sSkipUnsupportedFlag) if (!$bSkipUnsupportedFlag)
{ {
throw new \MailSo\Mail\Exceptions\RuntimeException('Message flag "'.$sMessageFlag.'" is not supported.'); 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
* @throws \MailSo\Mail\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); $this->oImapClient->FolderSelect($sFolderName);
$oFolderInfo = $this->oImapClient->FolderCurrentInformation(); $oFolderInfo = $this->oImapClient->FolderCurrentInformation();
if (!$oFolderInfo || !$oFolderInfo->IsFlagSupported($sMessageFlag)) if (!$oFolderInfo || !$oFolderInfo->IsFlagSupported($sMessageFlag))
{ {
if (!$sSkipUnsupportedFlag) if (!$bSkipUnsupportedFlag)
{ {
throw new \MailSo\Mail\Exceptions\RuntimeException('Message flag "'.$sMessageFlag.'" is not supported.'); 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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, $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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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); $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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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, $this->MessageSetFlag($sFolderName, $aIndexRange, $bIndexIsUid,
\MailSo\Imap\Enumerations\MessageFlag::SEEN, $bSetAction, true); \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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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)) if (!\MailSo\Base\Validator::RangeInt($iIndex, 1))
{ {
@ -370,13 +291,9 @@ class MailClient
$oBodyStructure = $aFetchResponse[0]->GetFetchBodyStructure(); $oBodyStructure = $aFetchResponse[0]->GetFetchBodyStructure();
if ($oBodyStructure) if ($oBodyStructure)
{ {
$aTextParts = $oBodyStructure->SearchHtmlOrPlainParts(); foreach ($oBodyStructure->SearchHtmlOrPlainParts() as $oPart)
if (is_array($aTextParts) && 0 < \count($aTextParts))
{ {
foreach ($aTextParts as $oPart) $aBodyPeekMimeIndexes[] = array($oPart->PartID(), $oPart->Size());
{
$aBodyPeekMimeIndexes[] = array($oPart->PartID(), $oPart->Size());
}
} }
$aSignatureParts = $oBodyStructure->SearchByContentType('application/pgp-signature'); $aSignatureParts = $oBodyStructure->SearchByContentType('application/pgp-signature');
@ -404,9 +321,9 @@ class MailClient
foreach ($aBodyPeekMimeIndexes as $aTextMimeData) foreach ($aBodyPeekMimeIndexes as $aTextMimeData)
{ {
$sLine = \MailSo\Imap\Enumerations\FetchType::BODY_PEEK.'['.$aTextMimeData[0].']'; $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; $aFetchItems[] = $sLine;
@ -432,24 +349,16 @@ class MailClient
$oMessage = \MailSo\Mail\Message::NewFetchResponseInstance( $oMessage = \MailSo\Mail\Message::NewFetchResponseInstance(
$sFolderName, $aFetchResponse[0], $oBodyStructure); $sFolderName, $aFetchResponse[0], $oBodyStructure);
} }
return $oMessage;
} }
/** /**
* @param mixed $mCallback * @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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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)) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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)) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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) || if (0 === \strlen($sFromFolder) || 0 === \strlen($sToFolder) ||
!\is_array($aIndexRange) || 0 === \count($aIndexRange)) !\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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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) || if (0 === \strlen($sFromFolder) || 0 === \strlen($sToFolder) ||
!\is_array($aIndexRange) || 0 === \count($aIndexRange)) !\is_array($aIndexRange) || 0 === \count($aIndexRange))
@ -640,12 +525,10 @@ class MailClient
} }
/** /**
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function FolderUnSelect() public function FolderUnSelect() : self
{ {
if ($this->oImapClient->IsSelected()) if ($this->oImapClient->IsSelected())
{ {
@ -657,14 +540,8 @@ class MailClient
/** /**
* @param resource $rMessageStream * @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)) if (!\is_resource($rMessageStream) || 0 === \strlen($sFolderToSave))
{ {
@ -677,15 +554,7 @@ class MailClient
return $this; return $this;
} }
/** public function MessageAppendFile(string $sMessageFileName, string $sFolderToSave, array $aAppendFlags = null, int &$iUid = null) : self
* @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)
{ {
if (!@\is_file($sMessageFileName) || !@\is_readable($sMessageFileName)) if (!@\is_file($sMessageFileName) || !@\is_readable($sMessageFileName))
{ {
@ -705,15 +574,8 @@ class MailClient
return $this; return $this;
} }
/** protected function initFolderValues(string $sFolderName, int &$iCount, int &$iUnseenCount,
* @param string $sFolderName string &$sUidNext, string &$sHighestModSeq = '') : void
* @param int $iCount
* @param int $iUnseenCount
* @param string $sUidNext
* @param string $sHighestModSeq
*/
protected function initFolderValues($sFolderName, &$iCount, &$iUnseenCount,
&$sUidNext, &$sHighestModSeq = '') : void
{ {
$aTypes = array( $aTypes = array(
\MailSo\Imap\Enumerations\FolderResponseStatus::MESSAGES, \MailSo\Imap\Enumerations\FolderResponseStatus::MESSAGES,
@ -755,10 +617,7 @@ class MailClient
} }
} }
/** public function GenerateImapClientHash() : string
* @return string
*/
public function GenerateImapClientHash()
{ {
return \md5('ImapClientHash/'. return \md5('ImapClientHash/'.
$this->oImapClient->GetLogginedUser().'@'. $this->oImapClient->GetLogginedUser().'@'.
@ -767,16 +626,7 @@ class MailClient
); );
} }
/** public function GenerateFolderHash(string $sFolder, int $iCount, int $iUnseenCount, string $sUidNext, string $sHighestModSeq = '') : string
* @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 = '')
{ {
$iUnseenCount = 0; // unneccessery $iUnseenCount = 0; // unneccessery
return \md5('FolderHash/'.$sFolder.'-'.$iCount.'-'.$iUnseenCount.'-'.$sUidNext.'-'. return \md5('FolderHash/'.$sFolder.'-'.$iCount.'-'.$iUnseenCount.'-'.$sUidNext.'-'.
@ -785,14 +635,7 @@ class MailClient
); );
} }
/** private function getFolderNextMessageInformation(string $sFolderName, string $sPrevUidNext, string $sCurrentUidNext) : array
* @param string $sFolderName
* @param string $sPrevUidNext
* @param string $sCurrentUidNext
*
* @return array
*/
private function getFolderNextMessageInformation($sFolderName, $sPrevUidNext, $sCurrentUidNext)
{ {
$aNewMessages = 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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(); $aFlags = array();
@ -925,15 +762,11 @@ class MailClient
} }
/** /**
* @param string $sFolderName
*
* @return string
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function FolderHash($sFolderName) public function FolderHash(string $sFolderName) : string
{ {
$iCount = 0; $iCount = 0;
$iUnseenCount = 0; $iUnseenCount = 0;
@ -946,12 +779,10 @@ class MailClient
} }
/** /**
* @return int
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function InboxUnreadCount() public function InboxUnreadCount() : int
{ {
$aFolderStatus = $this->oImapClient->FolderStatus('INBOX', array( $aFolderStatus = $this->oImapClient->FolderStatus('INBOX', array(
\MailSo\Imap\Enumerations\FolderResponseStatus::UNSEEN \MailSo\Imap\Enumerations\FolderResponseStatus::UNSEEN
@ -963,21 +794,12 @@ class MailClient
return 0 < $iResult ? $iResult : 0; return 0 < $iResult ? $iResult : 0;
} }
/** public function IsGmail() : bool
* @return bool
*/
public function IsGmail()
{ {
return 'ssl://imap.gmail.com' === \strtolower($this->oImapClient->GetConnectedHost()); return 'ssl://imap.gmail.com' === \strtolower($this->oImapClient->GetConnectedHost());
} }
/** private function escapeSearchString(string $sSearch, bool $bDetectGmail = true) : string
* @param string $sSearch
* @param bool $bDetectGmail = true
*
* @return string
*/
private function escapeSearchString($sSearch, $bDetectGmail = true)
{ {
return !\MailSo\Base\Utils::IsAscii($sSearch) return !\MailSo\Base\Utils::IsAscii($sSearch)
? '{'.\strlen($sSearch).'}'."\r\n".$sSearch : $this->oImapClient->EscapeString($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); // ? '{'.\strlen($sSearch).'+}'."\r\n".$sSearch : $this->oImapClient->EscapeString($sSearch);
} }
/** private function parseSearchDate(string $sDate, int $iTimeZoneOffset) : int
* @param string $sDate
* @param int $iTimeZoneOffset
*
* @return int
*/
private function parseSearchDate($sDate, $iTimeZoneOffset)
{ {
$iResult = 0; $iResult = 0;
if (0 < \strlen($sDate)) if (0 < \strlen($sDate))
@ -1003,12 +819,7 @@ class MailClient
return $iResult; return $iResult;
} }
/** private function parseFriendlySize(string $sSize) : int
* @param string $sSize
*
* @return int
*/
private function parseFriendlySize($sSize)
{ {
$sSize = preg_replace('/[^0-9bBkKmM]/', '', $sSize); $sSize = preg_replace('/[^0-9bBkKmM]/', '', $sSize);
@ -1039,12 +850,7 @@ class MailClient
return $iResult; return $iResult;
} }
/** private function parseSearchString(string $sSearch) : array
* @param string $sSearch
*
* @return array
*/
private function parseSearchString($sSearch)
{ {
$aResult = array( $aResult = array(
'OTHER' => '' 'OTHER' => ''
@ -1163,15 +969,7 @@ class MailClient
return $aResult; return $aResult;
} }
/** private function getImapSearchCriterias(string $sSearch, string $sFilter, int $iTimeZoneOffset = 0, bool &$bUseCache = true) : string
* @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)
{ {
$bUseCache = true; $bUseCache = true;
$iTimeFilter = 0; $iTimeFilter = 0;
@ -1436,11 +1234,7 @@ class MailClient
return $sCriteriasResult; return $sCriteriasResult;
} }
/** private function threadArrayMap(array $aThreads) : array
* @param array $aThreads
* @return array
*/
private function threadArrayMap($aThreads)
{ {
$aNew = array(); $aNew = array();
foreach ($aThreads as $mItem) foreach ($aThreads as $mItem)
@ -1462,12 +1256,7 @@ class MailClient
return $aNew; return $aNew;
} }
/** private function compileThreadArray(array $aThreads) : array
* @param array $aThreads
*
* @return array
*/
private function compileThreadArray($aThreads)
{ {
$aResult = array(); $aResult = array();
foreach ($aThreads as $mItem) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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; $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\Net\Exceptions\Exception
* @throws \MailSo\Imap\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)) if (\is_array($aRequestIndexOrUids) && 0 < \count($aRequestIndexOrUids))
{ {
@ -1747,11 +1523,9 @@ class MailClient
} }
/** /**
* @return bool
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
*/ */
public function IsThreadsSupported() public function IsThreadsSupported() : bool
{ {
return $this->oImapClient->IsSupported('THREAD=REFS') || return $this->oImapClient->IsSupported('THREAD=REFS') ||
$this->oImapClient->IsSupported('THREAD=REFERENCES') || $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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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)) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\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; $aResultUids = false;
$bUidsFromCacher = 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function MessageList($sFolderName, $iOffset = 0, $iLimit = 10, $sSearch = '', $sPrevUidNext = '', $oCacher = null, public function MessageList(string $sFolderName, int $iOffset = 0, int $iLimit = 10,
$bUseSortIfSupported = false, $bUseThreadSortIfSupported = false, $sThreadUid = '', $sFilter = '') string $sSearch = '', string $sPrevUidNext = '', ?\MailSo\Cache\CacheClient $oCacher = null,
bool $bUseSortIfSupported = false, bool $bUseThreadSortIfSupported = false,
string $sThreadUid = '', string $sFilter = '')
{ {
$sFilter = \trim($sFilter); $sFilter = \trim($sFilter);
$sSearch = \trim($sSearch); $sSearch = \trim($sSearch);
@ -2131,21 +1879,12 @@ class MailClient
return $oMessageCollection; return $oMessageCollection;
} }
/** public function Quota() : array
* @return array|false
*/
public function Quota()
{ {
return $this->oImapClient->Quota(); return $this->oImapClient->Quota();
} }
/** public function FindMessageUidByMessageId(string $sFolderName, string $sMessageId) : ?int
* @param string $sFolderName
* @param string $sMessageId
*
* @return int|null
*/
public function FindMessageUidByMessageId($sFolderName, $sMessageId)
{ {
if (0 === \strlen($sMessageId)) 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; return \is_array($aUids) && 1 === \count($aUids) && \is_numeric($aUids[0]) ? (int) $aUids[0] : null;
} }
/** public function folderListOptimization(array $aMailFoldersHelper, int $iOptimizationLimit = 0) : array
* @param array $aMailFoldersHelper
* @param int $iOptimizationLimit = 0
*
* @return array
*/
public function folderListOptimization($aMailFoldersHelper, $iOptimizationLimit = 0)
{ {
// optimization // optimization
if (10 < $iOptimizationLimit && \is_array($aMailFoldersHelper) && $iOptimizationLimit < \count($aMailFoldersHelper)) if (10 < $iOptimizationLimit && \is_array($aMailFoldersHelper) && $iOptimizationLimit < \count($aMailFoldersHelper))
@ -2294,15 +2027,7 @@ class MailClient
return $aMailFoldersHelper; return $aMailFoldersHelper;
} }
/** public function Folders(string $sParent = '', string $sListPattern = '*', bool $bUseListSubscribeStatus = true, int $iOptimizationLimit = 0) : \MailSo\Mail\FolderCollection
* @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)
{ {
$oFolderCollection = false; $oFolderCollection = false;
@ -2313,7 +2038,7 @@ class MailClient
{ {
$aSubscribedFolders = $this->oImapClient->FolderSubscribeList($sParent, $sListPattern); $aSubscribedFolders = $this->oImapClient->FolderSubscribeList($sParent, $sListPattern);
} }
catch (\Exception $oException) catch (\Throwable $oException)
{ {
unset($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 * @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) || if (!\MailSo\Base\Validator::NotEmptyString($sFolderNameInUtf8, true) ||
!\is_string($sFolderParentFullNameRaw)) !\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 * @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); 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 * @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); 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 * @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)) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Mail\Exceptions\RuntimeException * @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) if (0 === \strlen($sFolderFullNameRaw) || 'INBOX' === $sFolderFullNameRaw)
{ {
@ -2595,13 +2289,9 @@ class MailClient
} }
/** /**
* @param string $sFolderFullNameRaw
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/ */
public function FolderClear($sFolderFullNameRaw) public function FolderClear(string $sFolderFullNameRaw) : self
{ {
$this->oImapClient->FolderSelect($sFolderFullNameRaw); $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 * @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/ */
public function FolderSubscribe($sFolderFullNameRaw, $bSubscribe) public function FolderSubscribe(string $sFolderFullNameRaw, bool $bSubscribe) : self
{ {
if (0 === \strlen($sFolderFullNameRaw)) if (0 === \strlen($sFolderFullNameRaw))
{ {
@ -2640,13 +2325,9 @@ class MailClient
} }
/** /**
* @param \MailSo\Log\Logger $oLogger
*
* @return \MailSo\Mail\MailClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/ */
public function SetLogger($oLogger) public function SetLogger(\MailSo\Log\Logger $oLogger) : self
{ {
if (!($oLogger instanceof \MailSo\Log\Logger)) if (!($oLogger instanceof \MailSo\Log\Logger))
{ {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -24,9 +24,6 @@ class ResponseException extends \MailSo\Sieve\Exceptions\Exception
private $aResponses; private $aResponses;
/** /**
* @param array $aResponses = array
* @param string $sMessage = ''
* @param int $iCode = 0
* @param \Exception $oPrevious = null * @param \Exception $oPrevious = null
*/ */
public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null) public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null)
@ -39,18 +36,12 @@ class ResponseException extends \MailSo\Sieve\Exceptions\Exception
} }
} }
/** public function GetResponses() : array
* @return array
*/
public function GetResponses()
{ {
return $this->aResponses; return $this->aResponses;
} }
/** public function GetLastResponse() : ?\MailSo\Sieve\Response
* @return \MailSo\Sieve\Response | null
*/
public function GetLastResponse()
{ {
return 0 < count($this->aResponses) ? $this->aResponses[count($this->aResponses) - 1] : null; 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; public $__USE_INITIAL_AUTH_PLAIN_COMMAND;
/**
* @access protected
*/
protected function __construct() protected function __construct()
{ {
parent::__construct(); parent::__construct();
@ -52,66 +49,39 @@ class ManageSieveClient extends \MailSo\Net\NetClient
$this->__USE_INITIAL_AUTH_PLAIN_COMMAND = true; $this->__USE_INITIAL_AUTH_PLAIN_COMMAND = true;
} }
/** public static function NewInstance() : self
* @return \MailSo\Sieve\ManageSieveClient
*/
public static function NewInstance()
{ {
return new self(); return new self();
} }
/** public function IsSupported(string $sCapa) : bool
* @param string $sCapa
*
* @return bool
*/
public function IsSupported($sCapa)
{ {
return isset($this->aCapa[\strtoupper($sCapa)]); return isset($this->aCapa[\strtoupper($sCapa)]);
} }
/** public function IsModuleSupported(string $sModule) : bool
* @param string $sModule
*
* @return bool
*/
public function IsModuleSupported($sModule)
{ {
return $this->IsSupported('SIEVE') && \in_array(\strtolower(\trim($sModule)), $this->aModules); return $this->IsSupported('SIEVE') && \in_array(\strtolower(\trim($sModule)), $this->aModules);
} }
/** public function Modules() : array
* @return array
*/
public function Modules()
{ {
return $this->aModules; return $this->aModules;
} }
/** public function IsAuthSupported(string $sAuth) : bool
* @param string $sAuth
*
* @return bool
*/
public function IsAuthSupported($sAuth)
{ {
return $this->IsSupported('SASL') && \in_array(\strtoupper($sAuth), $this->aAuth); 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\Net\Exceptions\Exception
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Sieve\Exceptions\ResponseException * @throws \MailSo\Sieve\Exceptions\ResponseException
*/ */
public function Connect($sServerName, $iPort, public function Connect(string $sServerName, int $iPort,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true, $sClientCert = '') : void bool $bVerifySsl = false, bool $bAllowSelfSigned = true, string $sClientCert = '') : void
{ {
$this->iRequestTime = \microtime(true); $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\Net\Exceptions\Exception
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Sieve\Exceptions\LoginException * @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) || if (!\MailSo\Base\Validator::NotEmptyString($sLogin, true) ||
!\MailSo\Base\Validator::NotEmptyString($sPassword, 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\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
public function Logout() public function Logout() : self
{ {
if ($this->bIsLoggined) if ($this->bIsLoggined)
{ {
@ -246,12 +208,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
} }
/** /**
* @return array
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
public function ListScripts() public function ListScripts() : array
{ {
$this->sendRequest('LISTSCRIPTS'); $this->sendRequest('LISTSCRIPTS');
$mResponse = $this->parseResponse(); $mResponse = $this->parseResponse();
@ -276,12 +236,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
} }
/** /**
* @return array
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
public function Capability() public function Capability() : array
{ {
$this->sendRequest('CAPABILITY'); $this->sendRequest('CAPABILITY');
$mResponse = $this->parseResponse(); $mResponse = $this->parseResponse();
@ -292,12 +250,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
} }
/** /**
* @return \MailSo\Sieve\ManageSieveClient
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
public function Noop() public function Noop() : self
{ {
$this->sendRequestWithCheck('NOOP'); $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\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
public function GetScript($sScriptName) public function GetScript(string $sScriptName) : string
{ {
$this->sendRequest('GETSCRIPT "'.$sScriptName.'"'); $this->sendRequest('GETSCRIPT "'.$sScriptName.'"');
$mResponse = $this->parseResponse(); $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\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @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->sendRequest('PUTSCRIPT "'.$sScriptName.'" {'.\strlen($sScriptSource).'+}');
$this->sendRequestWithCheck($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\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
public function CheckScript($sScriptSource) public function CheckScript(string $sScriptSource) : self
{ {
$this->sendRequest('CHECKSCRIPT {'.\strlen($sScriptSource).'+}'); $this->sendRequest('CHECKSCRIPT {'.\strlen($sScriptSource).'+}');
$this->sendRequestWithCheck($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\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
public function SetActiveScript($sScriptName) public function SetActiveScript(string $sScriptName) : self
{ {
$this->sendRequestWithCheck('SETACTIVE "'.$sScriptName.'"'); $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\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
public function DeleteScript($sScriptName) public function DeleteScript(string $sScriptName) : self
{ {
$this->sendRequestWithCheck('DELETESCRIPT "'.$sScriptName.'"'); $this->sendRequestWithCheck('DELETESCRIPT "'.$sScriptName.'"');
@ -401,12 +336,10 @@ class ManageSieveClient extends \MailSo\Net\NetClient
} }
/** /**
* @return string
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
public function GetActiveScriptName() public function GetActiveScriptName() : string
{ {
$aList = $this->ListScripts(); $aList = $this->ListScripts();
if (\is_array($aList) && 0 < \count($aList)) 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\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
public function IsActiveScript($sScriptName) public function IsActiveScript(string $sScriptName) : bool
{ {
return $sScriptName === $this->GetActiveScriptName(); return $sScriptName === $this->GetActiveScriptName();
} }
/** private function parseLine(string $sLine) : array
* @param string $sLine
* @return array|false
*/
private function parseLine($sLine)
{ {
if (false === $sLine || null === $sLine || \in_array(\substr($sLine, 0, 2), array('OK', 'NO'))) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
*/ */
private function sendRequest($sRequest) : void private function sendRequest(string $sRequest) : void
{ {
if (!\MailSo\Base\Validator::NotEmptyString($sRequest, true)) 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\Net\Exceptions\Exception
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
private function sendRequestWithCheck($sRequest) : void private function sendRequestWithCheck(string $sRequest) : void
{ {
$this->sendRequest($sRequest); $this->sendRequest($sRequest);
$this->validateResponse($this->parseResponse()); $this->validateResponse($this->parseResponse());
} }
/** private function convertEndOfLine(string $sLine) : string
* @param string $sLine
*
* @return string
*/
private function convertEndOfLine($sLine)
{ {
$sLine = \trim($sLine); $sLine = \trim($sLine);
if ('}' === \substr($sLine, -1)) if ('}' === \substr($sLine, -1))
@ -570,10 +483,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
return $sLine; return $sLine;
} }
/** private function parseResponse() : array
* @return array|bool
*/
private function parseResponse()
{ {
$this->iRequestTime = \microtime(true); $this->iRequestTime = \microtime(true);
@ -608,7 +518,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
/** /**
* @throws \MailSo\Sieve\Exceptions\NegativeResponseException * @throws \MailSo\Sieve\Exceptions\NegativeResponseException
*/ */
private function validateResponse($aResponse) private function validateResponse(array $aResponse)
{ {
if (!\is_array($aResponse) || 0 === \count($aResponse) || if (!\is_array($aResponse) || 0 === \count($aResponse) ||
'OK' !== \substr($aResponse[\count($aResponse) - 1], 0, 2)) 'OK' !== \substr($aResponse[\count($aResponse) - 1], 0, 2))
@ -619,10 +529,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
} }
} }
/** protected function getLogName() : string
* @return string
*/
protected function getLogName()
{ {
return 'SIEVE'; return 'SIEVE';
} }

View file

@ -24,9 +24,6 @@ class ResponseException extends \MailSo\Smtp\Exceptions\Exception
private $aResponses; private $aResponses;
/** /**
* @param array $aResponses = array
* @param string $sMessage = ''
* @param int $iCode = 0
* @param \Exception $oPrevious = null * @param \Exception $oPrevious = null
*/ */
public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null) public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null)
@ -39,18 +36,12 @@ class ResponseException extends \MailSo\Smtp\Exceptions\Exception
} }
} }
/** public function GetResponses() : array
* @return array
*/
public function GetResponses()
{ {
return $this->aResponses; return $this->aResponses;
} }
/** public function GetLastResponse() : ?\MailSo\Smtp\Response
* @return \MailSo\Smtp\Response | null
*/
public function GetLastResponse()
{ {
return 0 < count($this->aResponses) ? $this->aResponses[count($this->aResponses) - 1] : null; 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; public $__USE_SINGLE_LINE_AUTH_PLAIN_COMMAND = false;
/**
* @access protected
*/
protected function __construct() protected function __construct()
{ {
parent::__construct(); parent::__construct();
@ -87,42 +84,27 @@ class SmtpClient extends \MailSo\Net\NetClient
$this->bData = false; $this->bData = false;
} }
/** public static function NewInstance() : self
* @return \MailSo\Smtp\SmtpClient
*/
public static function NewInstance()
{ {
return new self(); return new self();
} }
/** public function IsSupported(string $sCapa) : bool
* @return bool
*/
public function IsSupported($sCapa)
{ {
return in_array(strtoupper($sCapa), $this->aCapa); return in_array(strtoupper($sCapa), $this->aCapa);
} }
/** public function IsAuthSupported(string $sAuth) : bool
* @return bool
*/
public function IsAuthSupported($sAuth)
{ {
return in_array(strtoupper($sAuth), $this->aAuthTypes); return in_array(strtoupper($sAuth), $this->aAuthTypes);
} }
/** public function HasSupportedAuth() : bool
* @return bool
*/
public function HasSupportedAuth()
{ {
return $this->IsAuthSupported('PLAIN') || $this->IsAuthSupported('LOGIN'); return $this->IsAuthSupported('PLAIN') || $this->IsAuthSupported('LOGIN');
} }
/** public static function EhloHelper() : string
* @return string
*/
public static function EhloHelper()
{ {
$sEhloHost = empty($_SERVER['SERVER_NAME']) ? '' : \trim($_SERVER['SERVER_NAME']); $sEhloHost = empty($_SERVER['SERVER_NAME']) ? '' : \trim($_SERVER['SERVER_NAME']);
if (empty($sEhloHost)) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\ResponseException * @throws \MailSo\Smtp\Exceptions\ResponseException
*/ */
public function Connect($sServerName, $iPort = 25, $sEhloHost = '[127.0.0.1]', public function Connect(string $sServerName, int $iPort = 25,
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT,
$bVerifySsl = false, $bAllowSelfSigned = true) : void bool $bVerifySsl = false, bool $bAllowSelfSigned = true,
string $sClientCert = '', string $sEhloHost = '[127.0.0.1]') : void
{ {
$this->iRequestTime = microtime(true); $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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\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)); $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\Net\Exceptions\Exception
* @throws \MailSo\Smtp\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( $sFrom = \MailSo\Base\Utils::IdnToAscii(
\MailSo\Base\Utils::Trim($sFrom), true); \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\Net\Exceptions\Exception
* @throws \MailSo\Smtp\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) 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\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception * @throws \MailSo\Smtp\Exceptions\Exception
*/ */
public function MailTo($sTo) public function MailTo(string $sTo) : self
{ {
return $this->Rcpt($sTo); return $this->Rcpt($sTo);
} }
/** /**
* @param string $sData
*
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception * @throws \MailSo\Smtp\Exceptions\Exception
*/ */
public function Data($sData) public function Data(string $sData) : self
{ {
if (!\MailSo\Base\Validator::NotEmptyString($sData, true)) if (!\MailSo\Base\Validator::NotEmptyString($sData, true))
{ {
@ -423,13 +373,11 @@ class SmtpClient extends \MailSo\Net\NetClient
/** /**
* @param resource $rDataStream * @param resource $rDataStream
* *
* @return \MailSo\Smtp\SmtpClient
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception * @throws \MailSo\Smtp\Exceptions\Exception
*/ */
public function DataWithStream($rDataStream) public function DataWithStream($rDataStream) : self
{ {
if (!\is_resource($rDataStream)) 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\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception * @throws \MailSo\Smtp\Exceptions\Exception
*/ */
public function Rset() public function Rset() : self
{ {
$this->sendRequestWithCheck('RSET', array(250, 220)); $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\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception * @throws \MailSo\Smtp\Exceptions\Exception
*/ */
public function Vrfy($sUser) public function Vrfy(string $sUser) : self
{ {
$sUser = \MailSo\Base\Utils::IdnToAscii( $sUser = \MailSo\Base\Utils::IdnToAscii(
\MailSo\Base\Utils::Trim($sUser)); \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\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception * @throws \MailSo\Smtp\Exceptions\Exception
*/ */
public function Noop() public function Noop() : self
{ {
$this->sendRequestWithCheck('NOOP', 250); $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\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception * @throws \MailSo\Smtp\Exceptions\Exception
*/ */
public function Logout() public function Logout() : self
{ {
if ($this->IsConnected()) if ($this->IsConnected())
{ {
@ -550,10 +490,7 @@ class SmtpClient extends \MailSo\Net\NetClient
return $this; return $this;
} }
/** private function preLoginStartTLSAndEhloProcess(string $sEhloHost) : void
* @param string $sEhloHost
*/
private function preLoginStartTLSAndEhloProcess($sEhloHost) : void
{ {
if ($this->bHelo) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @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)) 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\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\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->sendRequest($sCommand, $sAddToCommand, $bSecureLog);
$this->validateResponse($mExpectCode, $sErrorPrefix); $this->validateResponse($mExpectCode, $sErrorPrefix);
} }
/** private function ehloOrHelo(string $sHost) : void
* @param string $sHost
*/
private function ehloOrHelo($sHost) : void
{ {
try try
{ {
$this->ehlo($sHost); $this->ehlo($sHost);
} }
catch (\Exception $oException) catch (\Throwable $oException)
{ {
try try
{ {
$this->helo($sHost); $this->helo($sHost);
} }
catch (\Exception $oException) catch (\Throwable $oException)
{ {
throw $oException; throw $oException;
} }
@ -650,8 +574,6 @@ class SmtpClient extends \MailSo\Net\NetClient
} }
/** /**
* @param string $sHost
*
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Smtp\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\Net\Exceptions\Exception
* @throws \MailSo\Smtp\Exceptions\Exception * @throws \MailSo\Smtp\Exceptions\Exception
*/ */
private function helo($sHost) : void private function helo(string $sHost) : void
{ {
$this->sendRequestWithCheck('HELO', 250, $sHost); $this->sendRequestWithCheck('HELO', 250, $sHost);
$this->aAuthTypes = array(); $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 * @throws \MailSo\Smtp\Exceptions\ResponseException
*/ */
private function validateResponse($mExpectCode, $sErrorPrefix = '') : void private function validateResponse($mExpectCode, string $sErrorPrefix = '') : void
{ {
if (!\is_array($mExpectCode)) if (!\is_array($mExpectCode))
{ {
@ -757,10 +674,7 @@ class SmtpClient extends \MailSo\Net\NetClient
\MailSo\Log\Enumerations\Type::TIME); \MailSo\Log\Enumerations\Type::TIME);
} }
/** protected function getLogName() : string
* @return string
*/
protected function getLogName()
{ {
return 'SMTP'; return 'SMTP';
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -72,12 +72,7 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider
$iOffset, $iLimit, $sSearch, $iResultCount) : array(); $iOffset, $iLimit, $sSearch, $iResultCount) : array();
} }
/** public function GetContactByID(string $sEmail, $mID, bool $bIsStrID = false) : ?\RainLoop\Providers\AddressBook\Classes\Contact
* @param string $mID
*
* @return \RainLoop\Providers\AddressBook\Classes\Contact|null
*/
public function GetContactByID(string $sEmail, $mID, bool $bIsStrID = false)
{ {
return $this->IsActive() ? $this->oDriver->GetContactByID($sEmail, $mID, $bIsStrID) : null; 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 '. return !!$this->prepareAndExecute('UPDATE rainloop_ab_contacts SET changed = :changed, etag = :etag '.
'WHERE id_user = :id_user AND id_contact = :id_contact', array( 'WHERE id_user = :id_user AND id_contact = :id_contact', array(
':id_user' => array($iUserID, \PDO::PARAM_INT), ':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), ':changed' => array($iChanged, \PDO::PARAM_INT),
':etag' => array($sEtag, \PDO::PARAM_STR) ':etag' => array($sEtag, \PDO::PARAM_STR)
) )
@ -239,7 +239,7 @@ class PdoAddressBook
return $aResponse; 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(); $aContactsPaths = array();
@ -425,7 +425,7 @@ class PdoAddressBook
return $aContactsPaths; return $aContactsPaths;
} }
private function checkContactsPath(\SabreForRainLoop\DAV\Client &$oClient, string $sPath) : bool private function checkContactsPath(\SabreForRainLoop\DAV\Client $oClient, string $sPath) : bool
{ {
if (!$oClient) if (!$oClient)
{ {
@ -475,7 +475,7 @@ class PdoAddressBook
return $bGood; 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)) if (!\preg_match('/^http[s]?:\/\//i', $sUrl))
{ {
@ -527,11 +527,11 @@ class PdoAddressBook
return $oClient; 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')) if (!\class_exists('SabreForRainLoop\DAV\Client'))
{ {
return false; return null;
} }
$aMatch = array(); $aMatch = array();
@ -548,7 +548,7 @@ class PdoAddressBook
$oClient = $this->getDavClientFromUrl($sUrl, $sUser, $sPassword, $sProxy); $oClient = $this->getDavClientFromUrl($sUrl, $sUser, $sPassword, $sProxy);
if (!$oClient) if (!$oClient)
{ {
return false; return null;
} }
$bGood = false; $bGood = false;
@ -1168,10 +1168,8 @@ class PdoAddressBook
/** /**
* @param mixed $mID * @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); $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 $this->bAdmin;
} }
/** public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true) : ?\RainLoop\Model\Domain
* @return \RainLoop\Model\Domain|null
*/
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true)
{ {
$oDomain = $this->oDriver->Load($sName, $bFindWithWildCard, $bCheckDisabled, $bCheckAliases); $oDomain = $this->oDriver->Load($sName, $bFindWithWildCard, $bCheckDisabled, $bCheckAliases);
if ($oDomain instanceof \RainLoop\Model\Domain) if ($oDomain instanceof \RainLoop\Model\Domain)
@ -93,10 +90,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
return $this->oDriver->Count($sSearch); return $this->oDriver->Count($sSearch);
} }
/** public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '') : ?\RainLoop\Model\Domain
* @return \RainLoop\Model\Domain | null
*/
public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '')
{ {
$oDomain = null; $oDomain = null;
@ -163,10 +157,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
return $oDomain; return $oDomain;
} }
/** public function CreateNewAliasFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '') : ?\RainLoop\Model\Domain
* @return \RainLoop\Model\Domain | null
*/
public function CreateNewAliasFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '')
{ {
$oDomain = null; $oDomain = null;

View file

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

View file

@ -7,10 +7,7 @@ interface DomainAdminInterface extends DomainInterface
public function Disable(string $sName, bool $bDisable) : bool; public function Disable(string $sName, bool $bDisable) : bool;
/** public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true) : ?\RainLoop\Model\Domain;
* @return \RainLoop\Model\Domain|null
*/
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true);
public function Save(\RainLoop\Model\Domain $oDomain) : bool; 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 $this->oDriver->GetFile($oAccount, $sKey, $sOpenMode);
} }
/** public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey) : string
* @return string | bool
*/
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey)
{ {
return $this->oDriver->GetFileName($oAccount, $sKey); return $this->oDriver->GetFileName($oAccount, $sKey);
} }
@ -45,10 +42,7 @@ class Files extends \RainLoop\Providers\AbstractProvider
return $this->oDriver->Clear($oAccount, $sKey); return $this->oDriver->Clear($oAccount, $sKey);
} }
/** public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey) : int
* @return int|bool
*/
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey)
{ {
return $this->oDriver->FileSize($oAccount, $sKey); return $this->oDriver->FileSize($oAccount, $sKey);
} }

View file

@ -68,10 +68,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
return $mResult; return $mResult;
} }
/** public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey) : string
* @return string|bool
*/
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey)
{ {
$mResult = false; $mResult = false;
$sFileName = $this->generateFullFileName($oAccount, $sKey); $sFileName = $this->generateFullFileName($oAccount, $sKey);
@ -100,10 +97,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
return $mResult; return $mResult;
} }
/** public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey) : int
* @return int|bool
*/
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey)
{ {
$mResult = false; $mResult = false;
$sFileName = $this->generateFullFileName($oAccount, $sKey); $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(); $aResult = array();
if (\is_array($aCollection) && 0 < \count($aCollection)) if (\is_array($aCollection) && 0 < \count($aCollection))

View file

@ -9,30 +9,18 @@ class Settings extends \RainLoop\Providers\AbstractProvider
*/ */
private $oDriver; private $oDriver;
/**
* @param \RainLoop\Providers\Settings\ISettings $oDriver
*/
public function __construct(\RainLoop\Providers\Settings\ISettings $oDriver) public function __construct(\RainLoop\Providers\Settings\ISettings $oDriver)
{ {
$this->oDriver = $oDriver; $this->oDriver = $oDriver;
} }
/** public function Load(\RainLoop\Model\Account $oAccount) : \RainLoop\Settings
* @param \RainLoop\Model\Account $oAccount
*
* @return \RainLoop\Settings
*/
public function Load(\RainLoop\Model\Account $oAccount)
{ {
$oSettings = new \RainLoop\Settings(); $oSettings = new \RainLoop\Settings();
$oSettings->InitData($this->oDriver->Load($oAccount)); $oSettings->InitData($this->oDriver->Load($oAccount));
return $oSettings; return $oSettings;
} }
/**
* @param \RainLoop\Model\Account $oAccount
* @param \RainLoop\Settings $oSettings
*/
public function Save(\RainLoop\Model\Account $oAccount, \RainLoop\Settings $oSettings) : bool public function Save(\RainLoop\Model\Account $oAccount, \RainLoop\Settings $oSettings) : bool
{ {
return $this->oDriver->Save($oAccount, $oSettings->DataAsArray()); 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 \RainLoop\Model\Account|string|null $oAccount
* @param mixed $sValue * @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)) 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 \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( return false !== @\file_put_contents(
$this->generateFileName($oAccount, $iStorageType, $sKey, true), $sValue); $this->generateFileName($oAccount, $iStorageType, $sKey, true), $sValue);
@ -166,9 +165,6 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
return $sFilePath; return $sFilePath;
} }
/**
* @param \MailSo\Log\Logger $oLogger
*/
public function SetLogger(?\MailSo\Log\Logger $oLogger) public function SetLogger(?\MailSo\Log\Logger $oLogger)
{ {
$this->oLogger = $oLogger; $this->oLogger = $oLogger;

View file

@ -6,9 +6,8 @@ interface IStorage
{ {
/** /**
* @param \RainLoop\Model\Account|null $oAccount * @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 * @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 \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); return !!@\apc_store($this->generateFileName($oAccount, $iStorageType, $sKey, true), $sValue);
} }

View file

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

View file

@ -4,11 +4,6 @@ namespace RainLoop\Providers\Suggestions;
class TestSuggestions implements \RainLoop\Providers\Suggestions\ISuggestions 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 public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20) : array
{ {
return array( return array(

View file

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

View file

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

View file

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

View file

@ -51,7 +51,7 @@ class VCalendar extends VObject\Document {
'DATE' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Date', 'DATE' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Date',
'DATE-TIME' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\DateTime', 'DATE-TIME' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\DateTime',
'DURATION' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Duration', 'DURATION' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Duration',
'FLOAT' => 'SabreForRainLoop\\VObject\\Property\\Number', 'FLOAT' => 'SabreForRainLoop\\VObject\\Property\\FloatValue',
'INTEGER' => 'SabreForRainLoop\\VObject\\Property\\Integer', 'INTEGER' => 'SabreForRainLoop\\VObject\\Property\\Integer',
'PERIOD' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Period', 'PERIOD' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Period',
'RECUR' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Recur', 'RECUR' => 'SabreForRainLoop\\VObject\\Property\\ICalendar\\Recur',
@ -80,7 +80,7 @@ class VCalendar extends VObject\Document {
'CLASS' => 'SabreForRainLoop\\VObject\\Property\\FlatText', 'CLASS' => 'SabreForRainLoop\\VObject\\Property\\FlatText',
'COMMENT' => 'SabreForRainLoop\\VObject\\Property\\FlatText', 'COMMENT' => 'SabreForRainLoop\\VObject\\Property\\FlatText',
'DESCRIPTION' => 'SabreForRainLoop\\VObject\\Property\\FlatText', 'DESCRIPTION' => 'SabreForRainLoop\\VObject\\Property\\FlatText',
'GEO' => 'SabreForRainLoop\\VObject\\Property\\Number', 'GEO' => 'SabreForRainLoop\\VObject\\Property\\FloatValue',
'LOCATION' => 'SabreForRainLoop\\VObject\\Property\\FlatText', 'LOCATION' => 'SabreForRainLoop\\VObject\\Property\\FlatText',
'PERCENT-COMPLETE' => 'SabreForRainLoop\\VObject\\Property\\Integer', 'PERCENT-COMPLETE' => 'SabreForRainLoop\\VObject\\Property\\Integer',
'PRIORITY' => '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' => 'SabreForRainLoop\\VObject\\Property\\VCard\\Date',
'DATE-TIME' => 'SabreForRainLoop\\VObject\\Property\\VCard\\DateTime', 'DATE-TIME' => 'SabreForRainLoop\\VObject\\Property\\VCard\\DateTime',
'DATE-AND-OR-TIME' => 'SabreForRainLoop\\VObject\\Property\\VCard\\DateAndOrTime', // vCard only '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', 'INTEGER' => 'SabreForRainLoop\\VObject\\Property\\Integer',
'LANGUAGE-TAG' => 'SabreForRainLoop\\VObject\\Property\\VCard\\LanguageTag', 'LANGUAGE-TAG' => 'SabreForRainLoop\\VObject\\Property\\VCard\\LanguageTag',
'TIMESTAMP' => 'SabreForRainLoop\\VObject\\Property\\VCard\\TimeStamp', 'TIMESTAMP' => 'SabreForRainLoop\\VObject\\Property\\VCard\\TimeStamp',

View file

@ -6,7 +6,7 @@ use
SabreForRainLoop\VObject\Property; SabreForRainLoop\VObject\Property;
/** /**
* Number property * Float property
* *
* This object represents FLOAT values. These can be 1 or more floating-point * This object represents FLOAT values. These can be 1 or more floating-point
* numbers. * numbers.
@ -15,7 +15,7 @@ use
* @author Evert Pot (http://evertpot.com/) * @author Evert Pot (http://evertpot.com/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License * @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 * 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_VERSION'))
{ {
if (!defined('APP_START_TIME')) if (!defined('APP_REQUEST_RND'))
{ {
@ini_set('register_globals', 0); @ini_set('register_globals', 0);
@ini_set('zend.ze1_compatibility_mode', 0); @ini_set('zend.ze1_compatibility_mode', 0);
@ini_set('magic_quotes_gpc', 0); @ini_set('magic_quotes_gpc', 0);
@ini_set('magic_quotes_runtime', 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_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.'/'); define('APP_VERSION_ROOT_PATH', APP_INDEX_ROOT_PATH.'rainloop/v/'.APP_VERSION.'/');