Changed: MailSo\*Collection now extends \ArrayObject

Changed: fixed __constructor param type hinting
Replace: &$o with $o as objects don't need & referencing
This commit is contained in:
djmaze 2020-03-18 23:14:00 +01:00
parent 9bb44e7f98
commit f6fdb69c65
30 changed files with 290 additions and 736 deletions

View file

@ -15,48 +15,33 @@ namespace MailSo\Base;
* @category MailSo * @category MailSo
* @package Base * @package Base
*/ */
abstract class Collection abstract class Collection extends \ArrayObject /*implements \ArrayAccess, \Traversable, \Countable, \Ds\Collection */
{ {
/**
* @var array
*/
protected $aItems;
protected function __construct()
{
$this->aItems = array();
}
/** /**
* @param mixed $mItem * @param mixed $mItem
*/ */
public function append($mItem, bool $bToTop = false) : void
{
if ($bToTop) {
$array = $this->getArrayCopy();
array_unshift($array, $mItem);
$this->exchangeArray($array);
} else {
parent::append($mItem);
}
}
public function Add($mItem, bool $bToTop = false) : self public function Add($mItem, bool $bToTop = false) : self
{ {
if ($bToTop) $this->append($mItem, $bToTop);
{
\array_unshift($this->aItems, $mItem);
}
else
{
\array_push($this->aItems, $mItem);
}
return $this; return $this;
} }
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function AddArray(array $aItems) : self public function AddArray(array $aItems) : self
{ {
if (!\is_array($aItems))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
foreach ($aItems as $mItem) foreach ($aItems as $mItem)
{ {
$this->Add($mItem); $this->append($mItem);
} }
return $this; return $this;
@ -64,52 +49,38 @@ abstract class Collection
public function Clear() : void public function Clear() : void
{ {
$this->aItems = array(); $this->exchangeArray([]);
} }
public function CloneAsArray() : array public function Slice(int $offset, int $length = null, bool $preserve_keys = false)
{ {
return $this->aItems; return new static(
array_slice($this->getArrayCopy(), $offset, $length, $preserve_keys)
);
} }
public function Count() : int public function MapList(callable $cCallback) : array
{
return \count($this->aItems);
}
public function &GetAsArray() : array
{
return $this->aItems;
}
/**
* @param mixed $mCallback
*/
public function MapList($mCallback)
{ {
$aResult = array(); $aResult = array();
if (\is_callable($mCallback)) if (\is_callable($cCallback))
{ {
foreach ($this->aItems as $oItem) foreach ($this as $oItem)
{ {
$aResult[] = \call_user_func($mCallback, $oItem); $aResult[] = \call_user_func($cCallback, $oItem);
} }
} }
return $aResult; return $aResult;
} }
/** public function FilterList(callable $cCallback) : array
* @param mixed $mCallback
*/
public function FilterList($mCallback) : array
{ {
$aResult = array(); $aResult = array();
if (\is_callable($mCallback)) if (\is_callable($cCallback))
{ {
foreach ($this->aItems as $oItem) foreach ($this as $oItem)
{ {
if (\call_user_func($mCallback, $oItem)) if (\call_user_func($cCallback, $oItem))
{ {
$aResult[] = $oItem; $aResult[] = $oItem;
} }
@ -119,45 +90,14 @@ abstract class Collection
return $aResult; return $aResult;
} }
/** public function ForeachList(callable $cCallback) : void
* @param mixed $mCallback
*/
public function ForeachList($mCallback) : void
{ {
if (\is_callable($mCallback)) if (\is_callable($cCallback))
{ {
foreach ($this->aItems as $oItem) foreach ($this as $oItem)
{ {
\call_user_func($mCallback, $oItem); \call_user_func($cCallback, $oItem);
} }
} }
} }
/**
* @return mixed | null
* @return mixed
*/
public function &GetByIndex(int $iIndex)
{
$mResult = null;
if (\key_exists($iIndex, $this->aItems))
{
$mResult = $this->aItems[$iIndex];
}
return $mResult;
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function SetAsArray(array $aItems)
{
if (!\is_array($aItems))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
$this->aItems = $aItems;
}
} }

View file

@ -50,9 +50,9 @@ abstract class HtmlUtils
$sHtmlAttrs = $sBodyAttrs = ''; $sHtmlAttrs = $sBodyAttrs = '';
$sText = \MailSo\Base\HtmlUtils::FixSchemas($sText); $sText = static::FixSchemas($sText);
$sText = \MailSo\Base\HtmlUtils::ClearFastTags($sText); $sText = static::ClearFastTags($sText);
$sText = \MailSo\Base\HtmlUtils::ClearBodyAndHtmlTag($sText, $sHtmlAttrs, $sBodyAttrs); $sText = static::ClearBodyAndHtmlTag($sText, $sHtmlAttrs, $sBodyAttrs);
$oDom = self::createDOMDocument(); $oDom = self::createDOMDocument();
@$oDom->loadHTML('<'.'?xml version="1.0" encoding="utf-8"?'.'>'. @$oDom->loadHTML('<'.'?xml version="1.0" encoding="utf-8"?'.'>'.
@ -117,60 +117,7 @@ abstract class HtmlUtils
return \trim($sResult); return \trim($sResult);
} }
public static function GetTextFromDom_(\DOMDocument $oDom, bool $bWrapByFakeHtmlAndBodyDiv = true) : string public static function GetTextFromDom(\DOMDocument $oDom, bool $bWrapByFakeHtmlAndBodyDiv = true) : string
{
$sResult = '';
$aHtmlAttrs = $aBodylAttrs = array();
if ($bWrapByFakeHtmlAndBodyDiv)
{
$oHtml = $oDom->getElementsByTagName('html')->item(0);
$oBody = $oDom->getElementsByTagName('body')->item(0);
$aHtmlAttrs = \MailSo\Base\HtmlUtils::GetElementAttributesAsArray($oHtml);
$aBodylAttrs = \MailSo\Base\HtmlUtils::GetElementAttributesAsArray($oBody);
}
$oDiv = $oDom->getElementsByTagName('div')->item(0);
if ($oDiv && $oDiv->hasAttribute('data-wrp') && 'rainloop' === $oDiv->getAttribute('data-wrp'))
{
$oDiv->removeAttribute('data-wrp');
if ($bWrapByFakeHtmlAndBodyDiv)
{
$oWrap = $oDom->createElement('div');
$oWrap->setAttribute('data-x-div-type', 'html');
foreach ($aHtmlAttrs as $sKey => $sValue)
{
$oWrap->setAttribute($sKey, $sValue);
}
$oDiv->setAttribute('data-x-div-type', 'body');
foreach ($aBodylAttrs as $sKey => $sValue)
{
$oDiv->setAttribute($sKey, $sValue);
}
$oWrap->appendChild($oDiv);
$sResult = self::domToString($oWrap, $oDom);
}
else
{
$sResult = self::domToString($oDiv, $oDom);
}
}
else
{
$sResult = self::domToString($oDom);
}
$sResult = \str_replace(\MailSo\Base\HtmlUtils::$KOS, ':', $sResult);
$sResult = \MailSo\Base\Utils::StripSpaces($sResult);
return $sResult;
}
public static function GetTextFromDom(\DOMDocument $oDom, bool $bWrapByFakeHtmlAndBodyDiv = true)
{ {
$sResult = ''; $sResult = '';
@ -184,8 +131,8 @@ abstract class HtmlUtils
if ($bWrapByFakeHtmlAndBodyDiv) if ($bWrapByFakeHtmlAndBodyDiv)
{ {
$aHtmlAttrs = \MailSo\Base\HtmlUtils::GetElementAttributesAsArray($oHtml); $aHtmlAttrs = static::GetElementAttributesAsArray($oHtml);
$aBodylAttrs = \MailSo\Base\HtmlUtils::GetElementAttributesAsArray($oBody); $aBodylAttrs = static::GetElementAttributesAsArray($oBody);
$oWrapHtml = $oDom->createElement('div'); $oWrapHtml = $oDom->createElement('div');
$oWrapHtml->setAttribute('data-x-div-type', 'html'); $oWrapHtml->setAttribute('data-x-div-type', 'html');
@ -208,7 +155,7 @@ abstract class HtmlUtils
$sResult = \str_replace('___xxx___', $sResult, $sWrp); $sResult = \str_replace('___xxx___', $sResult, $sWrp);
} }
$sResult = \str_replace(\MailSo\Base\HtmlUtils::$KOS, ':', $sResult); $sResult = \str_replace(static::$KOS, ':', $sResult);
$sResult = \MailSo\Base\Utils::StripSpaces($sResult); $sResult = \MailSo\Base\Utils::StripSpaces($sResult);
return $sResult; return $sResult;
@ -269,10 +216,7 @@ abstract class HtmlUtils
), '', $sHtml); ), '', $sHtml);
} }
/** public static function ClearComments(\DOMDocument $oDom) : void
* @param mixed $oDom
*/
public static function ClearComments(&$oDom)
{ {
$aRemove = array(); $aRemove = array();
@ -297,10 +241,7 @@ abstract class HtmlUtils
} }
} }
/** public static function ClearTags(\DOMDocument $oDom, bool $bClearStyleAndHead = true) : void
* @param mixed $oDom
*/
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',
@ -343,229 +284,6 @@ abstract class HtmlUtils
} }
} }
/*
// public static function ClearStyleUrlValueParserHelper($oUrlValue, $oRule, $oRuleSet,
// $oElem = null,
// &$bHasExternals = false, array &$aFoundCIDs = array(),
// $aContentLocationUrls = array(), array &$aFoundedContentLocationUrls = array(),
// $bDoNotReplaceExternalUrl = false, $fAdditionalExternalFilter = null
// )
// {
// if ($oUrlValue instanceof \Sabberworm\CSS\Value\URL)
// {
// $oNewRule = new \Sabberworm\CSS\Rule\Rule('x-rl-orig-'.$oRule->getRule());
// $oNewRule->setValue((string) $oRule->getValue());
// $oNewRule->setIsImportant($oRule->getIsImportant());
//
// $oRuleSet->addRule($oNewRule);
//
// $oUrl = $oUrlValue->getURL();
// $sUrl = $oUrl ? $oUrl->getString() : '';
//
// if ('cid:' === \strtolower(\substr($sUrl, 0, 4)))
// {
// $aFoundCIDs[] = \substr($sUrl, 4);
//
// $oRule->setRule('x-rl-mod-'.$oRule->getRule());
//
// if ($oElem)
// {
// $oElem->setAttribute('data-x-style-mod', '1');
// }
// }
// else
// {
// if (\preg_match('/http[s]?:\/\//i', $sUrl) || '//' === \substr($sUrl, 0, 2))
// {
// $oRule->setRule('x-rl-mod-'.$oRule->getRule());
//
// if (\in_array($sUrl, $aContentLocationUrls))
// {
// $aFoundedContentLocationUrls[] = $sUrl;
// }
// else
// {
// $bHasExternals = true;
// if (!$bDoNotReplaceExternalUrl)
// {
// if ($fAdditionalExternalFilter)
// {
// $sAdditionalResult = \call_user_func($fAdditionalExternalFilter, $sUrl);
// if (0 < \strlen($sAdditionalResult) && $oUrl)
// {
// $oUrl->setString($sAdditionalResult);
// }
// }
// }
// }
//
// if ($oElem)
// {
// $oElem->setAttribute('data-x-style-mod', '1');
// }
// }
// else if ('data:image/' !== \strtolower(\substr(\trim($sUrl), 0, 11)))
// {
// $oRuleSet->removeRule($oRule);
// }
// }
// }
// else if ($oRule instanceof \Sabberworm\CSS\Rule\Rule)
// {
// if ('x-rl-' !== \substr($oRule->getRule(), 0, 5))
// {
// $oValue = $oRule->getValue();
// if ($oValue instanceof \Sabberworm\CSS\Value\URL)
// {
// \MailSo\Base\HtmlUtils::ClearStyleUrlValueParserHelper($oValue, $oRule, $oRuleSet, $oElem,
// $bHasExternals, $aFoundCIDs,
// $aContentLocationUrls, $aFoundedContentLocationUrls,
// $bDoNotReplaceExternalUrl, $fAdditionalExternalFilter);
// }
// else if ($oValue instanceof \Sabberworm\CSS\Value\RuleValueList)
// {
// $aComps = $oValue->getListComponents();
// foreach ($aComps as $oValue)
// {
// if ($oValue instanceof \Sabberworm\CSS\Value\URL)
// {
// \MailSo\Base\HtmlUtils::ClearStyleUrlValueParserHelper($oValue, $oRule, $oRuleSet, $oElem,
// $bHasExternals, $aFoundCIDs,
// $aContentLocationUrls, $aFoundedContentLocationUrls,
// $bDoNotReplaceExternalUrl, $fAdditionalExternalFilter);
// }
// }
// }
// }
// }
// }
//
// public static function ClearStyleSmart(string $sStyle, $oElement = null,
// &$bHasExternals = false, array &$aFoundCIDs = array(),
// $aContentLocationUrls = array(), array &$aFoundedContentLocationUrls = array(),
// $bDoNotReplaceExternalUrl = false, $fAdditionalExternalFilter = null,
// $sSelectorPrefix = '')
// {
// $mResult = false;
// $oCss = null;
//
// if (!\class_exists('Sabberworm\CSS\Parser'))
// {
// return $mResult;
// }
//
// $sStyle = \trim($sStyle);
// if (empty($sStyle))
// {
// return '';
// }
//
// $sStyle = \trim(\preg_replace('/[\r\n\t\s]+/', ' ', $sStyle));
//
// try
// {
// $oSettings = \Sabberworm\CSS\Settings::create();
// $oSettings->beStrict();
// $oSettings->withMultibyteSupport(false);
//
// $oCssParser = new \Sabberworm\CSS\Parser($sStyle, $oSettings);
// $oCss = $oCssParser->parse();
// }
// catch (\Throwable $oEception)
// {
// unset($oEception);
// $mResult = false;
// }
//
// if ($oCss)
// {
// foreach ($oCss->getAllDeclarationBlocks() as $oBlock)
// {
// foreach($oBlock->getSelectors() as $oSelector)
// {
// $sS = ' '.\trim($oSelector->getSelector()).' ';
// $sS = \preg_replace('/ body([\.# ])/i', ' [data-x-div-type="body"]$1', $sS);
// $sS = \preg_replace('/ html([\.# ])/i', ' [data-x-div-type="html"]$1', $sS);
//
// if (0 < \strlen($sSelectorPrefix))
// {
// $sS = \trim($sSelectorPrefix.' '.\trim($sS));
// }
//
// $oSelector->setSelector(\trim($sS));
// }
// }
//
// $aRulesToRemove = array(
// 'pointer-events', 'content', 'behavior', 'cursor',
// );
//
// foreach($oCss->getAllRuleSets() as $oRuleSet)
// {
// foreach ($aRulesToRemove as $sRuleToRemove)
// {
// $oRuleSet->removeRule($sRuleToRemove);
// }
//
// // position: fixed -> position: fixed -> absolute
// $aRules = $oRuleSet->getRules('position');
// if (\is_array($aRules))
// {
// foreach ($aRules as $oRule)
// {
// $mValue = $oRule->getValue();
// if (\is_string($mValue) && 'fixed' === \trim(\strtolower($mValue)))
// {
// $oRule->setValue('absolute');
// }
// }
// }
// }
//
// foreach($oCss->getAllDeclarationBlocks() as $oRuleSet)
// {
// if ($oRuleSet instanceof \Sabberworm\CSS\RuleSet\RuleSet)
// {
// if ($oRuleSet instanceof \Sabberworm\CSS\RuleSet\DeclarationBlock)
// {
// $oRuleSet->expandBackgroundShorthand();
// $oRuleSet->expandListStyleShorthand();
// }
//
// $aRules = $oRuleSet->getRules();
// if (\is_array($aRules) && 0 < \count($aRules))
// {
// foreach ($aRules as $oRule)
// {
// if ($oRule instanceof \Sabberworm\CSS\Rule\Rule)
// {
// \MailSo\Base\HtmlUtils::ClearStyleUrlValueParserHelper(null, $oRule, $oRuleSet,
// $oElement,
// $bHasExternals, $aFoundCIDs,
// $aContentLocationUrls, $aFoundedContentLocationUrls,
// $bDoNotReplaceExternalUrl, $fAdditionalExternalFilter
// );
// }
// }
// }
// }
// }
//
// try
// {
// $mResult = $oCss->render(\Sabberworm\CSS\OutputFormat::createCompact());
// }
// catch (\Throwable $oEception)
// {
// unset($oEception);
// $mResult = false;
// }
// }
//
// return $mResult;
// }
*/
/** /**
* @param callback|null $fAdditionalExternalFilter = null * @param callback|null $fAdditionalExternalFilter = null
*/ */
@ -696,7 +414,7 @@ abstract class HtmlUtils
return \implode(';', $aOutStyles); return \implode(';', $aOutStyles);
} }
public static function FindLinksInDOM(\DOMDocument $oDom) public static function FindLinksInDOM(\DOMDocument $oDom) : void
{ {
$aNodes = $oDom->getElementsByTagName('*'); $aNodes = $oDom->getElementsByTagName('*');
foreach ($aNodes as /* @var $oElement \DOMElement */ $oElement) foreach ($aNodes as /* @var $oElement \DOMElement */ $oElement)
@ -734,7 +452,7 @@ abstract class HtmlUtils
->CompileText() ->CompileText()
; ;
$oSubDom = \MailSo\Base\HtmlUtils::GetDomFromText($sText); $oSubDom = static::GetDomFromText($sText);
if ($oSubDom) if ($oSubDom)
{ {
$oBodyNodes = $oSubDom->getElementsByTagName('body'); $oBodyNodes = $oSubDom->getElementsByTagName('body');
@ -752,7 +470,7 @@ abstract class HtmlUtils
'a' === \strtolower($oSubItem->tagName)) 'a' === \strtolower($oSubItem->tagName))
{ {
$oLink = $oDom->createElement('a', $oLink = $oDom->createElement('a',
\str_replace(':', \MailSo\Base\HtmlUtils::$KOS, \htmlspecialchars($oSubItem->nodeValue))); \str_replace(':', static::$KOS, \htmlspecialchars($oSubItem->nodeValue)));
$sHref = $oSubItem->getAttribute('href'); $sHref = $oSubItem->getAttribute('href');
if ($sHref) if ($sHref)
@ -795,7 +513,7 @@ abstract class HtmlUtils
$fAdditionalDomReader = null; $fAdditionalDomReader = null;
$bTryToDetectHiddenImages = false; $bTryToDetectHiddenImages = false;
return \MailSo\Base\HtmlUtils::ClearHtml($sHtml, $bHasExternals, $aFoundCIDs, return static::ClearHtml($sHtml, $bHasExternals, $aFoundCIDs,
$aContentLocationUrls, $aFoundedContentLocationUrls, $bDoNotReplaceExternalUrl, $bFindLinksInHtml, $aContentLocationUrls, $aFoundedContentLocationUrls, $bDoNotReplaceExternalUrl, $bFindLinksInHtml,
$fAdditionalExternalFilter, $fAdditionalDomReader, $bTryToDetectHiddenImages, $fAdditionalExternalFilter, $fAdditionalDomReader, $bTryToDetectHiddenImages,
$bWrapByFakeHtmlAndBodyDiv); $bWrapByFakeHtmlAndBodyDiv);
@ -833,7 +551,7 @@ abstract class HtmlUtils
$bHasExternals = false; $bHasExternals = false;
// Dom Part // Dom Part
$oDom = \MailSo\Base\HtmlUtils::GetDomFromText($sHtml); $oDom = static::GetDomFromText($sHtml);
unset($sHtml); unset($sHtml);
if (!$oDom) if (!$oDom)
@ -854,11 +572,11 @@ abstract class HtmlUtils
if ($bFindLinksInHtml) if ($bFindLinksInHtml)
{ {
\MailSo\Base\HtmlUtils::FindLinksInDOM($oDom); static::FindLinksInDOM($oDom);
} }
\MailSo\Base\HtmlUtils::ClearComments($oDom); static::ClearComments($oDom);
\MailSo\Base\HtmlUtils::ClearTags($oDom); static::ClearTags($oDom);
$sLinkColor = ''; $sLinkColor = '';
$aNodes = $oDom->getElementsByTagName('*'); $aNodes = $oDom->getElementsByTagName('*');
@ -1151,7 +869,7 @@ abstract class HtmlUtils
if ($oElement->hasAttribute('style') && !$oElement->hasAttribute('data-x-skip-style')) if ($oElement->hasAttribute('style') && !$oElement->hasAttribute('data-x-skip-style'))
{ {
$oElement->setAttribute('style', $oElement->setAttribute('style',
\MailSo\Base\HtmlUtils::ClearStyle($oElement->getAttribute('style'), $oElement, $bHasExternals, static::ClearStyle($oElement->getAttribute('style'), $oElement, $bHasExternals,
$aFoundCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, $bDoNotReplaceExternalUrl, $fAdditionalExternalFilter)); $aFoundCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, $bDoNotReplaceExternalUrl, $fAdditionalExternalFilter));
} }
@ -1170,7 +888,7 @@ abstract class HtmlUtils
} }
} }
$sResult = \MailSo\Base\HtmlUtils::GetTextFromDom($oDom, $bWrapByFakeHtmlAndBodyDiv); $sResult = static::GetTextFromDom($oDom, $bWrapByFakeHtmlAndBodyDiv);
unset($oDom); unset($oDom);
return $sResult; return $sResult;
@ -1178,9 +896,9 @@ abstract class HtmlUtils
public static function BuildHtml(string $sHtml, array &$aFoundCids = array(), &$mFoundDataURL = null, array &$aFoundedContentLocationUrls = array()) : string public static function BuildHtml(string $sHtml, array &$aFoundCids = array(), &$mFoundDataURL = null, array &$aFoundedContentLocationUrls = array()) : string
{ {
$oDom = \MailSo\Base\HtmlUtils::GetDomFromText($sHtml); $oDom = static::GetDomFromText($sHtml);
\MailSo\Base\HtmlUtils::ClearTags($oDom); static::ClearTags($oDom);
unset($sHtml); unset($sHtml);
$aNodes = $oDom->getElementsByTagName('*'); $aNodes = $oDom->getElementsByTagName('*');
@ -1304,7 +1022,7 @@ abstract class HtmlUtils
} }
} }
$sResult = \MailSo\Base\HtmlUtils::GetTextFromDom($oDom, false); $sResult = static::GetTextFromDom($oDom, false);
unset($oDom); unset($oDom);
return '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>'. return '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>'.

