diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Base/Collection.php b/rainloop/v/0.0.0/app/libraries/MailSo/Base/Collection.php index bfb0200eb..28dd27161 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Base/Collection.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Base/Collection.php @@ -15,48 +15,33 @@ namespace MailSo\Base; * @category MailSo * @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 */ + 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 { - if ($bToTop) - { - \array_unshift($this->aItems, $mItem); - } - else - { - \array_push($this->aItems, $mItem); - } - + $this->append($mItem, $bToTop); return $this; } - /** - * @throws \MailSo\Base\Exceptions\InvalidArgumentException - */ public function AddArray(array $aItems) : self { - if (!\is_array($aItems)) - { - throw new \MailSo\Base\Exceptions\InvalidArgumentException(); - } - foreach ($aItems as $mItem) { - $this->Add($mItem); + $this->append($mItem); } return $this; @@ -64,52 +49,38 @@ abstract class Collection 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 - { - return \count($this->aItems); - } - - public function &GetAsArray() : array - { - return $this->aItems; - } - - /** - * @param mixed $mCallback - */ - public function MapList($mCallback) + public function MapList(callable $cCallback) : 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; } - /** - * @param mixed $mCallback - */ - public function FilterList($mCallback) : array + public function FilterList(callable $cCallback) : 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; } @@ -119,45 +90,14 @@ abstract class Collection return $aResult; } - /** - * @param mixed $mCallback - */ - public function ForeachList($mCallback) : void + public function ForeachList(callable $cCallback) : 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; - } } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Base/HtmlUtils.php b/rainloop/v/0.0.0/app/libraries/MailSo/Base/HtmlUtils.php index d1b0377a9..04fd353c2 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Base/HtmlUtils.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Base/HtmlUtils.php @@ -50,9 +50,9 @@ abstract class HtmlUtils $sHtmlAttrs = $sBodyAttrs = ''; - $sText = \MailSo\Base\HtmlUtils::FixSchemas($sText); - $sText = \MailSo\Base\HtmlUtils::ClearFastTags($sText); - $sText = \MailSo\Base\HtmlUtils::ClearBodyAndHtmlTag($sText, $sHtmlAttrs, $sBodyAttrs); + $sText = static::FixSchemas($sText); + $sText = static::ClearFastTags($sText); + $sText = static::ClearBodyAndHtmlTag($sText, $sHtmlAttrs, $sBodyAttrs); $oDom = self::createDOMDocument(); @$oDom->loadHTML('<'.'?xml version="1.0" encoding="utf-8"?'.'>'. @@ -117,60 +117,7 @@ abstract class HtmlUtils return \trim($sResult); } - 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) + public static function GetTextFromDom(\DOMDocument $oDom, bool $bWrapByFakeHtmlAndBodyDiv = true) : string { $sResult = ''; @@ -184,8 +131,8 @@ abstract class HtmlUtils if ($bWrapByFakeHtmlAndBodyDiv) { - $aHtmlAttrs = \MailSo\Base\HtmlUtils::GetElementAttributesAsArray($oHtml); - $aBodylAttrs = \MailSo\Base\HtmlUtils::GetElementAttributesAsArray($oBody); + $aHtmlAttrs = static::GetElementAttributesAsArray($oHtml); + $aBodylAttrs = static::GetElementAttributesAsArray($oBody); $oWrapHtml = $oDom->createElement('div'); $oWrapHtml->setAttribute('data-x-div-type', 'html'); @@ -208,7 +155,7 @@ abstract class HtmlUtils $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); return $sResult; @@ -269,10 +216,7 @@ abstract class HtmlUtils ), '', $sHtml); } - /** - * @param mixed $oDom - */ - public static function ClearComments(&$oDom) + public static function ClearComments(\DOMDocument $oDom) : void { $aRemove = array(); @@ -297,10 +241,7 @@ abstract class HtmlUtils } } - /** - * @param mixed $oDom - */ - public static function ClearTags(&$oDom, bool $bClearStyleAndHead = true) + public static function ClearTags(\DOMDocument $oDom, bool $bClearStyleAndHead = true) : void { $aRemoveTags = array( '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 */ @@ -696,7 +414,7 @@ abstract class HtmlUtils return \implode(';', $aOutStyles); } - public static function FindLinksInDOM(\DOMDocument $oDom) + public static function FindLinksInDOM(\DOMDocument $oDom) : void { $aNodes = $oDom->getElementsByTagName('*'); foreach ($aNodes as /* @var $oElement \DOMElement */ $oElement) @@ -734,7 +452,7 @@ abstract class HtmlUtils ->CompileText() ; - $oSubDom = \MailSo\Base\HtmlUtils::GetDomFromText($sText); + $oSubDom = static::GetDomFromText($sText); if ($oSubDom) { $oBodyNodes = $oSubDom->getElementsByTagName('body'); @@ -752,7 +470,7 @@ abstract class HtmlUtils 'a' === \strtolower($oSubItem->tagName)) { $oLink = $oDom->createElement('a', - \str_replace(':', \MailSo\Base\HtmlUtils::$KOS, \htmlspecialchars($oSubItem->nodeValue))); + \str_replace(':', static::$KOS, \htmlspecialchars($oSubItem->nodeValue))); $sHref = $oSubItem->getAttribute('href'); if ($sHref) @@ -795,7 +513,7 @@ abstract class HtmlUtils $fAdditionalDomReader = null; $bTryToDetectHiddenImages = false; - return \MailSo\Base\HtmlUtils::ClearHtml($sHtml, $bHasExternals, $aFoundCIDs, + return static::ClearHtml($sHtml, $bHasExternals, $aFoundCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, $bDoNotReplaceExternalUrl, $bFindLinksInHtml, $fAdditionalExternalFilter, $fAdditionalDomReader, $bTryToDetectHiddenImages, $bWrapByFakeHtmlAndBodyDiv); @@ -833,7 +551,7 @@ abstract class HtmlUtils $bHasExternals = false; // Dom Part - $oDom = \MailSo\Base\HtmlUtils::GetDomFromText($sHtml); + $oDom = static::GetDomFromText($sHtml); unset($sHtml); if (!$oDom) @@ -854,11 +572,11 @@ abstract class HtmlUtils if ($bFindLinksInHtml) { - \MailSo\Base\HtmlUtils::FindLinksInDOM($oDom); + static::FindLinksInDOM($oDom); } - \MailSo\Base\HtmlUtils::ClearComments($oDom); - \MailSo\Base\HtmlUtils::ClearTags($oDom); + static::ClearComments($oDom); + static::ClearTags($oDom); $sLinkColor = ''; $aNodes = $oDom->getElementsByTagName('*'); @@ -1151,7 +869,7 @@ abstract class HtmlUtils if ($oElement->hasAttribute('style') && !$oElement->hasAttribute('data-x-skip-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)); } @@ -1170,7 +888,7 @@ abstract class HtmlUtils } } - $sResult = \MailSo\Base\HtmlUtils::GetTextFromDom($oDom, $bWrapByFakeHtmlAndBodyDiv); + $sResult = static::GetTextFromDom($oDom, $bWrapByFakeHtmlAndBodyDiv); unset($oDom); return $sResult; @@ -1178,9 +896,9 @@ abstract class HtmlUtils 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); $aNodes = $oDom->getElementsByTagName('*'); @@ -1304,7 +1022,7 @@ abstract class HtmlUtils } } - $sResult = \MailSo\Base\HtmlUtils::GetTextFromDom($oDom, false); + $sResult = static::GetTextFromDom($oDom, false); unset($oDom); return ''. diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php index 5145dc084..fd6e7778c 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/BodyStructure.php @@ -376,7 +376,7 @@ class BodyStructure 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)); } @@ -412,7 +412,7 @@ class BodyStructure 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); if (null !== $oPart) @@ -741,7 +741,7 @@ class BodyStructure $aDispositionParams = self::getKeyValueListFromArrayList($aDispParamList); if (\is_array($aDispositionParams)) { - $sFileName = self::decodeAttrParamenter($aDispositionParams, 'filename', $sCharset); + $sFileName = self::decodeAttrParamenter($aDispositionParams, 'filename', $sCharset ?: ''); } } } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/FetchResponse.php b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/FetchResponse.php index 8e7a49e53..01a6cf2c1 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/FetchResponse.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/FetchResponse.php @@ -79,7 +79,7 @@ class FetchResponse if (0 < strlen($sLocalPart) && 0 < strlen($sDomainPart)) { - $oResult->Add( + $oResult->append( \MailSo\Mime\Email::NewInstance($sLocalPart.'@'.$sDomainPart, $sDisplayName) ); } @@ -172,7 +172,7 @@ class FetchResponse return $sReturn; } - private static function findFetchUidAndSize(array $aList) + private static function findFetchUidAndSize(array $aList) : bool { $bUid = false; $bSize = false; diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php index 17a77ad83..0e1a58406 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php @@ -562,7 +562,7 @@ class ImapClient extends \MailSo\Net\NetClient $sFolderNameRaw = $oImapResponse->ResponseList[2]; $oCurrentFolder = null; - foreach ($aReturn as &$oFolder) + foreach ($aReturn as $oFolder) { if ($oFolder && $sFolderNameRaw === $oFolder->FullNameRaw()) { diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/File.php b/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/File.php index a289c05db..ae24e5161 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/File.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/File.php @@ -23,7 +23,7 @@ class File extends \MailSo\Log\Driver */ private $sLoggerFileName; - protected function __construct($sLoggerFileName, $sNewLine = "\r\n") + protected function __construct(string $sLoggerFileName, string $sNewLine = "\r\n") { parent::__construct(); diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/Inline.php b/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/Inline.php index f1f536860..731896d29 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/Inline.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Log/Drivers/Inline.php @@ -23,7 +23,7 @@ class Inline extends \MailSo\Log\Driver */ private $bHtmlEncodeSpecialChars; - protected function __construct($sNewLine = "\r\n", $bHtmlEncodeSpecialChars = false) + protected function __construct(string $sNewLine = "\r\n", bool $bHtmlEncodeSpecialChars = false) { parent::__construct(); diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Log/Logger.php b/rainloop/v/0.0.0/app/libraries/MailSo/Log/Logger.php index 9d83c4433..a325ba458 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Log/Logger.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Log/Logger.php @@ -42,7 +42,7 @@ class Logger extends \MailSo\Base\Collection */ private $bHideErrorNotices; - protected function __construct($bRegPhpErrorHandler = true) + protected function __construct(bool $bRegPhpErrorHandler = true) { parent::__construct(); @@ -208,10 +208,9 @@ class Logger extends \MailSo\Base\Collection { $iResult = 1; - $aLoggers =& $this->GetAsArray(); - foreach ($aLoggers as /* @var $oLogger \MailSo\Log\Driver */ &$oLogger) + foreach ($this as /* @var $oLogger \MailSo\Log\Driver */ $oLogger) { - $iResult &= $oLogger->WriteEmptyLine(); + $iResult = $oLogger->WriteEmptyLine(); } return (bool) $iResult; @@ -236,10 +235,9 @@ class Logger extends \MailSo\Base\Collection $sDesc = \str_replace($this->aSecretWords, '*******', $sDesc); } - $aLoggers =& $this->GetAsArray(); - foreach ($aLoggers as /* @var $oLogger \MailSo\Log\Driver */ $oLogger) + foreach ($this as /* @var $oLogger \MailSo\Log\Driver */ $oLogger) { - $iResult &= $oLogger->Write($sDesc, $iType, $sName, $bDiplayCrLf); + $iResult = $oLogger->Write($sDesc, $iType, $sName, $bDiplayCrLf); } return (bool) $iResult; diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/AttachmentCollection.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/AttachmentCollection.php index 515672c23..7f9c69c59 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/AttachmentCollection.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/AttachmentCollection.php @@ -22,7 +22,7 @@ class AttachmentCollection extends \MailSo\Base\Collection parent::__construct(); } - public static function NewInstance() : \MailSo\Mail\AttachmentCollection + public static function NewInstance() : self { return new self(); } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/FolderCollection.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/FolderCollection.php index 5f1f9a740..6b6be0c22 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/FolderCollection.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/FolderCollection.php @@ -61,7 +61,7 @@ class FolderCollection extends \MailSo\Base\Collection public function GetByFullNameRaw(string $sFullNameRaw) : ?\MailSo\Mail\Folder { $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) { @@ -88,7 +88,7 @@ class FolderCollection extends \MailSo\Base\Collection public function CountRec() : int { $iResult = $this->Count(); - foreach ($this->aItems as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder) + foreach ($this as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder) { if ($oFolder) { @@ -110,9 +110,9 @@ class FolderCollection extends \MailSo\Base\Collection $sDelimiter = '/'; $oFolder = $this->GetByFullNameRaw('INBOX'); - if (!$oFolder) + if (!$oFolder && isset($this[0])) { - $oFolder = $this->GetByIndex(0); + $oFolder = $this[0]; } if ($oFolder) @@ -123,7 +123,7 @@ class FolderCollection extends \MailSo\Base\Collection return $sDelimiter; } - public function SetNamespace(string $sNamespace) : \MailSo\Mail\FolderCollection + public function SetNamespace(string $sNamespace) : self { $this->Namespace = $sNamespace; @@ -135,7 +135,7 @@ class FolderCollection extends \MailSo\Base\Collection $this->Clear(); $aSortedByLenImapFolders = array(); - foreach ($aUnsortedMailFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ &$oMailFolder) + foreach ($aUnsortedMailFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ $oMailFolder) { $aSortedByLenImapFolders[$oMailFolder->FullNameRaw()] =& $oMailFolder; unset($oMailFolder); @@ -181,7 +181,7 @@ class FolderCollection extends \MailSo\Base\Collection 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); unset($oMailFolder); @@ -194,9 +194,8 @@ class FolderCollection extends \MailSo\Base\Collection { $oItemFolder = null; $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 && 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) { $bIsAdded = true; - $this->Add($oMailFolder); + $this->append($oMailFolder); } return $bIsAdded; } - /** - * @param callable $fCallback - */ - public function SortByCallback($fCallback) : void + public function SortByCallback(callable $fCallback) : void { if (\is_callable($fCallback)) { - $aList =& $this->GetAsArray(); + $aList = $this->getArrayCopy(); \usort($aList, $fCallback); - foreach ($aList as &$oItemFolder) + foreach ($aList as $oItemFolder) { if ($oItemFolder->HasSubFolders()) { diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php index 41153328d..c1d2a92ff 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php @@ -1502,7 +1502,7 @@ class MailClient { $aFetchIndexArray = array(); $oFetchResponseItem = null; - foreach ($aFetchResponse as /* @var $oFetchResponseItem \MailSo\Imap\FetchResponse */ &$oFetchResponseItem) + foreach ($aFetchResponse as /* @var $oFetchResponseItem \MailSo\Imap\FetchResponse */ $oFetchResponseItem) { $aFetchIndexArray[($bIndexAsUid) ? $oFetchResponseItem->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID) @@ -1515,7 +1515,7 @@ class MailClient { if (isset($aFetchIndexArray[$iFUid])) { - $oMessageCollection->Add( + $oMessageCollection->append( Message::NewFetchResponseInstance( $oMessageCollection->FolderName, $aFetchIndexArray[$iFUid])); } @@ -1534,28 +1534,6 @@ class MailClient $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\Net\Exceptions\Exception diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/Message.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/Message.php index d44cde667..7b1a17815 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/Message.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/Message.php @@ -742,7 +742,7 @@ class Message $this->oAttachments = AttachmentCollection::NewInstance(); foreach ($aAttachmentsParts as /* @var $oAttachmentItem \MailSo\Imap\BodyStructure */ $oAttachmentItem) { - $this->oAttachments->Add( + $this->oAttachments->append( \MailSo\Mail\Attachment::NewBodyStructureInstance($this->sFolder, $this->iUid, $oAttachmentItem) ); } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Attachment.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Attachment.php index 4974fc335..686830076 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Attachment.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Attachment.php @@ -57,8 +57,8 @@ class Attachment */ private $sContentLocation; - private function __construct($rResource, $sFileName, $iFileSize, $bIsInline, $bIsLinked, $sCID, - $aCustomContentTypeParams = array(), $sContentLocation = '') + private function __construct($rResource, string $sFileName, int $iFileSize, bool $bIsInline, bool $bIsLinked, string $sCID, + array $aCustomContentTypeParams = array(), string $sContentLocation = '') { $this->rResource = $rResource; $this->sFileName = $sFileName; diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Email.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Email.php index 778934057..1bd8c9653 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Email.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Email.php @@ -40,7 +40,7 @@ class Email /** * @throws \MailSo\Base\Exceptions\InvalidArgumentException */ - private function __construct($sEmail, $sDisplayName = '') + private function __construct(string $sEmail, string $sDisplayName = '') { if (!\MailSo\Base\Validator::NotEmptyString($sEmail, true)) { diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/EmailCollection.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/EmailCollection.php index 9a8b86771..5d3151c80 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/EmailCollection.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/EmailCollection.php @@ -17,7 +17,7 @@ namespace MailSo\Mime; */ class EmailCollection extends \MailSo\Base\Collection { - protected function __construct($sEmailAddresses = '') + protected function __construct(string $sEmailAddresses = '') { parent::__construct(); @@ -40,9 +40,8 @@ class EmailCollection extends \MailSo\Base\Collection public function ToArray() : array { - $aReturn = $aEmails = array(); - $aEmails =& $this->GetAsArray(); - foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) + $aReturn = array(); + foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) { $aReturn[] = $oEmail->ToArray(); } @@ -52,10 +51,9 @@ class EmailCollection extends \MailSo\Base\Collection public function MergeWithOtherCollection(EmailCollection $oEmails) : self { - $aEmails =& $oEmails->GetAsArray(); - foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) + foreach ($oEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) { - $this->Add($oEmail); + $this->append($oEmail); } return $this; @@ -63,30 +61,26 @@ class EmailCollection extends \MailSo\Base\Collection public function Unique() : self { - $aCache = array(); $aReturn = array(); - $aEmails =& $this->GetAsArray(); - foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) + foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) { $sEmail = $oEmail->GetEmail(); - if (!isset($aCache[$sEmail])) + if (!isset($aReturn[$sEmail])) { - $aCache[$sEmail] = true; - $aReturn[] = $oEmail; + $aReturn[$sEmail] = $oEmail; } } - $this->SetAsArray($aReturn); + $this->exchangeArray(array_values($aReturn)); return $this; } public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string { - $aReturn = $aEmails = array(); - $aEmails =& $this->GetAsArray(); - foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) + $aReturn = array(); + foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) { $aReturn[] = $oEmail->ToString($bConvertSpecialsName, $bIdn); } @@ -174,7 +168,7 @@ class EmailCollection extends \MailSo\Base\Collection try { - $this->Add( + $this->append( \MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iEmailEndPos - $iEmailStartPos)) ); @@ -194,7 +188,7 @@ class EmailCollection extends \MailSo\Base\Collection { try { - $this->Add( + $this->append( \MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iCurrentPos - $iEmailStartPos)) ); } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/EmailDep.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/EmailDep.php index 6f1a374fc..39523e937 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/EmailDep.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/EmailDep.php @@ -46,7 +46,7 @@ class EmailDep /** * @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)) { diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Header.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Header.php index d114f2450..519ac51c6 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Header.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Header.php @@ -47,7 +47,7 @@ class Header */ private $sParentCharset; - private function __construct($sName, $sValue, $sEncodedValueForReparse, $sParentCharset = '') + private function __construct(string $sName, string $sValue, string $sEncodedValueForReparse, string $sParentCharset = '') { $this->sParentCharset = $sParentCharset; diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/HeaderCollection.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/HeaderCollection.php index 9976fc54b..bf44ec3ab 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/HeaderCollection.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/HeaderCollection.php @@ -21,11 +21,11 @@ class HeaderCollection extends \MailSo\Base\Collection protected $sRawHeaders; /** - * @var strign + * @var string */ protected $sParentCharset; - protected function __construct($sRawHeaders = '', $bStoreRawHeaders = true) + protected function __construct(string $sRawHeaders = '', bool $bStoreRawHeaders = true) { 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); } - /** - * @throws \MailSo\Base\Exceptions\InvalidArgumentException - */ - public function AddByName(string $sName, string $sValue, bool $bToTop = false) : \MailSo\Mime\HeaderCollection + public function AddByName(string $sName, string $sValue, bool $bToTop = false) : self { - return $this->Add(Header::NewInstance($sName, $sValue), $bToTop); + $this->append(Header::NewInstance($sName, $sValue), $bToTop); + return $this; } - /** - * @throws \MailSo\Base\Exceptions\InvalidArgumentException - */ - public function SetByName(string $sName, string $sValue, bool $bToTop = false) : \MailSo\Mime\HeaderCollection + public function SetByName(string $sName, string $sValue, bool $bToTop = false) : self { 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 { - $oHeader = null; - $oHeader =& $this->GetByName($sHeaderName); - return (null !== $oHeader) ? ($bCharsetAutoDetect ? $oHeader->ValueWithCharsetAutoDetect() : $oHeader->Value()) : ''; + $oHeader = $this->GetByName($sHeaderName); + return $oHeader ? ($bCharsetAutoDetect ? $oHeader->ValueWithCharsetAutoDetect() : $oHeader->Value()) : ''; } public function ValuesByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : array { $aResult = array(); - $oHeader = null; $sHeaderNameLower = \strtolower($sHeaderName); - $aHeaders =& $this->GetAsArray(); - foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader) + foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader) { if ($sHeaderNameLower === \strtolower($oHeader->Name())) { @@ -91,12 +76,12 @@ class HeaderCollection extends \MailSo\Base\Collection return $aResult; } - public function RemoveByName(string $sHeaderName) : \MailSo\Mime\HeaderCollection + public function RemoveByName(string $sHeaderName) : self { - $aResult = $this->FilterList(function ($oHeader) use ($sHeaderName) { - return $oHeader && \strtolower($oHeader->Name()) !== \strtolower($sHeaderName); - }); - $this->SetAsArray($aResult); + $sHeaderName = \strtolower($sHeaderName); + $this->exchangeArray(array_filter($this->getArrayCopy(), function ($oHeader) use ($sHeaderName) { + return $oHeader && \strtolower($oHeader->Name()) !== $sHeaderName; + })); return $this; } @@ -114,14 +99,8 @@ class HeaderCollection extends \MailSo\Base\Collection public function ParametersByName(string $sHeaderName) : ?\MailSo\Mime\ParameterCollection { - $oParameters = $oHeader = null; - $oHeader =& $this->GetByName($sHeaderName); - if ($oHeader) - { - $oParameters = $oHeader->Parameters(); - } - - return $oParameters; + $oHeader = $this->GetByName($sHeaderName); + return $oHeader ? $oHeader->Parameters() : null; } public function ParameterValue(string $sHeaderName, string $sParamName) : string @@ -130,34 +109,27 @@ class HeaderCollection extends \MailSo\Base\Collection 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); - $aHeaders =& $this->GetAsArray(); - foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader) + foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader) { if ($sHeaderNameLower === \strtolower($oHeader->Name())) { - $oResult =& $oHeader; - break; + return $oHeader; } } - return $oResult; + return null; } - public function SetParentCharset(string $sParentCharset) : \MailSo\Mime\HeaderCollection + public function SetParentCharset(string $sParentCharset) : self { if (0 < \strlen($sParentCharset)) { if ($this->sParentCharset !== $sParentCharset) { - $oHeader = null; - $aHeaders =& $this->GetAsArray(); - - foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader) + foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader) { $oHeader->SetParentCharset($sParentCharset); } @@ -171,12 +143,11 @@ class HeaderCollection extends \MailSo\Base\Collection public function Clear() : void { - parent::Clear(); - + $this->exchangeArray(array()); $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(); @@ -236,7 +207,7 @@ class HeaderCollection extends \MailSo\Base\Collection $oHeader = Header::NewInstanceFromEncodedString($sName.': '.$sValue, $this->sParentCharset); if ($oHeader) { - $this->Add($oHeader); + $this->append($oHeader); } $sName = null; @@ -259,7 +230,7 @@ class HeaderCollection extends \MailSo\Base\Collection $oHeader = Header::NewInstanceFromEncodedString($sName.': '.$sValue, $this->sParentCharset); if ($oHeader) { - $this->Add($oHeader); + $this->append($oHeader); } } @@ -370,8 +341,7 @@ class HeaderCollection extends \MailSo\Base\Collection public function ToEncodedString() : string { $aResult = array(); - $aHeaders =& $this->GetAsArray(); - foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader) + foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader) { $aResult[] = $oHeader->EncodedValue(); } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Message.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Message.php index a78019056..d96f4a335 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Message.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Message.php @@ -402,14 +402,14 @@ class Message \MailSo\Mime\Enumerations\Parameter::FILENAME, $sFileName)); } - $oAttachmentPart->Headers->Add( + $oAttachmentPart->Headers->append( Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, $oAttachment->ContentType().';'. (($oContentTypeParameters) ? ' '.$oContentTypeParameters->ToString() : '') ) ); - $oAttachmentPart->Headers->Add( + $oAttachmentPart->Headers->append( Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_DISPOSITION, ($oAttachment->IsInline() ? 'inline' : 'attachment').';'. (($oContentDispositionParameters) ? ' '.$oContentDispositionParameters->ToString() : '') @@ -418,14 +418,14 @@ class Message if (0 < strlen($sCID)) { - $oAttachmentPart->Headers->Add( + $oAttachmentPart->Headers->append( Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_ID, $sCID) ); } if (0 < strlen($sContentLocation)) { - $oAttachmentPart->Headers->Add( + $oAttachmentPart->Headers->append( Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_LOCATION, $sContentLocation) ); } @@ -434,7 +434,7 @@ class Message if ('message/rfc822' !== strtolower($oAttachment->ContentType())) { - $oAttachmentPart->Headers->Add( + $oAttachmentPart->Headers->append( Header::NewInstance( \MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING, \MailSo\Base\Enumerations\Encoding::BASE64_LOWER @@ -466,7 +466,7 @@ class Message { $oAlternativePart = Part::NewInstance(); $oParameters = ParameterCollection::NewInstance(); - $oParameters->Add( + $oParameters->append( Parameter::NewInstance( \MailSo\Mime\Enumerations\Parameter::CHARSET, \MailSo\Base\Enumerations\Charset::UTF_8) @@ -476,11 +476,11 @@ class Message { 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, $aAlternativeData[0].'; '.$oParameters->ToString()) ); @@ -501,7 +501,7 @@ class Message if (isset($aAlternativeData[2]) && 0 < strlen($aAlternativeData[2])) { - $oAlternativePart->Headers->Add( + $oAlternativePart->Headers->append( Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING, $aAlternativeData[2] ) @@ -538,7 +538,7 @@ class Message { $oResultPart = Part::NewInstance(); - $oResultPart->Headers->Add( + $oResultPart->Headers->append( Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, \MailSo\Mime\Enumerations\MimeType::MULTIPART_ALTERNATIVE.'; '. ParameterCollection::NewInstance()->Add( @@ -554,7 +554,7 @@ class Message $oAlternativePart = $this->createNewMessageAlternativePartBody($aAlternativeData); if ($oAlternativePart) { - $oResultPart->SubParts->Add($oAlternativePart); + $oResultPart->SubParts->append($oAlternativePart); } unset($oAlternativePart); @@ -580,7 +580,7 @@ class Message } else { - $aAttachments = $this->oAttachmentCollection->CloneAsArray(); + $aAttachments = $this->oAttachmentCollection->getArrayCopy(); if (\is_array($aAttachments) && 1 === count($aAttachments) && isset($aAttachments[0])) { $this->oAttachmentCollection->Clear(); @@ -605,7 +605,7 @@ class Message { $oResultPart = Part::NewInstance(); - $oResultPart->Headers->Add( + $oResultPart->Headers->append( Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, \MailSo\Mime\Enumerations\MimeType::MULTIPART_RELATED.'; '. ParameterCollection::NewInstance()->Add( @@ -616,11 +616,11 @@ class Message ) ); - $oResultPart->SubParts->Add($oIncPart); + $oResultPart->SubParts->append($oIncPart); foreach ($aAttachments as $oAttachment) { - $oResultPart->SubParts->Add($this->createNewMessageAttachmentBody($oAttachment)); + $oResultPart->SubParts->append($this->createNewMessageAttachmentBody($oAttachment)); } } else @@ -649,11 +649,11 @@ class Message )->ToString() ); - $oResultPart->SubParts->Add($oIncPart); + $oResultPart->SubParts->append($oIncPart); foreach ($aAttachments as $oAttachment) { - $oResultPart->SubParts->Add($this->createNewMessageAttachmentBody($oAttachment)); + $oResultPart->SubParts->append($this->createNewMessageAttachmentBody($oAttachment)); } } else diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Parameter.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Parameter.php index b1c0561bc..6c71eab63 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Parameter.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Parameter.php @@ -27,7 +27,7 @@ class Parameter */ private $sValue; - private function __construct($sName, $sValue) + private function __construct(string $sName, string $sValue) { $this->sName = $sName; $this->sValue = $sValue; diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/ParameterCollection.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/ParameterCollection.php index f8ba5b7b4..2af9e70ae 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/ParameterCollection.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/ParameterCollection.php @@ -17,7 +17,7 @@ namespace MailSo\Mime; */ class ParameterCollection extends \MailSo\Base\Collection { - protected function __construct($sRawParams = '') + protected function __construct(string $sRawParams = '') { parent::__construct(); @@ -32,29 +32,19 @@ class ParameterCollection extends \MailSo\Base\Collection 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 { - $sResult = ''; - $sName = \trim($sName); + $sName = \strtolower(\trim($sName)); - $aParams =& $this->GetAsArray(); - foreach ($aParams as /* @var $oParam \MailSo\Mime\ParameterCollection */ $oParam) + foreach ($this as /* @var $oParam \MailSo\Mime\ParameterCollection */ $oParam) { - if (\strtolower($sName) === \strtolower($oParam->Name())) + if ($sName === \strtolower($oParam->Name())) { - $sResult = $oParam->Value(); - break; + return $oParam->Value(); } } - return $sResult; + return ''; } public function Parse(string $sRawParams) : self @@ -65,7 +55,7 @@ class ParameterCollection extends \MailSo\Base\Collection foreach ($aDataToParse as $sParam) { - $this->Add(Parameter::CreateFromParameterLine($sParam)); + $this->append(Parameter::CreateFromParameterLine($sParam)); } $this->reParseParameters(); @@ -76,8 +66,7 @@ class ParameterCollection extends \MailSo\Base\Collection public function ToString(bool $bConvertSpecialsName = false) : string { $aResult = array(); - $aParams =& $this->GetAsArray(); - foreach ($aParams as /* @var $oParam \MailSo\Mime\Parameter */ $oParam) + foreach ($this as /* @var $oParam \MailSo\Mime\Parameter */ $oParam) { $sLine = $oParam->ToString($bConvertSpecialsName); if (0 < \strlen($sLine)) @@ -91,7 +80,7 @@ class ParameterCollection extends \MailSo\Base\Collection private function reParseParameters() : void { - $aDataToReParse = $this->CloneAsArray(); + $aDataToReParse = $this->getArrayCopy(); $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8; $this->Clear(); @@ -146,7 +135,7 @@ class ParameterCollection extends \MailSo\Base\Collection } else { - $this->Add($oParam); + $this->append($oParam); } } @@ -162,7 +151,7 @@ class ParameterCollection extends \MailSo\Base\Collection $sCharset, \MailSo\Base\Enumerations\Charset::UTF_8); } - $this->Add(Parameter::NewInstance($sName, $sResult)); + $this->append(Parameter::NewInstance($sName, $sResult)); } } } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Part.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Part.php index e30c01aab..200284a4c 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Part.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/Part.php @@ -262,7 +262,7 @@ class Part $sPrevBuffer, $sBuffer, $aBoundaryStack, $bIsOef); $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(); if (0 < strlen($sCharset)) @@ -275,7 +275,7 @@ class Part $sForceCharset = self::$ForceCharset; 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->Headers->SetParentCharset($sForceCharset); @@ -286,7 +286,7 @@ class Part $sFirstNotNullCharset = (null !== $sFirstNotNullCharset) ? $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(); $oMimePart->SetParentCharset((0 < strlen($sHeaderCharset)) ? $sHeaderCharset : $sFirstNotNullCharset); @@ -302,7 +302,7 @@ class Part /** * @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 { $oCallbackClass->StartParseMimePart($this); @@ -496,7 +496,7 @@ class Part ->ParseFromStreamRecursion($rStreamHandle, $oCallbackClass, $iOffset, $sPrevBuffer, $sBuffer, $aBoundaryStack, $bIsOef, true); - $this->SubParts->Add($oSubPart); + $this->SubParts->append($oSubPart); $this->LineParts[] =& $oSubPart; //$iParsePosition = self::POS_HEADERS; unset($oSubPart); diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/PartCollection.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/PartCollection.php index 87fe0a21a..c98a8b7d8 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mime/PartCollection.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mime/PartCollection.php @@ -37,8 +37,7 @@ class PartCollection extends \MailSo\Base\Collection { $aResult = array(); - $aParts =& $this->GetAsArray(); - foreach ($aParts as /* @var $oPart \MailSo\Mime\Part */ &$oPart) + foreach ($this as /* @var $oPart \MailSo\Mime\Part */ $oPart) { if (0 < count($aResult)) { diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Net/Exceptions/SocketCanNotConnectToHostException.php b/rainloop/v/0.0.0/app/libraries/MailSo/Net/Exceptions/SocketCanNotConnectToHostException.php index eaf233965..93350837c 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Net/Exceptions/SocketCanNotConnectToHostException.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Net/Exceptions/SocketCanNotConnectToHostException.php @@ -28,10 +28,7 @@ class SocketCanNotConnectToHostException extends \MailSo\Net\Exceptions\Connecti */ private $iSocketCode; - /** - * @param \Exception $oPrevious = null - */ - public function __construct($sSocketMessage = '', $iSocketCode = 0, $sMessage = '', $iCode = 0, $oPrevious = null) + public function __construct(string $sSocketMessage = '', int $iSocketCode = 0, string $sMessage = '', int $iCode = 0, ?\Throwable $oPrevious = null) { parent::__construct($sMessage, $iCode, $oPrevious); diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Sieve/Exceptions/ResponseException.php b/rainloop/v/0.0.0/app/libraries/MailSo/Sieve/Exceptions/ResponseException.php index 8c742de31..62bca4073 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Sieve/Exceptions/ResponseException.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Sieve/Exceptions/ResponseException.php @@ -23,10 +23,7 @@ class ResponseException extends \MailSo\Sieve\Exceptions\Exception */ private $aResponses; - /** - * @param \Exception $oPrevious = null - */ - public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null) + public function __construct(array $aResponses = array(), string $sMessage = '', int $iCode = 0, ?\Throwable $oPrevious = null) { parent::__construct($sMessage, $iCode, $oPrevious); diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/Exceptions/ResponseException.php b/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/Exceptions/ResponseException.php index f113fe05c..9ed6dadec 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/Exceptions/ResponseException.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/Exceptions/ResponseException.php @@ -23,10 +23,7 @@ class ResponseException extends \MailSo\Smtp\Exceptions\Exception */ private $aResponses; - /** - * @param \Exception $oPrevious = null - */ - public function __construct($aResponses = array(), $sMessage = '', $iCode = 0, $oPrevious = null) + public function __construct(array $aResponses = array(), string $sMessage = '', int $iCode = 0, ?\Throwable $oPrevious = null) { parent::__construct($sMessage, $iCode, $oPrevious); diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 407764132..a152fa79d 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -146,7 +146,7 @@ class Actions $this->bIsAjax = false; $oConfig = $this->Config(); - $this->Plugins()->RunHook('filter.application-config', array(&$oConfig)); + $this->Plugins()->RunHook('filter.application-config', array($oConfig)); $this->Logger()->Ping(); } @@ -907,7 +907,7 @@ class Actions $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)) ->WriteOnPhpErrorOnly($this->Config()->Get('logs', 'write_on_php_error_only', false)) ->WriteOnTimeoutOnly($this->Config()->Get('logs', 'write_on_timeout_only', 0)) @@ -981,7 +981,7 @@ class Actions $oDriver->DisableGuidPrefix(); $oDriver->DisableTypedPrefix(); - $this->oLoggerAuth->Add($oDriver); + $this->oLoggerAuth->append($oDriver); } } @@ -1058,7 +1058,7 @@ class Actions if ($oDomain->ValidateWhiteList($sEmail, $sLogin)) { $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)) { @@ -1885,7 +1885,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack 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)) { @@ -4268,9 +4268,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $aResult = array(); if ($oFolders) { - $aFolders =& $oFolders->GetAsArray(); - - foreach ($aFolders as $oFolder) + foreach ($oFolders as $oFolder) { $aResult[] = $oFolder->FullNameRaw()."|". 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 { - if ($oFolders) + if ($oFolders && $oFolders->Count()) { - $aFolders =& $oFolders->GetAsArray(); - if (\is_array($aFolders) && 0 < \count($aFolders)) + if ($bListFolderTypes) { - 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(); - 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); - } + $aResult[$iFolderListType] = $oFolder->FullNameRaw(); } } - $aMap = $this->systemFoldersNames($oAccount); - 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) + foreach ($oFolders as $oFolder) { $oSub = $oFolder->SubFolders(); 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(); $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); @@ -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) { @@ -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); } @@ -5038,12 +5032,12 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack \MailSo\Base\HtmlUtils::BuildHtml($sText, $aFoundedCids, $mFoundDataURL, $aFoundedContentLocationUrls) : $sText; $this->Plugins()->RunHook($bTextIsHtml ? 'filter.message-html' : 'filter.message-plain', - array($oAccount, &$oMessage, &$sTextToAdd)); + array($oAccount, $oMessage, &$sTextToAdd)); if ($bTextIsHtml && 0 < \strlen($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); } @@ -5063,7 +5057,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack { $iFileSize = $this->FilesProvider()->FileSize($oAccount, $sTempName); - $oMessage->Attachments()->Add( + $oMessage->Attachments()->append( \MailSo\Mime\Attachment::NewInstance($rResource, $sFileName, $iFileSize, $bIsInline, \in_array(trim(trim($sCID), '<>'), $aFoundedCids), $sCID, array(), $sContentLocation @@ -5093,7 +5087,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack unset($sRaw); unset($aMatch); - $oMessage->Attachments()->Add( + $oMessage->Attachments()->append( \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[2]', array(&$oMessage, $oAccount)); + $this->Plugins()->RunHook('filter.build-message', array($oMessage)); + $this->Plugins()->RunHook('filter.build-message[2]', array($oMessage, $oAccount)); return $oMessage; } @@ -5166,11 +5160,11 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $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); - $this->Plugins()->RunHook('filter.build-read-receipt-message', array(&$oMessage, $oAccount)); + $this->Plugins()->RunHook('filter.build-read-receipt-message', array($oMessage, $oAccount)); return $oMessage; } @@ -5196,8 +5190,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $oMessage = $this->buildMessage($oAccount, true); $this->Plugins() - ->RunHook('filter.save-message', array(&$oMessage)) - ->RunHook('filter.save-message[2]', array(&$oMessage, $oAccount)) + ->RunHook('filter.save-message', array($oMessage)) + ->RunHook('filter.save-message[2]', array($oMessage, $oAccount)) ; $mResult = false; @@ -5258,7 +5252,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $this->Plugins()->RunHook('filter.smtp-message-stream', array($oAccount, &$rMessageStream, &$iMessageStreamSize)); - $this->Plugins()->RunHook('filter.message-rcpt', array($oAccount, &$oRcpt)); + $this->Plugins()->RunHook('filter.message-rcpt', array($oAccount, $oRcpt)); try { @@ -5341,8 +5335,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $oSmtpClient->MailFrom($sFrom, '', $bDsn); } - $aRcpt =& $oRcpt->GetAsArray(); - foreach ($aRcpt as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) + foreach ($oRcpt as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) { $oSmtpClient->Rcpt($oEmail->GetEmail(), $bDsn); } @@ -5421,8 +5414,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $oMessage = $this->buildMessage($oAccount, false); $this->Plugins() - ->RunHook('filter.send-message', array(&$oMessage)) - ->RunHook('filter.send-message[2]', array(&$oMessage, $oAccount)) + ->RunHook('filter.send-message', array($oMessage)) + ->RunHook('filter.send-message[2]', array($oMessage, $oAccount)) ; $mResult = false; @@ -5562,8 +5555,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $oToCollection = $oMessage->GetTo(); if ($oToCollection) { - $aTo =& $oToCollection->GetAsArray(); - foreach ($aTo as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) + foreach ($oToCollection as /* @var $oEmail \MailSo\Mime\Email */ $oEmail) { $aArrayToFrec[$oEmail->GetEmail(true)] = $oEmail->ToString(false, true); } @@ -5599,7 +5591,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $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; try @@ -6287,8 +6279,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack if ($oMessage instanceof \MailSo\Mail\Message) { $this->Plugins() - ->RunHook('filter.result-message', array(&$oMessage)) - ->RunHook('filter.result-message[2]', array(&$oMessage, $oAccount)) + ->RunHook('filter.result-message', array($oMessage)) + ->RunHook('filter.result-message[2]', array($oMessage, $oAccount)) ; $this->cacheByKey($sRawKey); @@ -7244,7 +7236,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack 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) { @@ -8144,7 +8136,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack { $mResult['@Object'] = 'Collection/'.$mResult['@Object']; $mResult['@Count'] = $oData->Count(); - $mResult['@Collection'] = $this->responseObject($oData->GetAsArray(), $sParent, $aParameters); + $mResult['@Collection'] = $this->responseObject($oData->getArrayCopy(), $sParent, $aParameters); } else { @@ -8298,55 +8290,24 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack * * @return mixed */ + protected $oAccount = null; + protected $aCheckableFolder = null; protected function responseObject($mResponse, string $sParent = '', array $aParameters = array()) { - $mResult = $mResponse; if (\is_object($mResponse)) { $bHook = true; - $self = $this; $sClassName = \get_class($mResponse); - $bHasSimpleJsonFunc = \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) + if (\method_exists($mResponse, 'ToSimpleJSON')) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), $mResponse->ToSimpleJSON(true)); } 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(); 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()) { - $aList =& $oAttachments->GetAsArray(); - foreach ($aList as /* @var \MailSo\Mail\Attachment */ $oAttachment) + foreach ($oAttachments as /* @var \MailSo\Mail\Attachment */ $oAttachment) { if ($oAttachment) { @@ -8573,7 +8533,9 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack } 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']) && 0 < \count($aParameters['FoundedCIDs']) ? @@ -8604,7 +8566,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack 'CID' => $mResponse->Cid(), 'ContentLocation' => $mResponse->ContentLocation(), 'IsInline' => $mResponse->IsInline(), - 'IsThumbnail' => $bThumb, + 'IsThumbnail' => $this->GetCapa(false, false, \RainLoop\Enumerations\Capa::ATTACHMENT_THUMBNAILS), 'IsLinked' => ($mFoundedCIDs && \in_array(\trim(\trim($mResponse->Cid()), '<>'), $mFoundedCIDs)) || ($mFoundedContentLocationUrls && \in_array(\trim($mResponse->ContentLocation()), $mFoundedContentLocationUrls)) )); @@ -8618,7 +8580,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $mResult['Download'] = \RainLoop\Utils::EncodeKeyValuesQ(array( 'V' => APP_VERSION, - 'Account' => $oAccount ? \md5($oAccount->Hash()) : '', + 'Account' => $this->oAccount ? \md5($this->oAccount->Hash()) : '', 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeIndex' => $mResult['MimeIndex'], @@ -8644,10 +8606,17 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack // ); // } - $aCheckableFolder = \call_user_func($fGetCheckableFolder); - if (!\is_array($aCheckableFolder)) + if (null === $this->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( @@ -8661,7 +8630,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack 'IsExists' => $mResponse->IsExists(), 'IsSelectable' => $mResponse->IsSelectable(), 'Flags' => $mResponse->FlagsLowerCase(), - 'Checkable' => \in_array($mResponse->FullNameRaw(), $aCheckableFolder), + 'Checkable' => \in_array($mResponse->FullNameRaw(), $this->aCheckableFolder), 'Extended' => $aExtended, 'SubFolders' => $this->responseObject($mResponse->SubFolders(), $sParent, $aParameters) )); @@ -8701,20 +8670,28 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $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) { - $aList =& $mResponse->GetAsArray(); - if (100 < \count($aList) && $mResponse instanceof \MailSo\Mime\EmailCollection) - { - $aList = \array_slice($aList, 0, 100); + $mResult = array(); + foreach ($mResponse as $iKey => $oItem) { + $mResult[$iKey] = $this->responseObject($oItem, $sParent, $aParameters); } - - $mResult = $this->responseObject($aList, $sParent, $aParameters); $bHook = false; } else { - $mResult = '["'.\get_class($mResponse).'"]'; + $mResult = '["'.$sClassName.'"]'; $bHook = false; } @@ -8732,6 +8709,10 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack $mResult = $mResponse; } + else + { + $mResult = $mResponse; + } unset($mResponse); return $mResult; diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php index 3fbc5de55..f781b88ec 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php @@ -76,7 +76,7 @@ class Contact $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) { @@ -170,7 +170,7 @@ class Contact public function GetEmails() : 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()) { @@ -233,7 +233,7 @@ class Contact unset($oVCard->FN, $oVCard->EMAIL, $oVCard->TEL, $oVCard->URL, $oVCard->NICKNAME); $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) { @@ -353,7 +353,7 @@ class Contact $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; if ($oProperty) diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php index dc2e07844..2a9770ec7 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php @@ -1152,7 +1152,7 @@ class PdoAddressBook unset($aFetch); - foreach ($aContacts as &$oItem) + foreach ($aContacts as $oItem) { $oItem->UpdateDependentValues(); } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Filters.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Filters.php index 206f8a749..6382e4041 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Filters.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Filters.php @@ -9,9 +9,9 @@ class Filters extends \RainLoop\Providers\AbstractProvider */ 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