View file

@ -376,7 +376,7 @@ class BodyStructure
if (\is_array($this->aSubParts) && 0 < \count($this->aSubParts)) if (\is_array($this->aSubParts) && 0 < \count($this->aSubParts))
{ {
foreach ($this->aSubParts as /* @var $oSubPart \MailSo\Imap\BodyStructure */ &$oSubPart) foreach ($this->aSubParts as /* @var $oSubPart \MailSo\Imap\BodyStructure */ $oSubPart)
{ {
$aReturn = \array_merge($aReturn, $oSubPart->SearchByCallback($fCallback)); $aReturn = \array_merge($aReturn, $oSubPart->SearchByCallback($fCallback));
} }
@ -412,7 +412,7 @@ class BodyStructure
if (null === $oPart && is_array($this->aSubParts) && 0 < count($this->aSubParts)) if (null === $oPart && is_array($this->aSubParts) && 0 < count($this->aSubParts))
{ {
foreach ($this->aSubParts as /* @var $oSubPart \MailSo\Imap\BodyStructure */ &$oSubPart) foreach ($this->aSubParts as /* @var $oSubPart \MailSo\Imap\BodyStructure */ $oSubPart)
{ {
$oPart = $oSubPart->GetPartByMimeIndex($sMimeIndex); $oPart = $oSubPart->GetPartByMimeIndex($sMimeIndex);
if (null !== $oPart) if (null !== $oPart)
@ -741,7 +741,7 @@ class BodyStructure
$aDispositionParams = self::getKeyValueListFromArrayList($aDispParamList); $aDispositionParams = self::getKeyValueListFromArrayList($aDispParamList);
if (\is_array($aDispositionParams)) if (\is_array($aDispositionParams))
{ {
$sFileName = self::decodeAttrParamenter($aDispositionParams, 'filename', $sCharset); $sFileName = self::decodeAttrParamenter($aDispositionParams, 'filename', $sCharset ?: '');
} }
} }
} }

View file

@ -79,7 +79,7 @@ class FetchResponse
if (0 < strlen($sLocalPart) && 0 < strlen($sDomainPart)) if (0 < strlen($sLocalPart) && 0 < strlen($sDomainPart))
{ {
$oResult->Add( $oResult->append(
\MailSo\Mime\Email::NewInstance($sLocalPart.'@'.$sDomainPart, $sDisplayName) \MailSo\Mime\Email::NewInstance($sLocalPart.'@'.$sDomainPart, $sDisplayName)
); );
} }
@ -172,7 +172,7 @@ class FetchResponse
return $sReturn; return $sReturn;
} }
private static function findFetchUidAndSize(array $aList) private static function findFetchUidAndSize(array $aList) : bool
{ {
$bUid = false; $bUid = false;
$bSize = false; $bSize = false;

View file

@ -562,7 +562,7 @@ class ImapClient extends \MailSo\Net\NetClient
$sFolderNameRaw = $oImapResponse->ResponseList[2]; $sFolderNameRaw = $oImapResponse->ResponseList[2];
$oCurrentFolder = null; $oCurrentFolder = null;
foreach ($aReturn as &$oFolder) foreach ($aReturn as $oFolder)
{ {
if ($oFolder && $sFolderNameRaw === $oFolder->FullNameRaw()) if ($oFolder && $sFolderNameRaw === $oFolder->FullNameRaw())
{ {

View file

@ -23,7 +23,7 @@ class File extends \MailSo\Log\Driver
*/ */
private $sLoggerFileName; private $sLoggerFileName;
protected function __construct($sLoggerFileName, $sNewLine = "\r\n") protected function __construct(string $sLoggerFileName, string $sNewLine = "\r\n")
{ {
parent::__construct(); parent::__construct();

View file

@ -23,7 +23,7 @@ class Inline extends \MailSo\Log\Driver
*/ */
private $bHtmlEncodeSpecialChars; private $bHtmlEncodeSpecialChars;
protected function __construct($sNewLine = "\r\n", $bHtmlEncodeSpecialChars = false) protected function __construct(string $sNewLine = "\r\n", bool $bHtmlEncodeSpecialChars = false)
{ {
parent::__construct(); parent::__construct();

View file

@ -42,7 +42,7 @@ class Logger extends \MailSo\Base\Collection
*/ */
private $bHideErrorNotices; private $bHideErrorNotices;
protected function __construct($bRegPhpErrorHandler = true) protected function __construct(bool $bRegPhpErrorHandler = true)
{ {
parent::__construct(); parent::__construct();
@ -208,10 +208,9 @@ class Logger extends \MailSo\Base\Collection
{ {
$iResult = 1; $iResult = 1;
$aLoggers =& $this->GetAsArray(); foreach ($this as /* @var $oLogger \MailSo\Log\Driver */ $oLogger)
foreach ($aLoggers as /* @var $oLogger \MailSo\Log\Driver */ &$oLogger)
{ {
$iResult &= $oLogger->WriteEmptyLine(); $iResult = $oLogger->WriteEmptyLine();
} }
return (bool) $iResult; return (bool) $iResult;
@ -236,10 +235,9 @@ class Logger extends \MailSo\Base\Collection
$sDesc = \str_replace($this->aSecretWords, '*******', $sDesc); $sDesc = \str_replace($this->aSecretWords, '*******', $sDesc);
} }
$aLoggers =& $this->GetAsArray(); foreach ($this as /* @var $oLogger \MailSo\Log\Driver */ $oLogger)
foreach ($aLoggers as /* @var $oLogger \MailSo\Log\Driver */ $oLogger)
{ {
$iResult &= $oLogger->Write($sDesc, $iType, $sName, $bDiplayCrLf); $iResult = $oLogger->Write($sDesc, $iType, $sName, $bDiplayCrLf);
} }
return (bool) $iResult; return (bool) $iResult;

View file

@ -22,7 +22,7 @@ class AttachmentCollection extends \MailSo\Base\Collection
parent::__construct(); parent::__construct();
} }
public static function NewInstance() : \MailSo\Mail\AttachmentCollection public static function NewInstance() : self
{ {
return new self(); return new self();
} }

View file

@ -61,7 +61,7 @@ class FolderCollection extends \MailSo\Base\Collection
public function GetByFullNameRaw(string $sFullNameRaw) : ?\MailSo\Mail\Folder public function GetByFullNameRaw(string $sFullNameRaw) : ?\MailSo\Mail\Folder
{ {
$mResult = null; $mResult = null;
foreach ($this->aItems as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder) foreach ($this as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder)
{ {
if ($oFolder->FullNameRaw() === $sFullNameRaw) if ($oFolder->FullNameRaw() === $sFullNameRaw)
{ {
@ -88,7 +88,7 @@ class FolderCollection extends \MailSo\Base\Collection
public function CountRec() : int public function CountRec() : int
{ {
$iResult = $this->Count(); $iResult = $this->Count();
foreach ($this->aItems as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder) foreach ($this as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder)
{ {
if ($oFolder) if ($oFolder)
{ {
@ -110,9 +110,9 @@ class FolderCollection extends \MailSo\Base\Collection
$sDelimiter = '/'; $sDelimiter = '/';
$oFolder = $this->GetByFullNameRaw('INBOX'); $oFolder = $this->GetByFullNameRaw('INBOX');
if (!$oFolder) if (!$oFolder && isset($this[0]))
{ {
$oFolder = $this->GetByIndex(0); $oFolder = $this[0];
} }
if ($oFolder) if ($oFolder)
@ -123,7 +123,7 @@ class FolderCollection extends \MailSo\Base\Collection
return $sDelimiter; return $sDelimiter;
} }
public function SetNamespace(string $sNamespace) : \MailSo\Mail\FolderCollection public function SetNamespace(string $sNamespace) : self
{ {
$this->Namespace = $sNamespace; $this->Namespace = $sNamespace;
@ -135,7 +135,7 @@ class FolderCollection extends \MailSo\Base\Collection
$this->Clear(); $this->Clear();
$aSortedByLenImapFolders = array(); $aSortedByLenImapFolders = array();
foreach ($aUnsortedMailFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ &$oMailFolder) foreach ($aUnsortedMailFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ $oMailFolder)
{ {
$aSortedByLenImapFolders[$oMailFolder->FullNameRaw()] =& $oMailFolder; $aSortedByLenImapFolders[$oMailFolder->FullNameRaw()] =& $oMailFolder;
unset($oMailFolder); unset($oMailFolder);
@ -181,7 +181,7 @@ class FolderCollection extends \MailSo\Base\Collection
return \strnatcmp($oFolderA->FullNameRaw(), $oFolderB->FullNameRaw()); return \strnatcmp($oFolderA->FullNameRaw(), $oFolderB->FullNameRaw());
}); });
foreach ($aSortedByLenImapFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ &$oMailFolder) foreach ($aSortedByLenImapFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ $oMailFolder)
{ {
$this->AddWithPositionSearch($oMailFolder); $this->AddWithPositionSearch($oMailFolder);
unset($oMailFolder); unset($oMailFolder);
@ -194,9 +194,8 @@ class FolderCollection extends \MailSo\Base\Collection
{ {
$oItemFolder = null; $oItemFolder = null;
$bIsAdded = false; $bIsAdded = false;
$aList =& $this->GetAsArray();
foreach ($aList as /* @var $oItemFolder \MailSo\Mail\Folder */ $oItemFolder) foreach ($this as /* @var $oItemFolder \MailSo\Mail\Folder */ $oItemFolder)
{ {
if ($oMailFolder instanceof \MailSo\Mail\Folder && if ($oMailFolder instanceof \MailSo\Mail\Folder &&
0 === \strpos($oMailFolder->FullNameRaw(), $oItemFolder->FullNameRaw().$oItemFolder->Delimiter())) 0 === \strpos($oMailFolder->FullNameRaw(), $oItemFolder->FullNameRaw().$oItemFolder->Delimiter()))
@ -213,24 +212,21 @@ class FolderCollection extends \MailSo\Base\Collection
if (!$bIsAdded && $oMailFolder instanceof \MailSo\Mail\Folder) if (!$bIsAdded && $oMailFolder instanceof \MailSo\Mail\Folder)
{ {
$bIsAdded = true; $bIsAdded = true;
$this->Add($oMailFolder); $this->append($oMailFolder);
} }
return $bIsAdded; return $bIsAdded;
} }
/** public function SortByCallback(callable $fCallback) : void
* @param callable $fCallback
*/
public function SortByCallback($fCallback) : void
{ {
if (\is_callable($fCallback)) if (\is_callable($fCallback))
{ {
$aList =& $this->GetAsArray(); $aList = $this->getArrayCopy();
\usort($aList, $fCallback); \usort($aList, $fCallback);
foreach ($aList as &$oItemFolder) foreach ($aList as $oItemFolder)
{ {
if ($oItemFolder->HasSubFolders()) if ($oItemFolder->HasSubFolders())
{ {

View file

@ -1502,7 +1502,7 @@ class MailClient
{ {
$aFetchIndexArray = array(); $aFetchIndexArray = array();
$oFetchResponseItem = null; $oFetchResponseItem = null;
foreach ($aFetchResponse as /* @var $oFetchResponseItem \MailSo\Imap\FetchResponse */ &$oFetchResponseItem) foreach ($aFetchResponse as /* @var $oFetchResponseItem \MailSo\Imap\FetchResponse */ $oFetchResponseItem)
{ {
$aFetchIndexArray[($bIndexAsUid) $aFetchIndexArray[($bIndexAsUid)
? $oFetchResponseItem->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID) ? $oFetchResponseItem->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID)
@ -1515,7 +1515,7 @@ class MailClient
{ {
if (isset($aFetchIndexArray[$iFUid])) if (isset($aFetchIndexArray[$iFUid]))
{ {
$oMessageCollection->Add( $oMessageCollection->append(
Message::NewFetchResponseInstance( Message::NewFetchResponseInstance(
$oMessageCollection->FolderName, $aFetchIndexArray[$iFUid])); $oMessageCollection->FolderName, $aFetchIndexArray[$iFUid]));
} }
@ -1534,28 +1534,6 @@ class MailClient
$this->oImapClient->IsSupported('THREAD=ORDEREDSUBJECT'); $this->oImapClient->IsSupported('THREAD=ORDEREDSUBJECT');
} }
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageListSimple(string $sFolderName, array $aUids) : \MailSo\Mail\MessageCollection
{
if (0 === \strlen($sFolderName) || !\MailSo\Base\Validator::NotEmptyArray($aUids))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
$this->oImapClient->FolderExamine($sFolderName);
$oMessageCollection = \MailSo\Mail\MessageCollection::NewInstance();
$oMessageCollection->FolderName = $sFolderName;
$this->MessageListByRequestIndexOrUids($oMessageCollection, $aUids, true, true);
return $oMessageCollection->GetAsArray();
}
/** /**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception

View file

@ -742,7 +742,7 @@ class Message
$this->oAttachments = AttachmentCollection::NewInstance(); $this->oAttachments = AttachmentCollection::NewInstance();
foreach ($aAttachmentsParts as /* @var $oAttachmentItem \MailSo\Imap\BodyStructure */ $oAttachmentItem) foreach ($aAttachmentsParts as /* @var $oAttachmentItem \MailSo\Imap\BodyStructure */ $oAttachmentItem)
{ {
$this->oAttachments->Add( $this->oAttachments->append(
\MailSo\Mail\Attachment::NewBodyStructureInstance($this->sFolder, $this->iUid, $oAttachmentItem) \MailSo\Mail\Attachment::NewBodyStructureInstance($this->sFolder, $this->iUid, $oAttachmentItem)
); );
} }

View file

@ -57,8 +57,8 @@ class Attachment
*/ */
private $sContentLocation; private $sContentLocation;
private function __construct($rResource, $sFileName, $iFileSize, $bIsInline, $bIsLinked, $sCID, private function __construct($rResource, string $sFileName, int $iFileSize, bool $bIsInline, bool $bIsLinked, string $sCID,
$aCustomContentTypeParams = array(), $sContentLocation = '') array $aCustomContentTypeParams = array(), string $sContentLocation = '')
{ {
$this->rResource = $rResource; $this->rResource = $rResource;
$this->sFileName = $sFileName; $this->sFileName = $sFileName;

View file

@ -40,7 +40,7 @@ class Email
/** /**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/ */
private function __construct($sEmail, $sDisplayName = '') private function __construct(string $sEmail, string $sDisplayName = '')
{ {
if (!\MailSo\Base\Validator::NotEmptyString($sEmail, true)) if (!\MailSo\Base\Validator::NotEmptyString($sEmail, true))
{ {

View file

@ -17,7 +17,7 @@ namespace MailSo\Mime;
*/ */
class EmailCollection extends \MailSo\Base\Collection class EmailCollection extends \MailSo\Base\Collection
{ {
protected function __construct($sEmailAddresses = '') protected function __construct(string $sEmailAddresses = '')
{ {
parent::__construct(); parent::__construct();
@ -40,9 +40,8 @@ class EmailCollection extends \MailSo\Base\Collection
public function ToArray() : array public function ToArray() : array
{ {
$aReturn = $aEmails = array(); $aReturn = array();
$aEmails =& $this->GetAsArray(); foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
{ {
$aReturn[] = $oEmail->ToArray(); $aReturn[] = $oEmail->ToArray();
} }
@ -52,10 +51,9 @@ class EmailCollection extends \MailSo\Base\Collection
public function MergeWithOtherCollection(EmailCollection $oEmails) : self public function MergeWithOtherCollection(EmailCollection $oEmails) : self
{ {
$aEmails =& $oEmails->GetAsArray(); foreach ($oEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
{ {
$this->Add($oEmail); $this->append($oEmail);
} }
return $this; return $this;
@ -63,30 +61,26 @@ class EmailCollection extends \MailSo\Base\Collection
public function Unique() : self public function Unique() : self
{ {
$aCache = array();
$aReturn = array(); $aReturn = array();
$aEmails =& $this->GetAsArray(); foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
{ {
$sEmail = $oEmail->GetEmail(); $sEmail = $oEmail->GetEmail();
if (!isset($aCache[$sEmail])) if (!isset($aReturn[$sEmail]))
{ {
$aCache[$sEmail] = true; $aReturn[$sEmail] = $oEmail;
$aReturn[] = $oEmail;
} }
} }
$this->SetAsArray($aReturn); $this->exchangeArray(array_values($aReturn));
return $this; return $this;
} }
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string
{ {
$aReturn = $aEmails = array(); $aReturn = array();
$aEmails =& $this->GetAsArray(); foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
{ {
$aReturn[] = $oEmail->ToString($bConvertSpecialsName, $bIdn); $aReturn[] = $oEmail->ToString($bConvertSpecialsName, $bIdn);
} }
@ -174,7 +168,7 @@ class EmailCollection extends \MailSo\Base\Collection
try try
{ {
$this->Add( $this->append(
\MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iEmailEndPos - $iEmailStartPos)) \MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iEmailEndPos - $iEmailStartPos))
); );
@ -194,7 +188,7 @@ class EmailCollection extends \MailSo\Base\Collection
{ {
try try
{ {
$this->Add( $this->append(
\MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iCurrentPos - $iEmailStartPos)) \MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iCurrentPos - $iEmailStartPos))
); );
} }

View file

@ -46,7 +46,7 @@ class EmailDep
/** /**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/ */
private function __construct($sEmail, $sDisplayName = '', $sRemark = '') private function __construct(string $sEmail, string $sDisplayName = '', string $sRemark = '')
{ {
if (!\MailSo\Base\Validator::NotEmptyString($sEmail, true)) if (!\MailSo\Base\Validator::NotEmptyString($sEmail, true))
{ {

View file

@ -47,7 +47,7 @@ class Header
*/ */
private $sParentCharset; private $sParentCharset;
private function __construct($sName, $sValue, $sEncodedValueForReparse, $sParentCharset = '') private function __construct(string $sName, string $sValue, string $sEncodedValueForReparse, string $sParentCharset = '')
{ {
$this->sParentCharset = $sParentCharset; $this->sParentCharset = $sParentCharset;

View file

@ -21,11 +21,11 @@ class HeaderCollection extends \MailSo\Base\Collection
protected $sRawHeaders; protected $sRawHeaders;
/** /**
* @var strign * @var string
*/ */
protected $sParentCharset; protected $sParentCharset;
protected function __construct($sRawHeaders = '', $bStoreRawHeaders = true) protected function __construct(string $sRawHeaders = '', bool $bStoreRawHeaders = true)
{ {
parent::__construct(); parent::__construct();
@ -38,49 +38,34 @@ class HeaderCollection extends \MailSo\Base\Collection
} }
} }
public static function NewInstance(string $sRawHeaders = '', bool $bStoreRawHeaders = true) : \MailSo\Mime\HeaderCollection public static function NewInstance(string $sRawHeaders = '', bool $bStoreRawHeaders = true) : self
{ {
return new self($sRawHeaders, $bStoreRawHeaders); return new self($sRawHeaders, $bStoreRawHeaders);
} }
/** public function AddByName(string $sName, string $sValue, bool $bToTop = false) : self
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function AddByName(string $sName, string $sValue, bool $bToTop = false) : \MailSo\Mime\HeaderCollection
{ {
return $this->Add(Header::NewInstance($sName, $sValue), $bToTop); $this->append(Header::NewInstance($sName, $sValue), $bToTop);
return $this;
} }
/** public function SetByName(string $sName, string $sValue, bool $bToTop = false) : self
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
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
{
$mResult = null;
$mResult =& parent::GetByIndex($iIndex);
return $mResult;
}
public function ValueByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : string public function ValueByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : string
{ {
$oHeader = null; $oHeader = $this->GetByName($sHeaderName);
$oHeader =& $this->GetByName($sHeaderName); return $oHeader ? ($bCharsetAutoDetect ? $oHeader->ValueWithCharsetAutoDetect() : $oHeader->Value()) : '';
return (null !== $oHeader) ? ($bCharsetAutoDetect ? $oHeader->ValueWithCharsetAutoDetect() : $oHeader->Value()) : '';
} }
public function ValuesByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : array public function ValuesByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : array
{ {
$aResult = array(); $aResult = array();
$oHeader = null;
$sHeaderNameLower = \strtolower($sHeaderName); $sHeaderNameLower = \strtolower($sHeaderName);
$aHeaders =& $this->GetAsArray(); foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader)
{ {
if ($sHeaderNameLower === \strtolower($oHeader->Name())) if ($sHeaderNameLower === \strtolower($oHeader->Name()))
{ {
@ -91,12 +76,12 @@ class HeaderCollection extends \MailSo\Base\Collection
return $aResult; return $aResult;
} }
public function RemoveByName(string $sHeaderName) : \MailSo\Mime\HeaderCollection public function RemoveByName(string $sHeaderName) : self
{ {
$aResult = $this->FilterList(function ($oHeader) use ($sHeaderName) { $sHeaderName = \strtolower($sHeaderName);
return $oHeader && \strtolower($oHeader->Name()) !== \strtolower($sHeaderName); $this->exchangeArray(array_filter($this->getArrayCopy(), function ($oHeader) use ($sHeaderName) {
}); return $oHeader && \strtolower($oHeader->Name()) !== $sHeaderName;
$this->SetAsArray($aResult); }));
return $this; return $this;
} }
@ -114,14 +99,8 @@ class HeaderCollection extends \MailSo\Base\Collection
public function ParametersByName(string $sHeaderName) : ?\MailSo\Mime\ParameterCollection public function ParametersByName(string $sHeaderName) : ?\MailSo\Mime\ParameterCollection
{ {
$oParameters = $oHeader = null; $oHeader = $this->GetByName($sHeaderName);
$oHeader =& $this->GetByName($sHeaderName); return $oHeader ? $oHeader->Parameters() : null;
if ($oHeader)
{
$oParameters = $oHeader->Parameters();
}
return $oParameters;
} }
public function ParameterValue(string $sHeaderName, string $sParamName) : string public function ParameterValue(string $sHeaderName, string $sParamName) : string
@ -130,34 +109,27 @@ class HeaderCollection extends \MailSo\Base\Collection
return (null !== $oParameters) ? $oParameters->ParameterValueByName($sParamName) : ''; return (null !== $oParameters) ? $oParameters->ParameterValueByName($sParamName) : '';
} }
public function &GetByName(string $sHeaderName) : ?\MailSo\Mime\Header public function GetByName(string $sHeaderName) : ?\MailSo\Mime\Header
{ {
$oResult = $oHeader = null;
$sHeaderNameLower = \strtolower($sHeaderName); $sHeaderNameLower = \strtolower($sHeaderName);
$aHeaders =& $this->GetAsArray(); foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader)
{ {
if ($sHeaderNameLower === \strtolower($oHeader->Name())) if ($sHeaderNameLower === \strtolower($oHeader->Name()))
{ {
$oResult =& $oHeader; return $oHeader;
break;
} }
} }
return $oResult; return null;
} }
public function SetParentCharset(string $sParentCharset) : \MailSo\Mime\HeaderCollection public function SetParentCharset(string $sParentCharset) : self
{ {
if (0 < \strlen($sParentCharset)) if (0 < \strlen($sParentCharset))
{ {
if ($this->sParentCharset !== $sParentCharset) if ($this->sParentCharset !== $sParentCharset)
{ {
$oHeader = null; foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
$aHeaders =& $this->GetAsArray();
foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader)
{ {
$oHeader->SetParentCharset($sParentCharset); $oHeader->SetParentCharset($sParentCharset);
} }
@ -171,12 +143,11 @@ class HeaderCollection extends \MailSo\Base\Collection
public function Clear() : void public function Clear() : void
{ {
parent::Clear(); $this->exchangeArray(array());
$this->sRawHeaders = ''; $this->sRawHeaders = '';
} }
public function Parse(string $sRawHeaders, bool $bStoreRawHeaders = false, string $sParentCharset = '') : \MailSo\Mime\HeaderCollection public function Parse(string $sRawHeaders, bool $bStoreRawHeaders = false, string $sParentCharset = '') : self
{ {
$this->Clear(); $this->Clear();
@ -236,7 +207,7 @@ class HeaderCollection extends \MailSo\Base\Collection
$oHeader = Header::NewInstanceFromEncodedString($sName.': '.$sValue, $this->sParentCharset); $oHeader = Header::NewInstanceFromEncodedString($sName.': '.$sValue, $this->sParentCharset);
if ($oHeader) if ($oHeader)
{ {
$this->Add($oHeader); $this->append($oHeader);
} }
$sName = null; $sName = null;
@ -259,7 +230,7 @@ class HeaderCollection extends \MailSo\Base\Collection
$oHeader = Header::NewInstanceFromEncodedString($sName.': '.$sValue, $this->sParentCharset); $oHeader = Header::NewInstanceFromEncodedString($sName.': '.$sValue, $this->sParentCharset);
if ($oHeader) if ($oHeader)
{ {
$this->Add($oHeader); $this->append($oHeader);
} }
} }
@ -370,8 +341,7 @@ class HeaderCollection extends \MailSo\Base\Collection
public function ToEncodedString() : string public function ToEncodedString() : string
{ {
$aResult = array(); $aResult = array();
$aHeaders =& $this->GetAsArray(); foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader)
{ {
$aResult[] = $oHeader->EncodedValue(); $aResult[] = $oHeader->EncodedValue();
} }

View file

@ -402,14 +402,14 @@ class Message
\MailSo\Mime\Enumerations\Parameter::FILENAME, $sFileName)); \MailSo\Mime\Enumerations\Parameter::FILENAME, $sFileName));
} }
$oAttachmentPart->Headers->Add( $oAttachmentPart->Headers->append(
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
$oAttachment->ContentType().';'. $oAttachment->ContentType().';'.
(($oContentTypeParameters) ? ' '.$oContentTypeParameters->ToString() : '') (($oContentTypeParameters) ? ' '.$oContentTypeParameters->ToString() : '')
) )
); );
$oAttachmentPart->Headers->Add( $oAttachmentPart->Headers->append(
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_DISPOSITION, Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_DISPOSITION,
($oAttachment->IsInline() ? 'inline' : 'attachment').';'. ($oAttachment->IsInline() ? 'inline' : 'attachment').';'.
(($oContentDispositionParameters) ? ' '.$oContentDispositionParameters->ToString() : '') (($oContentDispositionParameters) ? ' '.$oContentDispositionParameters->ToString() : '')
@ -418,14 +418,14 @@ class Message
if (0 < strlen($sCID)) if (0 < strlen($sCID))
{ {
$oAttachmentPart->Headers->Add( $oAttachmentPart->Headers->append(
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_ID, $sCID) Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_ID, $sCID)
); );
} }
if (0 < strlen($sContentLocation)) if (0 < strlen($sContentLocation))
{ {
$oAttachmentPart->Headers->Add( $oAttachmentPart->Headers->append(
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_LOCATION, $sContentLocation) Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_LOCATION, $sContentLocation)
); );
} }
@ -434,7 +434,7 @@ class Message
if ('message/rfc822' !== strtolower($oAttachment->ContentType())) if ('message/rfc822' !== strtolower($oAttachment->ContentType()))
{ {
$oAttachmentPart->Headers->Add( $oAttachmentPart->Headers->append(
Header::NewInstance( Header::NewInstance(
\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING, \MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING,
\MailSo\Base\Enumerations\Encoding::BASE64_LOWER \MailSo\Base\Enumerations\Encoding::BASE64_LOWER
@ -466,7 +466,7 @@ class Message
{ {
$oAlternativePart = Part::NewInstance(); $oAlternativePart = Part::NewInstance();
$oParameters = ParameterCollection::NewInstance(); $oParameters = ParameterCollection::NewInstance();
$oParameters->Add( $oParameters->append(
Parameter::NewInstance( Parameter::NewInstance(
\MailSo\Mime\Enumerations\Parameter::CHARSET, \MailSo\Mime\Enumerations\Parameter::CHARSET,
\MailSo\Base\Enumerations\Charset::UTF_8) \MailSo\Base\Enumerations\Charset::UTF_8)
@ -476,11 +476,11 @@ class Message
{ {
foreach ($aAlternativeData[3] as $sName => $sValue) foreach ($aAlternativeData[3] as $sName => $sValue)
{ {
$oParameters->Add(Parameter::NewInstance($sName, $sValue)); $oParameters->append(Parameter::NewInstance($sName, $sValue));
} }
} }
$oAlternativePart->Headers->Add( $oAlternativePart->Headers->append(
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
$aAlternativeData[0].'; '.$oParameters->ToString()) $aAlternativeData[0].'; '.$oParameters->ToString())
); );
@ -501,7 +501,7 @@ class Message
if (isset($aAlternativeData[2]) && 0 < strlen($aAlternativeData[2])) if (isset($aAlternativeData[2]) && 0 < strlen($aAlternativeData[2]))
{ {
$oAlternativePart->Headers->Add( $oAlternativePart->Headers->append(
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING, Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING,
$aAlternativeData[2] $aAlternativeData[2]
) )
@ -538,7 +538,7 @@ class Message
{ {
$oResultPart = Part::NewInstance(); $oResultPart = Part::NewInstance();
$oResultPart->Headers->Add( $oResultPart->Headers->append(
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
\MailSo\Mime\Enumerations\MimeType::MULTIPART_ALTERNATIVE.'; '. \MailSo\Mime\Enumerations\MimeType::MULTIPART_ALTERNATIVE.'; '.
ParameterCollection::NewInstance()->Add( ParameterCollection::NewInstance()->Add(
@ -554,7 +554,7 @@ class Message
$oAlternativePart = $this->createNewMessageAlternativePartBody($aAlternativeData); $oAlternativePart = $this->createNewMessageAlternativePartBody($aAlternativeData);
if ($oAlternativePart) if ($oAlternativePart)
{ {
$oResultPart->SubParts->Add($oAlternativePart); $oResultPart->SubParts->append($oAlternativePart);
} }
unset($oAlternativePart); unset($oAlternativePart);
@ -580,7 +580,7 @@ class Message
} }
else else
{ {
$aAttachments = $this->oAttachmentCollection->CloneAsArray(); $aAttachments = $this->oAttachmentCollection->getArrayCopy();
if (\is_array($aAttachments) && 1 === count($aAttachments) && isset($aAttachments[0])) if (\is_array($aAttachments) && 1 === count($aAttachments) && isset($aAttachments[0]))
{ {
$this->oAttachmentCollection->Clear(); $this->oAttachmentCollection->Clear();
@ -605,7 +605,7 @@ class Message
{ {
$oResultPart = Part::NewInstance(); $oResultPart = Part::NewInstance();
$oResultPart->Headers->Add( $oResultPart->Headers->append(
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
\MailSo\Mime\Enumerations\MimeType::MULTIPART_RELATED.'; '. \MailSo\Mime\Enumerations\MimeType::MULTIPART_RELATED.'; '.
ParameterCollection::NewInstance()->Add( ParameterCollection::NewInstance()->Add(
@ -616,11 +616,11 @@ class Message
) )
); );
$oResultPart->SubParts->Add($oIncPart); $oResultPart->SubParts->append($oIncPart);
foreach ($aAttachments as $oAttachment) foreach ($aAttachments as $oAttachment)
{ {
$oResultPart->SubParts->Add($this->createNewMessageAttachmentBody($oAttachment)); $oResultPart->SubParts->append($this->createNewMessageAttachmentBody($oAttachment));
} }
} }
else else
@ -649,11 +649,11 @@ class Message
)->ToString() )->ToString()
); );
$oResultPart->SubParts->Add($oIncPart); $oResultPart->SubParts->append($oIncPart);
foreach ($aAttachments as $oAttachment) foreach ($aAttachments as $oAttachment)
{ {
$oResultPart->SubParts->Add($this->createNewMessageAttachmentBody($oAttachment)); $oResultPart->SubParts->append($this->createNewMessageAttachmentBody($oAttachment));
} }
} }
else else

View file

@ -27,7 +27,7 @@ class Parameter
*/ */
private $sValue; private $sValue;
private function __construct($sName, $sValue) private function __construct(string $sName, string $sValue)
{ {
$this->sName = $sName; $this->sName = $sName;
$this->sValue = $sValue; $this->sValue = $sValue;

View file

@ -17,7 +17,7 @@ namespace MailSo\Mime;
*/ */
class ParameterCollection extends \MailSo\Base\Collection class ParameterCollection extends \MailSo\Base\Collection
{ {
protected function __construct($sRawParams = '') protected function __construct(string $sRawParams = '')
{ {
parent::__construct(); parent::__construct();
@ -32,29 +32,19 @@ class ParameterCollection extends \MailSo\Base\Collection
return new self($sRawParams); return new self($sRawParams);
} }
public function &GetByIndex(int $iIndex) : ?\MailSo\Mime\Parameter
{
$mResult = null;
$mResult =& parent::GetByIndex($iIndex);
return $mResult;
}
public function ParameterValueByName(string $sName) : string public function ParameterValueByName(string $sName) : string
{ {
$sResult = ''; $sName = \strtolower(\trim($sName));
$sName = \trim($sName);
$aParams =& $this->GetAsArray(); foreach ($this as /* @var $oParam \MailSo\Mime\ParameterCollection */ $oParam)
foreach ($aParams as /* @var $oParam \MailSo\Mime\ParameterCollection */ $oParam)
{ {
if (\strtolower($sName) === \strtolower($oParam->Name())) if ($sName === \strtolower($oParam->Name()))
{ {
$sResult = $oParam->Value(); return $oParam->Value();
break;
} }
} }
return $sResult; return '';
} }
public function Parse(string $sRawParams) : self public function Parse(string $sRawParams) : self
@ -65,7 +55,7 @@ class ParameterCollection extends \MailSo\Base\Collection
foreach ($aDataToParse as $sParam) foreach ($aDataToParse as $sParam)
{ {
$this->Add(Parameter::CreateFromParameterLine($sParam)); $this->append(Parameter::CreateFromParameterLine($sParam));
} }
$this->reParseParameters(); $this->reParseParameters();
@ -76,8 +66,7 @@ class ParameterCollection extends \MailSo\Base\Collection
public function ToString(bool $bConvertSpecialsName = false) : string public function ToString(bool $bConvertSpecialsName = false) : string
{ {
$aResult = array(); $aResult = array();
$aParams =& $this->GetAsArray(); foreach ($this as /* @var $oParam \MailSo\Mime\Parameter */ $oParam)
foreach ($aParams as /* @var $oParam \MailSo\Mime\Parameter */ $oParam)
{ {
$sLine = $oParam->ToString($bConvertSpecialsName); $sLine = $oParam->ToString($bConvertSpecialsName);
if (0 < \strlen($sLine)) if (0 < \strlen($sLine))
@ -91,7 +80,7 @@ class ParameterCollection extends \MailSo\Base\Collection
private function reParseParameters() : void private function reParseParameters() : void
{ {
$aDataToReParse = $this->CloneAsArray(); $aDataToReParse = $this->getArrayCopy();
$sCharset = \MailSo\Base\Enumerations\Charset::UTF_8; $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8;
$this->Clear(); $this->Clear();
@ -146,7 +135,7 @@ class ParameterCollection extends \MailSo\Base\Collection
} }
else else
{ {
$this->Add($oParam); $this->append($oParam);
} }
} }
@ -162,7 +151,7 @@ class ParameterCollection extends \MailSo\Base\Collection
$sCharset, \MailSo\Base\Enumerations\Charset::UTF_8); $sCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
} }
$this->Add(Parameter::NewInstance($sName, $sResult)); $this->append(Parameter::NewInstance($sName, $sResult));
} }
} }
} }

View file

@ -262,7 +262,7 @@ class Part
$sPrevBuffer, $sBuffer, $aBoundaryStack, $bIsOef); $sPrevBuffer, $sBuffer, $aBoundaryStack, $bIsOef);
$sFirstNotNullCharset = null; $sFirstNotNullCharset = null;
foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ &$oMimePart) foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ $oMimePart)
{ {
$sCharset = $oMimePart->HeaderCharset(); $sCharset = $oMimePart->HeaderCharset();
if (0 < strlen($sCharset)) if (0 < strlen($sCharset))
@ -275,7 +275,7 @@ class Part
$sForceCharset = self::$ForceCharset; $sForceCharset = self::$ForceCharset;
if (0 < strlen($sForceCharset)) if (0 < strlen($sForceCharset))
{ {
foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ &$oMimePart) foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ $oMimePart)
{ {
$oMimePart->SetParentCharset($sForceCharset); $oMimePart->SetParentCharset($sForceCharset);
$oMimePart->Headers->SetParentCharset($sForceCharset); $oMimePart->Headers->SetParentCharset($sForceCharset);
@ -286,7 +286,7 @@ class Part
$sFirstNotNullCharset = (null !== $sFirstNotNullCharset) $sFirstNotNullCharset = (null !== $sFirstNotNullCharset)
? $sFirstNotNullCharset : self::$DefaultCharset; ? $sFirstNotNullCharset : self::$DefaultCharset;
foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ &$oMimePart) foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ $oMimePart)
{ {
$sHeaderCharset = $oMimePart->HeaderCharset(); $sHeaderCharset = $oMimePart->HeaderCharset();
$oMimePart->SetParentCharset((0 < strlen($sHeaderCharset)) ? $sHeaderCharset : $sFirstNotNullCharset); $oMimePart->SetParentCharset((0 < strlen($sHeaderCharset)) ? $sHeaderCharset : $sFirstNotNullCharset);
@ -302,7 +302,7 @@ class Part
/** /**
* @param resource $rStreamHandle * @param resource $rStreamHandle
*/ */
public function ParseFromStreamRecursion($rStreamHandle, &$oCallbackClass, int &$iOffset, public function ParseFromStreamRecursion($rStreamHandle, $oCallbackClass, int &$iOffset,
string &$sPrevBuffer, string &$sBuffer, array &$aBoundaryStack, bool &$bIsOef, bool $bNotFirstRead = false) : self string &$sPrevBuffer, string &$sBuffer, array &$aBoundaryStack, bool &$bIsOef, bool $bNotFirstRead = false) : self
{ {
$oCallbackClass->StartParseMimePart($this); $oCallbackClass->StartParseMimePart($this);
@ -496,7 +496,7 @@ class Part
->ParseFromStreamRecursion($rStreamHandle, $oCallbackClass, ->ParseFromStreamRecursion($rStreamHandle, $oCallbackClass,
$iOffset, $sPrevBuffer, $sBuffer, $aBoundaryStack, $bIsOef, true); $iOffset, $sPrevBuffer, $sBuffer, $aBoundaryStack, $bIsOef, true);
$this->SubParts->Add($oSubPart); $this->SubParts->append($oSubPart);
$this->LineParts[] =& $oSubPart; $this->LineParts[] =& $oSubPart;
//$iParsePosition = self::POS_HEADERS; //$iParsePosition = self::POS_HEADERS;
unset($oSubPart); unset($oSubPart);

View file

@ -37,8 +37,7 @@ class PartCollection extends \MailSo\Base\Collection
{ {
$aResult = array(); $aResult = array();
$aParts =& $this->GetAsArray(); foreach ($this as /* @var $oPart \MailSo\Mime\Part */ $oPart)
foreach ($aParts as /* @var $oPart \MailSo\Mime\Part */ &$oPart)
{ {
if (0 < count($aResult)) if (0 < count($aResult))
{ {

View file

@ -28,10 +28,7 @@ class SocketCanNotConnectToHostException extends \MailSo\Net\Exceptions\Connecti
*/ */
private $iSocketCode; private $iSocketCode;
/** public function __construct(string $sSocketMessage = '', int $iSocketCode = 0, string $sMessage = '', int $iCode = 0, ?\Throwable $oPrevious = null)
* @param \Exception $oPrevious = null
*/
public function __construct($sSocketMessage = '', $iSocketCode = 0, $sMessage = '', $iCode = 0, $oPrevious = null)
{ {
parent::__construct($sMessage, $iCode, $oPrevious); parent::__construct($sMessage, $iCode, $oPrevious);

View file

@ -23,10 +23,7 @@ class ResponseException extends \MailSo\Sieve\Exceptions\Exception
*/ */
private $aResponses; private $aResponses;
/** public function __construct(array $aResponses = array(), string $sMessage = '', int $iCode = 0, ?\Throwable $oPrevious = null)
* @param \Exception $oPrevious = null
*/
public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null)
{ {
parent::__construct($sMessage, $iCode, $oPrevious); parent::__construct($sMessage, $iCode, $oPrevious);

View file

@ -23,10 +23,7 @@ class ResponseException extends \MailSo\Smtp\Exceptions\Exception
*/ */
private $aResponses; private $aResponses;
/** public function __construct(array $aResponses = array(), string $sMessage = '', int $iCode = 0, ?\Throwable $oPrevious = null)
* @param \Exception $oPrevious = null
*/
public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null)
{ {
parent::__construct($sMessage, $iCode, $oPrevious); parent::__construct($sMessage, $iCode, $oPrevious);

View file

@ -146,7 +146,7 @@ class Actions
$this->bIsAjax = false; $this->bIsAjax = false;
$oConfig = $this->Config(); $oConfig = $this->Config();
$this->Plugins()->RunHook('filter.application-config', array(&$oConfig)); $this->Plugins()->RunHook('filter.application-config', array($oConfig));
$this->Logger()->Ping(); $this->Logger()->Ping();
} }
@ -907,7 +907,7 @@ class Actions
$oDriver = \MailSo\Log\Drivers\File::NewInstance($sLogFileFullPath); $oDriver = \MailSo\Log\Drivers\File::NewInstance($sLogFileFullPath);
} }
$this->oLogger->Add($oDriver $this->oLogger->append($oDriver
->WriteOnErrorOnly($this->Config()->Get('logs', 'write_on_error_only', false)) ->WriteOnErrorOnly($this->Config()->Get('logs', 'write_on_error_only', false))
->WriteOnPhpErrorOnly($this->Config()->Get('logs', 'write_on_php_error_only', false)) ->WriteOnPhpErrorOnly($this->Config()->Get('logs', 'write_on_php_error_only', false))
->WriteOnTimeoutOnly($this->Config()->Get('logs', 'write_on_timeout_only', 0)) ->WriteOnTimeoutOnly($this->Config()->Get('logs', 'write_on_timeout_only', 0))
@ -981,7 +981,7 @@ class Actions
$oDriver->DisableGuidPrefix(); $oDriver->DisableGuidPrefix();
$oDriver->DisableTypedPrefix(); $oDriver->DisableTypedPrefix();
$this->oLoggerAuth->Add($oDriver); $this->oLoggerAuth->append($oDriver);
} }
} }
@ -1058,7 +1058,7 @@ class Actions
if ($oDomain->ValidateWhiteList($sEmail, $sLogin)) if ($oDomain->ValidateWhiteList($sEmail, $sLogin))
{ {
$oAccount = \RainLoop\Model\Account::NewInstance($sEmail, $sLogin, $sPassword, $oDomain, $sSignMeToken, '', '', $sClientCert); $oAccount = \RainLoop\Model\Account::NewInstance($sEmail, $sLogin, $sPassword, $oDomain, $sSignMeToken, '', '', $sClientCert);
$this->Plugins()->RunHook('filter.acount', array(&$oAccount)); $this->Plugins()->RunHook('filter.acount', array($oAccount));
if ($bThrowProvideException && !($oAccount instanceof \RainLoop\Model\Account)) if ($bThrowProvideException && !($oAccount instanceof \RainLoop\Model\Account))
{ {
@ -1885,7 +1885,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError); throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
} }
$this->Plugins()->RunHook('event.login-post-login-provide', array(&$oAccount)); $this->Plugins()->RunHook('event.login-post-login-provide', array($oAccount));
if (!($oAccount instanceof \RainLoop\Model\Account)) if (!($oAccount instanceof \RainLoop\Model\Account))
{ {
@ -4268,9 +4268,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$aResult = array(); $aResult = array();
if ($oFolders) if ($oFolders)
{ {
$aFolders =& $oFolders->GetAsArray(); foreach ($oFolders as $oFolder)
foreach ($aFolders as $oFolder)
{ {
$aResult[] = $oFolder->FullNameRaw()."|". $aResult[] = $oFolder->FullNameRaw()."|".
implode("|", $oFolder->Flags()).($oFolder->IsSubscribed() ? '1' : '0'); implode("|", $oFolder->Flags()).($oFolder->IsSubscribed() ? '1' : '0');
@ -4359,69 +4357,65 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
private function recFoldersTypes(\RainLoop\Model\Account $oAccount, \MailSo\Mail\FolderCollection $oFolders, array &$aResult, bool $bListFolderTypes = true) : void private function recFoldersTypes(\RainLoop\Model\Account $oAccount, \MailSo\Mail\FolderCollection $oFolders, array &$aResult, bool $bListFolderTypes = true) : void
{ {
if ($oFolders) if ($oFolders && $oFolders->Count())
{ {
$aFolders =& $oFolders->GetAsArray(); if ($bListFolderTypes)
if (\is_array($aFolders) && 0 < \count($aFolders))
{ {
if ($bListFolderTypes) foreach ($oFolders as $oFolder)
{ {
foreach ($aFolders as $oFolder) $iFolderListType = $oFolder->GetFolderListType();
if (!isset($aResult[$iFolderListType]) && \in_array($iFolderListType, array(
\MailSo\Imap\Enumerations\FolderType::SENT,
\MailSo\Imap\Enumerations\FolderType::DRAFTS,
\MailSo\Imap\Enumerations\FolderType::JUNK,
\MailSo\Imap\Enumerations\FolderType::TRASH,
\MailSo\Imap\Enumerations\FolderType::ALL
)))
{ {
$iFolderListType = $oFolder->GetFolderListType(); $aResult[$iFolderListType] = $oFolder->FullNameRaw();
if (!isset($aResult[$iFolderListType]) && \in_array($iFolderListType, array(
\MailSo\Imap\Enumerations\FolderType::SENT,
\MailSo\Imap\Enumerations\FolderType::DRAFTS,
\MailSo\Imap\Enumerations\FolderType::JUNK,
\MailSo\Imap\Enumerations\FolderType::TRASH,
\MailSo\Imap\Enumerations\FolderType::ALL
)))
{
$aResult[$iFolderListType] = $oFolder->FullNameRaw();
}
}
foreach ($aFolders as $oFolder)
{
$oSub = $oFolder->SubFolders();
if ($oSub && 0 < $oSub->Count())
{
$this->recFoldersTypes($oAccount, $oSub, $aResult, true);
}
} }
} }
$aMap = $this->systemFoldersNames($oAccount); foreach ($oFolders as $oFolder)
foreach ($aFolders as $oFolder)
{
$sName = $oFolder->Name();
$sFullName = $oFolder->FullName();
if (isset($aMap[$sName]) || isset($aMap[$sFullName]))
{
$iFolderType = isset($aMap[$sName]) ? $aMap[$sName] : $aMap[$sFullName];
if (!isset($aResult[$iFolderType]) && \in_array($iFolderType, array(
\MailSo\Imap\Enumerations\FolderType::SENT,
\MailSo\Imap\Enumerations\FolderType::DRAFTS,
\MailSo\Imap\Enumerations\FolderType::JUNK,
\MailSo\Imap\Enumerations\FolderType::TRASH,
\MailSo\Imap\Enumerations\FolderType::ALL
)))
{
$aResult[$iFolderType] = $oFolder->FullNameRaw();
}
}
}
foreach ($aFolders as $oFolder)
{ {
$oSub = $oFolder->SubFolders(); $oSub = $oFolder->SubFolders();
if ($oSub && 0 < $oSub->Count()) if ($oSub && 0 < $oSub->Count())
{ {
$this->recFoldersTypes($oAccount, $oSub, $aResult, false); $this->recFoldersTypes($oAccount, $oSub, $aResult, true);
} }
} }
} }
$aMap = $this->systemFoldersNames($oAccount);
foreach ($oFolders as $oFolder)
{
$sName = $oFolder->Name();
$sFullName = $oFolder->FullName();
if (isset($aMap[$sName]) || isset($aMap[$sFullName]))
{
$iFolderType = isset($aMap[$sName]) ? $aMap[$sName] : $aMap[$sFullName];
if (!isset($aResult[$iFolderType]) && \in_array($iFolderType, array(
\MailSo\Imap\Enumerations\FolderType::SENT,
\MailSo\Imap\Enumerations\FolderType::DRAFTS,
\MailSo\Imap\Enumerations\FolderType::JUNK,
\MailSo\Imap\Enumerations\FolderType::TRASH,
\MailSo\Imap\Enumerations\FolderType::ALL
)))
{
$aResult[$iFolderType] = $oFolder->FullNameRaw();
}
}
}
foreach ($oFolders as $oFolder)
{
$oSub = $oFolder->SubFolders();
if ($oSub && 0 < $oSub->Count())
{
$this->recFoldersTypes($oAccount, $oSub, $aResult, false);
}
}
} }
} }
@ -4430,7 +4424,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$oAccount = $this->initMailClientConnection(); $oAccount = $this->initMailClientConnection();
$oFolderCollection = null; $oFolderCollection = null;
$this->Plugins()->RunHook('filter.folders-before', array($oAccount, &$oFolderCollection)); $this->Plugins()->RunHook('filter.folders-before', array($oAccount, $oFolderCollection));
$bUseFolders = $this->GetCapa(false, false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount); $bUseFolders = $this->GetCapa(false, false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount);
@ -4443,7 +4437,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
); );
} }
$this->Plugins()->RunHook('filter.folders-post', array($oAccount, &$oFolderCollection)); $this->Plugins()->RunHook('filter.folders-post', array($oAccount, $oFolderCollection));
if ($oFolderCollection instanceof \MailSo\Mail\FolderCollection) if ($oFolderCollection instanceof \MailSo\Mail\FolderCollection)
{ {
@ -4563,7 +4557,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
} }
} }
$this->Plugins()->RunHook('filter.folders-complete', array($oAccount, &$oFolderCollection)); $this->Plugins()->RunHook('filter.folders-complete', array($oAccount, $oFolderCollection));
return $this->DefaultResponse(__FUNCTION__, $oFolderCollection); return $this->DefaultResponse(__FUNCTION__, $oFolderCollection);
} }
@ -5038,12 +5032,12 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
\MailSo\Base\HtmlUtils::BuildHtml($sText, $aFoundedCids, $mFoundDataURL, $aFoundedContentLocationUrls) : $sText; \MailSo\Base\HtmlUtils::BuildHtml($sText, $aFoundedCids, $mFoundDataURL, $aFoundedContentLocationUrls) : $sText;
$this->Plugins()->RunHook($bTextIsHtml ? 'filter.message-html' : 'filter.message-plain', $this->Plugins()->RunHook($bTextIsHtml ? 'filter.message-html' : 'filter.message-plain',
array($oAccount, &$oMessage, &$sTextToAdd)); array($oAccount, $oMessage, &$sTextToAdd));
if ($bTextIsHtml && 0 < \strlen($sTextToAdd)) if ($bTextIsHtml && 0 < \strlen($sTextToAdd))
{ {
$sTextConverted = \MailSo\Base\HtmlUtils::ConvertHtmlToPlain($sTextToAdd); $sTextConverted = \MailSo\Base\HtmlUtils::ConvertHtmlToPlain($sTextToAdd);
$this->Plugins()->RunHook('filter.message-plain', array($oAccount, &$oMessage, &$sTextConverted)); $this->Plugins()->RunHook('filter.message-plain', array($oAccount, $oMessage, &$sTextConverted));
$oMessage->AddText($sTextConverted, false); $oMessage->AddText($sTextConverted, false);
} }
@ -5063,7 +5057,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
{ {
$iFileSize = $this->FilesProvider()->FileSize($oAccount, $sTempName); $iFileSize = $this->FilesProvider()->FileSize($oAccount, $sTempName);
$oMessage->Attachments()->Add( $oMessage->Attachments()->append(
\MailSo\Mime\Attachment::NewInstance($rResource, $sFileName, $iFileSize, $bIsInline, \MailSo\Mime\Attachment::NewInstance($rResource, $sFileName, $iFileSize, $bIsInline,
\in_array(trim(trim($sCID), '<>'), $aFoundedCids), \in_array(trim(trim($sCID), '<>'), $aFoundedCids),
$sCID, array(), $sContentLocation $sCID, array(), $sContentLocation
@ -5093,7 +5087,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
unset($sRaw); unset($sRaw);
unset($aMatch); unset($aMatch);
$oMessage->Attachments()->Add( $oMessage->Attachments()->append(
\MailSo\Mime\Attachment::NewInstance($rResource, $sFileName, $iFileSize, true, true, $sCID) \MailSo\Mime\Attachment::NewInstance($rResource, $sFileName, $iFileSize, true, true, $sCID)
); );
} }
@ -5101,8 +5095,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
} }
} }
$this->Plugins()->RunHook('filter.build-message', array(&$oMessage)); $this->Plugins()->RunHook('filter.build-message', array($oMessage));
$this->Plugins()->RunHook('filter.build-message[2]', array(&$oMessage, $oAccount)); $this->Plugins()->RunHook('filter.build-message[2]', array($oMessage, $oAccount));
return $oMessage; return $oMessage;
} }
@ -5166,11 +5160,11 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$oMessage->SetTo($oToEmails); $oMessage->SetTo($oToEmails);
} }
$this->Plugins()->RunHook('filter.read-receipt-message-plain', array($oAccount, &$oMessage, &$sText)); $this->Plugins()->RunHook('filter.read-receipt-message-plain', array($oAccount, $oMessage, &$sText));
$oMessage->AddText($sText, false); $oMessage->AddText($sText, false);
$this->Plugins()->RunHook('filter.build-read-receipt-message', array(&$oMessage, $oAccount)); $this->Plugins()->RunHook('filter.build-read-receipt-message', array($oMessage, $oAccount));
return $oMessage; return $oMessage;
} }
@ -5196,8 +5190,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$oMessage = $this->buildMessage($oAccount, true); $oMessage = $this->buildMessage($oAccount, true);
$this->Plugins() $this->Plugins()
->RunHook('filter.save-message', array(&$oMessage)) ->RunHook('filter.save-message', array($oMessage))
->RunHook('filter.save-message[2]', array(&$oMessage, $oAccount)) ->RunHook('filter.save-message[2]', array($oMessage, $oAccount))
; ;
$mResult = false; $mResult = false;
@ -5258,7 +5252,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$this->Plugins()->RunHook('filter.smtp-message-stream', $this->Plugins()->RunHook('filter.smtp-message-stream',
array($oAccount, &$rMessageStream, &$iMessageStreamSize)); array($oAccount, &$rMessageStream, &$iMessageStreamSize));
$this->Plugins()->RunHook('filter.message-rcpt', array($oAccount, &$oRcpt)); $this->Plugins()->RunHook('filter.message-rcpt', array($oAccount, $oRcpt));
try try
{ {
@ -5341,8 +5335,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$oSmtpClient->MailFrom($sFrom, '', $bDsn); $oSmtpClient->MailFrom($sFrom, '', $bDsn);
} }
$aRcpt =& $oRcpt->GetAsArray(); foreach ($oRcpt as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
foreach ($aRcpt as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
{ {
$oSmtpClient->Rcpt($oEmail->GetEmail(), $bDsn); $oSmtpClient->Rcpt($oEmail->GetEmail(), $bDsn);
} }
@ -5421,8 +5414,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$oMessage = $this->buildMessage($oAccount, false); $oMessage = $this->buildMessage($oAccount, false);
$this->Plugins() $this->Plugins()
->RunHook('filter.send-message', array(&$oMessage)) ->RunHook('filter.send-message', array($oMessage))
->RunHook('filter.send-message[2]', array(&$oMessage, $oAccount)) ->RunHook('filter.send-message[2]', array($oMessage, $oAccount))
; ;
$mResult = false; $mResult = false;
@ -5562,8 +5555,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$oToCollection = $oMessage->GetTo(); $oToCollection = $oMessage->GetTo();
if ($oToCollection) if ($oToCollection)
{ {
$aTo =& $oToCollection->GetAsArray(); foreach ($oToCollection as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
foreach ($aTo as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
{ {
$aArrayToFrec[$oEmail->GetEmail(true)] = $oEmail->ToString(false, true); $aArrayToFrec[$oEmail->GetEmail(true)] = $oEmail->ToString(false, true);
} }
@ -5599,7 +5591,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$oMessage = $this->buildReadReceiptMessage($oAccount); $oMessage = $this->buildReadReceiptMessage($oAccount);
$this->Plugins()->RunHook('filter.send-read-receipt-message', array(&$oMessage, $oAccount)); $this->Plugins()->RunHook('filter.send-read-receipt-message', array($oMessage, $oAccount));
$mResult = false; $mResult = false;
try try
@ -6287,8 +6279,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
if ($oMessage instanceof \MailSo\Mail\Message) if ($oMessage instanceof \MailSo\Mail\Message)
{ {
$this->Plugins() $this->Plugins()
->RunHook('filter.result-message', array(&$oMessage)) ->RunHook('filter.result-message', array($oMessage))
->RunHook('filter.result-message[2]', array(&$oMessage, $oAccount)) ->RunHook('filter.result-message[2]', array($oMessage, $oAccount))
; ;
$this->cacheByKey($sRawKey); $this->cacheByKey($sRawKey);
@ -7244,7 +7236,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
return $aValues; return $aValues;
} }
private function rotateImageByOrientation(\Imagine\Image\AbstractImage &$oImage, int $iOrientation) : void private function rotateImageByOrientation(\Imagine\Image\AbstractImage $oImage, int $iOrientation) : void
{ {
if (0 < $iOrientation) if (0 < $iOrientation)
{ {
@ -8144,7 +8136,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
{ {
$mResult['@Object'] = 'Collection/'.$mResult['@Object']; $mResult['@Object'] = 'Collection/'.$mResult['@Object'];
$mResult['@Count'] = $oData->Count(); $mResult['@Count'] = $oData->Count();
$mResult['@Collection'] = $this->responseObject($oData->GetAsArray(), $sParent, $aParameters); $mResult['@Collection'] = $this->responseObject($oData->getArrayCopy(), $sParent, $aParameters);
} }
else else
{ {
@ -8298,55 +8290,24 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
* *
* @return mixed * @return mixed
*/ */
protected $oAccount = null;
protected $aCheckableFolder = null;
protected function responseObject($mResponse, string $sParent = '', array $aParameters = array()) protected function responseObject($mResponse, string $sParent = '', array $aParameters = array())
{ {
$mResult = $mResponse;
if (\is_object($mResponse)) if (\is_object($mResponse))
{ {
$bHook = true; $bHook = true;
$self = $this;
$sClassName = \get_class($mResponse); $sClassName = \get_class($mResponse);
$bHasSimpleJsonFunc = \method_exists($mResponse, 'ToSimpleJSON'); if (\method_exists($mResponse, 'ToSimpleJSON'))
$bThumb = $this->GetCapa(false, false, \RainLoop\Enumerations\Capa::ATTACHMENT_THUMBNAILS);
$oAccountCache = null;
$fGetAccount = function () use ($self, &$oAccountCache) {
if (null === $oAccountCache)
{
$oAccount = $self->getAccountFromToken(false);
$oAccountCache = $oAccount;
}
return $oAccountCache;
};
$aCheckableFoldersCache = null;
$fGetCheckableFolder = function () use ($self, &$aCheckableFoldersCache) {
if (null === $aCheckableFoldersCache)
{
$oAccount = $self->getAccountFromToken(false);
$oSettingsLocal = $self->SettingsProvider(true)->Load($oAccount);
$sCheckable = $oSettingsLocal->GetConf('CheckableFolder', '[]');
$aCheckable = @\json_decode($sCheckable);
if (!\is_array($aCheckable))
{
$aCheckable = array();
}
$aCheckableFoldersCache = $aCheckable;
}
return $aCheckableFoldersCache;
};
if ($bHasSimpleJsonFunc)
{ {
$mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), $mResponse->ToSimpleJSON(true)); $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), $mResponse->ToSimpleJSON(true));
} }
else if ('MailSo\Mail\Message' === $sClassName) else if ('MailSo\Mail\Message' === $sClassName)
{ {
$oAccount = \call_user_func($fGetAccount); if (null === $this->oAccount) {
$this->oAccount = $this->getAccountFromToken(false);
}
$oAccount = $this->oAccount;
$iDateTimeStampInUTC = $mResponse->InternalTimeStampInUTC(); $iDateTimeStampInUTC = $mResponse->InternalTimeStampInUTC();
if (0 === $iDateTimeStampInUTC || !!$this->Config()->Get('labs', 'date_from_headers', false)) if (0 === $iDateTimeStampInUTC || !!$this->Config()->Get('labs', 'date_from_headers', false))
@ -8430,8 +8391,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
if ($oAttachments && 0 < $oAttachments->Count()) if ($oAttachments && 0 < $oAttachments->Count())
{ {
$aList =& $oAttachments->GetAsArray(); foreach ($oAttachments as /* @var \MailSo\Mail\Attachment */ $oAttachment)
foreach ($aList as /* @var \MailSo\Mail\Attachment */ $oAttachment)
{ {
if ($oAttachment) if ($oAttachment)
{ {
@ -8573,7 +8533,9 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
} }
else if ('MailSo\Mail\Attachment' === $sClassName) else if ('MailSo\Mail\Attachment' === $sClassName)
{ {
$oAccount = $this->getAccountFromToken(false); if (null === $this->oAccount) {
$this->oAccount = $this->getAccountFromToken(false);
}
$mFoundedCIDs = isset($aParameters['FoundedCIDs']) && \is_array($aParameters['FoundedCIDs']) && $mFoundedCIDs = isset($aParameters['FoundedCIDs']) && \is_array($aParameters['FoundedCIDs']) &&
0 < \count($aParameters['FoundedCIDs']) ? 0 < \count($aParameters['FoundedCIDs']) ?
@ -8604,7 +8566,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
'CID' => $mResponse->Cid(), 'CID' => $mResponse->Cid(),
'ContentLocation' => $mResponse->ContentLocation(), 'ContentLocation' => $mResponse->ContentLocation(),
'IsInline' => $mResponse->IsInline(), 'IsInline' => $mResponse->IsInline(),
'IsThumbnail' => $bThumb, 'IsThumbnail' => $this->GetCapa(false, false, \RainLoop\Enumerations\Capa::ATTACHMENT_THUMBNAILS),
'IsLinked' => ($mFoundedCIDs && \in_array(\trim(\trim($mResponse->Cid()), '<>'), $mFoundedCIDs)) || 'IsLinked' => ($mFoundedCIDs && \in_array(\trim(\trim($mResponse->Cid()), '<>'), $mFoundedCIDs)) ||
($mFoundedContentLocationUrls && \in_array(\trim($mResponse->ContentLocation()), $mFoundedContentLocationUrls)) ($mFoundedContentLocationUrls && \in_array(\trim($mResponse->ContentLocation()), $mFoundedContentLocationUrls))
)); ));
@ -8618,7 +8580,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$mResult['Download'] = \RainLoop\Utils::EncodeKeyValuesQ(array( $mResult['Download'] = \RainLoop\Utils::EncodeKeyValuesQ(array(
'V' => APP_VERSION, 'V' => APP_VERSION,
'Account' => $oAccount ? \md5($oAccount->Hash()) : '', 'Account' => $this->oAccount ? \md5($this->oAccount->Hash()) : '',
'Folder' => $mResult['Folder'], 'Folder' => $mResult['Folder'],
'Uid' => $mResult['Uid'], 'Uid' => $mResult['Uid'],
'MimeIndex' => $mResult['MimeIndex'], 'MimeIndex' => $mResult['MimeIndex'],
@ -8644,10 +8606,17 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
// ); // );
// } // }
$aCheckableFolder = \call_user_func($fGetCheckableFolder); if (null === $this->aCheckableFolder)
if (!\is_array($aCheckableFolder))
{ {
$aCheckableFolder = array(); if (null === $this->oAccount) {
$this->oAccount = $this->getAccountFromToken(false);
}
$aCheckable = @\json_decode(
$this->SettingsProvider(true)
->Load($this->oAccount)
->GetConf('CheckableFolder', '[]')
);
$this->aCheckableFolder = \is_array($aCheckable) ? $aCheckable : array();
} }
$mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array( $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array(
@ -8661,7 +8630,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
'IsExists' => $mResponse->IsExists(), 'IsExists' => $mResponse->IsExists(),
'IsSelectable' => $mResponse->IsSelectable(), 'IsSelectable' => $mResponse->IsSelectable(),
'Flags' => $mResponse->FlagsLowerCase(), 'Flags' => $mResponse->FlagsLowerCase(),
'Checkable' => \in_array($mResponse->FullNameRaw(), $aCheckableFolder), 'Checkable' => \in_array($mResponse->FullNameRaw(), $this->aCheckableFolder),
'Extended' => $aExtended, 'Extended' => $aExtended,
'SubFolders' => $this->responseObject($mResponse->SubFolders(), $sParent, $aParameters) 'SubFolders' => $this->responseObject($mResponse->SubFolders(), $sParent, $aParameters)
)); ));
@ -8701,20 +8670,28 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$mResponse->SystemFolders : array() $mResponse->SystemFolders : array()
)); ));
} }
else if ('MailSo\Mime\EmailCollection' === $sClassName)
{
$mResult = array();
if (100 < \count($mResponse)) {
$mResponse = $mResponse->Slice(0, 100);
}
foreach ($mResponse as $iKey => $oItem) {
$mResult[$iKey] = $this->responseObject($oItem, $sParent, $aParameters);
}
$bHook = false;
}
else if ($mResponse instanceof \MailSo\Base\Collection) else if ($mResponse instanceof \MailSo\Base\Collection)
{ {
$aList =& $mResponse->GetAsArray(); $mResult = array();
if (100 < \count($aList) && $mResponse instanceof \MailSo\Mime\EmailCollection) foreach ($mResponse as $iKey => $oItem) {
{ $mResult[$iKey] = $this->responseObject($oItem, $sParent, $aParameters);
$aList = \array_slice($aList, 0, 100);
} }
$mResult = $this->responseObject($aList, $sParent, $aParameters);
$bHook = false; $bHook = false;
} }
else else
{ {
$mResult = '["'.\get_class($mResponse).'"]'; $mResult = '["'.$sClassName.'"]';
$bHook = false; $bHook = false;
} }
@ -8732,6 +8709,10 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$mResult = $mResponse; $mResult = $mResponse;
} }
else
{
$mResult = $mResponse;
}
unset($mResponse); unset($mResponse);
return $mResult; return $mResult;

View file

@ -76,7 +76,7 @@ class Contact
$oFullNameProperty = null; $oFullNameProperty = null;
foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\AddressBook\Classes\Property */ &$oProperty) foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\AddressBook\Classes\Property */ $oProperty)
{ {
if ($oProperty) if ($oProperty)
{ {
@ -170,7 +170,7 @@ class Contact
public function GetEmails() : array public function GetEmails() : array
{ {
$aResult = array(); $aResult = array();
foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\AddressBook\Classes\Property */ &$oProperty) foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\AddressBook\Classes\Property */ $oProperty)
{ {
if ($oProperty && $oProperty->IsEmail()) if ($oProperty && $oProperty->IsEmail())
{ {
@ -233,7 +233,7 @@ class Contact
unset($oVCard->FN, $oVCard->EMAIL, $oVCard->TEL, $oVCard->URL, $oVCard->NICKNAME); unset($oVCard->FN, $oVCard->EMAIL, $oVCard->TEL, $oVCard->URL, $oVCard->NICKNAME);
$sUid = $sFirstName = $sLastName = $sMiddleName = $sSuffix = $sPrefix = ''; $sUid = $sFirstName = $sLastName = $sMiddleName = $sSuffix = $sPrefix = '';
foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\AddressBook\Classes\Property */ &$oProperty) foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\AddressBook\Classes\Property */ $oProperty)
{ {
if ($oProperty) if ($oProperty)
{ {
@ -353,7 +353,7 @@ class Contact
$this->UpdateDependentValues(); $this->UpdateDependentValues();
foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\AddressBook\Classes\Property */ &$oProperty) foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\AddressBook\Classes\Property */ $oProperty)
{ {
$iIndex = -1; $iIndex = -1;
if ($oProperty) if ($oProperty)

View file

@ -1152,7 +1152,7 @@ class PdoAddressBook
unset($aFetch); unset($aFetch);
foreach ($aContacts as &$oItem) foreach ($aContacts as $oItem)
{ {
$oItem->UpdateDependentValues(); $oItem->UpdateDependentValues();
} }

View file

@ -9,9 +9,9 @@ class Filters extends \RainLoop\Providers\AbstractProvider
*/ */
private $oDriver; private $oDriver;
public function __construct($oDriver) public function __construct(\RainLoop\Providers\Filters\FiltersInterface $oDriver)
{ {
$this->oDriver = $oDriver instanceof \RainLoop\Providers\Filters\FiltersInterface ? $oDriver : null; $this->oDriver = $oDriver;
} }
public function Load(\RainLoop\Model\Account $oAccount, bool $bAllowRaw = false) : array public function Load(\RainLoop\Model\Account $oAccount, bool $bAllowRaw = false) : array