Replace slow call_user_func()/call_user_func_array() with simple calls and splat

This commit is contained in:
djmaze 2021-11-04 21:42:05 +01:00
parent 18e2049cf2
commit 159f899e1a
16 changed files with 125 additions and 143 deletions

View file

@ -255,7 +255,7 @@ abstract class HtmlUtils
} }
$aHtmlAllowedTags = isset(\MailSo\Config::$HtmlStrictAllowedTags) && $aHtmlAllowedTags = isset(\MailSo\Config::$HtmlStrictAllowedTags) &&
\is_array(\MailSo\Config::$HtmlStrictAllowedTags) && 0 < \count(\MailSo\Config::$HtmlStrictAllowedTags) ? \is_array(\MailSo\Config::$HtmlStrictAllowedTags) && \count(\MailSo\Config::$HtmlStrictAllowedTags) ?
\MailSo\Config::$HtmlStrictAllowedTags : null; \MailSo\Config::$HtmlStrictAllowedTags : null;
$aRemove = array(); $aRemove = array();
@ -311,7 +311,7 @@ abstract class HtmlUtils
$sValue = 'absolute'; $sValue = 'absolute';
} }
if (0 === \strlen($sName) || 0 === \strlen($sValue)) if (!\strlen($sName) || !\strlen($sValue))
{ {
continue; continue;
} }
@ -379,8 +379,8 @@ abstract class HtmlUtils
if ($fAdditionalExternalFilter) if ($fAdditionalExternalFilter)
{ {
$sAdditionalResult = \call_user_func($fAdditionalExternalFilter, $sUrl); $sAdditionalResult = $fAdditionalExternalFilter($sUrl);
if (0 < \strlen($sAdditionalResult)) if (\strlen($sAdditionalResult))
{ {
$oElement->setAttribute('data-x-additional-style-url', $oElement->setAttribute('data-x-additional-style-url',
('background' === $sName ? 'background-image' : $sName).': url('.$sAdditionalResult.')'); ('background' === $sName ? 'background-image' : $sName).': url('.$sAdditionalResult.')');
@ -444,7 +444,7 @@ abstract class HtmlUtils
foreach ($aTextNodes as $oTextNode) foreach ($aTextNodes as $oTextNode)
{ {
if ($oTextNode && 0 < \strlen($oTextNode->wholeText)/* && \preg_match('/http[s]?:\/\//i', $oTextNode->wholeText)*/) if ($oTextNode && \strlen($oTextNode->wholeText)/* && \preg_match('/http[s]?:\/\//i', $oTextNode->wholeText)*/)
{ {
$sText = (new \MailSo\Base\LinkFinder) $sText = (new \MailSo\Base\LinkFinder)
->Text($oTextNode->wholeText) ->Text($oTextNode->wholeText)
@ -517,7 +517,7 @@ abstract class HtmlUtils
$sHtml = null === $sHtml ? '' : (string) $sHtml; $sHtml = null === $sHtml ? '' : (string) $sHtml;
$sHtml = \trim($sHtml); $sHtml = \trim($sHtml);
if (0 === \strlen($sHtml)) if (!\strlen($sHtml))
{ {
return ''; return '';
} }
@ -545,7 +545,7 @@ abstract class HtmlUtils
if ($fAdditionalDomReader) if ($fAdditionalDomReader)
{ {
$oResDom = \call_user_func($fAdditionalDomReader, $oDom); $oResDom = $fAdditionalDomReader($oDom);
if ($oResDom) if ($oResDom)
{ {
$oDom = $oResDom; $oDom = $oResDom;
@ -633,7 +633,7 @@ abstract class HtmlUtils
} }
} }
if (0 < \count($aStyles)) if (\count($aStyles))
{ {
$sStyles .= $sStyles . '; ' . \implode('; ', $aStyles); $sStyles .= $sStyles . '; ' . \implode('; ', $aStyles);
} }
@ -652,7 +652,7 @@ abstract class HtmlUtils
if ($oElement->hasAttributes() && isset($oElement->attributes) && $oElement->attributes) if ($oElement->hasAttributes() && isset($oElement->attributes) && $oElement->attributes)
{ {
$aHtmlAllowedAttributes = isset(\MailSo\Config::$HtmlStrictAllowedAttributes) && $aHtmlAllowedAttributes = isset(\MailSo\Config::$HtmlStrictAllowedAttributes) &&
\is_array(\MailSo\Config::$HtmlStrictAllowedAttributes) && 0 < \count(\MailSo\Config::$HtmlStrictAllowedAttributes) ? \is_array(\MailSo\Config::$HtmlStrictAllowedAttributes) && \count(\MailSo\Config::$HtmlStrictAllowedAttributes) ?
\MailSo\Config::$HtmlStrictAllowedAttributes : null; \MailSo\Config::$HtmlStrictAllowedAttributes : null;
$sAttrsForRemove = array(); $sAttrsForRemove = array();
@ -676,7 +676,7 @@ abstract class HtmlUtils
} }
} }
if (0 < \count($sAttrsForRemove)) if (\count($sAttrsForRemove))
{ {
foreach ($sAttrsForRemove as $sName) foreach ($sAttrsForRemove as $sName)
{ {
@ -797,8 +797,8 @@ abstract class HtmlUtils
$oElement->setAttribute('data-x-src', $sSrc); $oElement->setAttribute('data-x-src', $sSrc);
if ($fAdditionalExternalFilter) if ($fAdditionalExternalFilter)
{ {
$sCallResult = \call_user_func($fAdditionalExternalFilter, $sSrc); $sCallResult = $fAdditionalExternalFilter($sSrc);
if (0 < \strlen($sCallResult)) if (\strlen($sCallResult))
{ {
$oElement->setAttribute('data-x-additional-src', $sCallResult); $oElement->setAttribute('data-x-additional-src', $sCallResult);
} }
@ -849,13 +849,13 @@ abstract class HtmlUtils
$aFoundCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, $bDoNotReplaceExternalUrl, $fAdditionalExternalFilter)); $aFoundCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, $bDoNotReplaceExternalUrl, $fAdditionalExternalFilter));
} }
if (\MailSo\Config::$HtmlStrictDebug && 0 < \count($aRemovedAttrs)) if (\MailSo\Config::$HtmlStrictDebug && \count($aRemovedAttrs))
{ {
unset($aRemovedAttrs['class'], $aRemovedAttrs['target'], $aRemovedAttrs['id'], $aRemovedAttrs['name'], unset($aRemovedAttrs['class'], $aRemovedAttrs['target'], $aRemovedAttrs['id'], $aRemovedAttrs['name'],
$aRemovedAttrs['itemprop'], $aRemovedAttrs['itemscope'], $aRemovedAttrs['itemtype']); $aRemovedAttrs['itemprop'], $aRemovedAttrs['itemscope'], $aRemovedAttrs['itemtype']);
$aRemovedAttrs = \array_keys($aRemovedAttrs); $aRemovedAttrs = \array_keys($aRemovedAttrs);
if (0 < \count($aRemovedAttrs)) if (\count($aRemovedAttrs))
{ {
$oElement->setAttribute('data-removed-attrs', \implode(',', $aRemovedAttrs)); $oElement->setAttribute('data-removed-attrs', \implode(',', $aRemovedAttrs));
} }
@ -1006,7 +1006,7 @@ abstract class HtmlUtils
public static function ConvertPlainToHtml(string $sText, bool $bLinksWithTargetBlank = true) : string public static function ConvertPlainToHtml(string $sText, bool $bLinksWithTargetBlank = true) : string
{ {
$sText = \trim($sText); $sText = \trim($sText);
if (0 === \strlen($sText)) if (!\strlen($sText))
{ {
return ''; return '';
} }

View file

@ -153,7 +153,7 @@ class LinkFinder
unset($sText, $sSubText); unset($sText, $sSubText);
if (0 < \count($this->aPrepearPlainStringUrls)) if (\count($this->aPrepearPlainStringUrls))
{ {
$aPrepearPlainStringUrls = $this->aPrepearPlainStringUrls; $aPrepearPlainStringUrls = $this->aPrepearPlainStringUrls;
$sResult = \preg_replace_callback('/'.\preg_quote(static::OPEN_LINK, '/'). $sResult = \preg_replace_callback('/'.\preg_quote(static::OPEN_LINK, '/').
@ -195,8 +195,8 @@ class LinkFinder
} }
} }
$sLinkWithWrap = \call_user_func($fWrapper, $aMatch[2].$aMatch[3]); $sLinkWithWrap = $fWrapper($aMatch[2].$aMatch[3]);
if (\is_string($sLinkWithWrap) && 0 < \strlen($sLinkWithWrap)) if (\is_string($sLinkWithWrap) && \strlen($sLinkWithWrap))
{ {
$aPrepearPlainStringUrls[] = \stripslashes($sLinkWithWrap); $aPrepearPlainStringUrls[] = \stripslashes($sLinkWithWrap);
return $aMatch[1]. return $aMatch[1].
@ -213,7 +213,7 @@ class LinkFinder
}, $sText); }, $sText);
if (0 < \count($aPrepearPlainStringUrls)) if (\count($aPrepearPlainStringUrls))
{ {
$this->aPrepearPlainStringUrls = $aPrepearPlainStringUrls; $this->aPrepearPlainStringUrls = $aPrepearPlainStringUrls;
} }
@ -233,8 +233,8 @@ class LinkFinder
if (\is_array($aMatch) && isset($aMatch[1])) if (\is_array($aMatch) && isset($aMatch[1]))
{ {
$sMailWithWrap = \call_user_func($fWrapper, $aMatch[1]); $sMailWithWrap = $fWrapper($aMatch[1]);
if (\is_string($sMailWithWrap) && 0 < \strlen($sMailWithWrap)) if (\is_string($sMailWithWrap) && \strlen($sMailWithWrap))
{ {
$aPrepearPlainStringUrls[] = \stripslashes($sMailWithWrap); $aPrepearPlainStringUrls[] = \stripslashes($sMailWithWrap);
return static::OPEN_LINK. return static::OPEN_LINK.
@ -249,7 +249,7 @@ class LinkFinder
}, $sText); }, $sText);
if (0 < \count($aPrepearPlainStringUrls)) if (\count($aPrepearPlainStringUrls))
{ {
$this->aPrepearPlainStringUrls = $aPrepearPlainStringUrls; $this->aPrepearPlainStringUrls = $aPrepearPlainStringUrls;
} }

View file

@ -110,7 +110,7 @@ END;
}; };
} }
if (!\call_user_func($fFileExistsCallback, $sFilePath)) if (!$fFileExistsCallback($sFilePath))
{ {
return $sFilePath; return $sFilePath;
} }
@ -129,7 +129,7 @@ END;
(empty($aFileInfo['extension']) ? '' : '.'.$aFileInfo['extension']) (empty($aFileInfo['extension']) ? '' : '.'.$aFileInfo['extension'])
; ;
if (!\call_user_func($fFileExistsCallback, $sFilePathNew)) if (!$fFileExistsCallback($sFilePathNew))
{ {
$sFilePath = $sFilePathNew; $sFilePath = $sFilePathNew;
break; break;
@ -152,9 +152,8 @@ END;
$aSupportedEncodings = \array_map('strtoupper', \array_unique( $aSupportedEncodings = \array_map('strtoupper', \array_unique(
\array_merge( \array_merge(
$aSupportedEncodings, $aSupportedEncodings,
\call_user_func_array( array_merge(
'array_merge', ...\array_map(
\array_map(
'mb_encoding_aliases', 'mb_encoding_aliases',
$aSupportedEncodings $aSupportedEncodings
) )
@ -1200,7 +1199,7 @@ END;
public static function PrepareFetchSequence(array $aSequence) : string public static function PrepareFetchSequence(array $aSequence) : string
{ {
$aResult = array(); $aResult = array();
if (0 < \count($aSequence)) if (\count($aSequence))
{ {
$iStart = null; $iStart = null;
$iPrev = null; $iPrev = null;
@ -1276,7 +1275,7 @@ END;
public static function MultipleStreamWriter($rRead, array $aWrite, int $iBufferLen = 8192, bool $bResetTimeLimit = true, bool $bFixCrLf = false, bool $bRewindOnComplete = false) : int public static function MultipleStreamWriter($rRead, array $aWrite, int $iBufferLen = 8192, bool $bResetTimeLimit = true, bool $bFixCrLf = false, bool $bRewindOnComplete = false) : int
{ {
$mResult = false; $mResult = false;
if ($rRead && 0 < \count($aWrite)) if ($rRead && \count($aWrite))
{ {
$mResult = 0; $mResult = 0;
while (!\feof($rRead)) while (!\feof($rRead))

View file

@ -27,7 +27,7 @@ class Hooks
{ {
foreach (static::$aCallbacks[$sName] as $mCallback) foreach (static::$aCallbacks[$sName] as $mCallback)
{ {
\call_user_func_array($mCallback, $aArg); $mCallback(...$aArg);
} }
} }
} }

View file

@ -172,7 +172,7 @@ class BodyStructure
public function IsInline() : bool public function IsInline() : bool
{ {
return (null === $this->sDisposition) ? return (null === $this->sDisposition) ?
(0 < \strlen($this->ContentID())) : ('inline' === strtolower($this->sDisposition)); (\strlen($this->ContentID())) : ('inline' === strtolower($this->sDisposition));
} }
public function IsImage() : bool public function IsImage() : bool
@ -328,7 +328,7 @@ class BodyStructure
public function SearchByCallback($fCallback) : array public function SearchByCallback($fCallback) : array
{ {
$aReturn = array(); $aReturn = array();
if (\call_user_func($fCallback, $this)) if ($fCallback($this))
{ {
$aReturn[] = $this; $aReturn[] = $this;
} }
@ -359,7 +359,7 @@ class BodyStructure
public function GetPartByMimeIndex(string $sMimeIndex) : self public function GetPartByMimeIndex(string $sMimeIndex) : self
{ {
$oPart = null; $oPart = null;
if (0 < \strlen($sMimeIndex)) if (\strlen($sMimeIndex))
{ {
if ($sMimeIndex === $this->sPartID) if ($sMimeIndex === $this->sPartID)
{ {
@ -419,7 +419,7 @@ class BodyStructure
if ($sCharsetIndex < $iIndex && false !== \strpos($sValue, "''")) if ($sCharsetIndex < $iIndex && false !== \strpos($sValue, "''"))
{ {
$aValueParts = \explode("''", $sValue, 2); $aValueParts = \explode("''", $sValue, 2);
if (2 === \count($aValueParts) && 0 < \strlen($aValueParts[0])) if (2 === \count($aValueParts) && \strlen($aValueParts[0]))
{ {
$sCharsetIndex = $iIndex; $sCharsetIndex = $iIndex;
$sCharset = $aValueParts[0]; $sCharset = $aValueParts[0];
@ -431,13 +431,13 @@ class BodyStructure
} }
} }
if (0 < \count($aFileNames)) if (\count($aFileNames))
{ {
\ksort($aFileNames, SORT_NUMERIC); \ksort($aFileNames, SORT_NUMERIC);
$sResult = \implode(\array_values($aFileNames)); $sResult = \implode(\array_values($aFileNames));
$sResult = \urldecode($sResult); $sResult = \urldecode($sResult);
if (0 < \strlen($sCharset)) if (\strlen($sCharset))
{ {
$sResult = \MailSo\Base\Utils::ConvertEncoding($sResult, $sResult = \MailSo\Base\Utils::ConvertEncoding($sResult,
$sCharset, \MailSo\Base\Enumerations\Charset::UTF_8); $sCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
@ -484,13 +484,13 @@ class BodyStructure
$sBodyMainType = 'multipart'; $sBodyMainType = 'multipart';
$sSubPartIDPrefix = ''; $sSubPartIDPrefix = '';
if (0 === \strlen($sPartID) || '.' === $sPartID[\strlen($sPartID) - 1]) if (!\strlen($sPartID) || '.' === $sPartID[\strlen($sPartID) - 1])
{ {
// This multi-part is root part of message. // This multi-part is root part of message.
$sSubPartIDPrefix = $sPartID; $sSubPartIDPrefix = $sPartID;
$sPartID .= 'TEXT'; $sPartID .= 'TEXT';
} }
else if (0 < \strlen($sPartID)) else if (\strlen($sPartID))
{ {
// This multi-part is a part of another multi-part. // This multi-part is a part of another multi-part.
$sSubPartIDPrefix = $sPartID.'.'; $sSubPartIDPrefix = $sPartID.'.';
@ -606,7 +606,7 @@ class BodyStructure
$iSize = -1; $iSize = -1;
} }
if (0 === \strlen($sPartID) || '.' === $sPartID[\strlen($sPartID) - 1]) if (!\strlen($sPartID) || '.' === $sPartID[\strlen($sPartID) - 1])
{ {
// This is the only sub-part of the message (otherwise, it would be // This is the only sub-part of the message (otherwise, it would be
// one of sub-parts of a multi-part, and partID would already be fully set up). // one of sub-parts of a multi-part, and partID would already be fully set up).

View file

@ -46,7 +46,7 @@ abstract class FetchType
{ {
$aReturn[$mType] = ''; $aReturn[$mType] = '';
} }
else if (\is_array($mType) && 2 === count($mType) && \is_string($mType[0]) && else if (\is_array($mType) && 2 === \count($mType) && \is_string($mType[0]) &&
\is_callable($mType[1])) \is_callable($mType[1]))
{ {
$aReturn[$mType[0]] = $mType[1]; $aReturn[$mType[0]] = $mType[1];
@ -56,7 +56,7 @@ abstract class FetchType
public static function BuildBodyCustomHeaderRequest(array $aHeaders, bool $bPeek = true) : string public static function BuildBodyCustomHeaderRequest(array $aHeaders, bool $bPeek = true) : string
{ {
$sResult = ''; $sResult = '';
if (0 < \count($aHeaders)) if (\count($aHeaders))
{ {
$aHeaders = \array_map('trim', $aHeaders); $aHeaders = \array_map('trim', $aHeaders);
$aHeaders = \array_map('strtoupper', $aHeaders); $aHeaders = \array_map('strtoupper', $aHeaders);

View file

@ -41,6 +41,7 @@ class ImapClient extends \MailSo\Net\NetClient
private $oCurrentFolderInfo = null; private $oCurrentFolderInfo = null;
/** /**
* Used by \MailSo\Mail\MailClient::MessageMimeStream
* @var array * @var array
*/ */
private $aFetchCallbacks; private $aFetchCallbacks;

View file

@ -72,7 +72,7 @@ trait ResponseParser
*/ */
private function partialParseResponseBranch(Response $oImapResponse, private function partialParseResponseBranch(Response $oImapResponse,
bool $bTreatAsAtom, bool $bTreatAsAtom,
string $sParentToken, ?string $sParentToken,
string $sOpenBracket, string $sOpenBracket,
bool $bRoot = false) bool $bRoot = false)
{ {
@ -147,9 +147,9 @@ trait ResponseParser
} }
case '(': case '(':
$this->iResponseBufParsedPos = ++$iPos; $this->iResponseBufParsedPos = ++$iPos;
$mResult = $this->partialParseResponseBranch($oImapResponse, $bTreatAsAtom, $mResult = $this->partialParseResponseBranch(
null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase), $oImapResponse, $bTreatAsAtom, $sPreviousAtomUpperCase, $sChar
$sChar); );
$sPreviousAtomUpperCase = null; $sPreviousAtomUpperCase = null;
$iPos = $this->iResponseBufParsedPos; $iPos = $this->iResponseBufParsedPos;
if ($bTreatAsAtom) { if ($bTreatAsAtom) {
@ -170,9 +170,7 @@ trait ResponseParser
$iLiteralLen = (int) \substr($this->sResponseBuffer, $iPos + 1, $iLength); $iLiteralLen = (int) \substr($this->sResponseBuffer, $iPos + 1, $iLength);
$iPos += 4 + $iLength; $iPos += 4 + $iLength;
if ($this->partialResponseLiteralCallbackCallable( if ($this->partialResponseLiteralCallbacks($sParentToken, $sPreviousAtomUpperCase, $iLiteralLen)) {
$sParentToken, null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase), $iLiteralLen))
{
if (!$bTreatAsAtom) { if (!$bTreatAsAtom) {
$aList[] = ''; $aList[] = '';
} }
@ -277,9 +275,9 @@ trait ResponseParser
$this->iResponseBufParsedPos = ++$iPos; $this->iResponseBufParsedPos = ++$iPos;
$sListBlock = $this->partialParseResponseBranch($oImapResponse, true, $sListBlock = $this->partialParseResponseBranch(
null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase), $oImapResponse, true, $sPreviousAtomUpperCase, '['
'['); );
if (null !== $sListBlock) if (null !== $sListBlock)
{ {
@ -305,7 +303,7 @@ trait ResponseParser
if (null === $sAtomBuilder) if (null === $sAtomBuilder)
{ {
$aList[] = 'NIL' === $sLastCharBlock ? null : $sLastCharBlock; $aList[] = 'NIL' === $sLastCharBlock ? null : $sLastCharBlock;
$sPreviousAtomUpperCase = $sLastCharBlock; $sPreviousAtomUpperCase = \strtoupper($sLastCharBlock);
} }
else else
{ {
@ -314,7 +312,7 @@ trait ResponseParser
if (!$bTreatAsAtom) if (!$bTreatAsAtom)
{ {
$aList[] = $sAtomBuilder; $aList[] = $sAtomBuilder;
$sPreviousAtomUpperCase = $sAtomBuilder; $sPreviousAtomUpperCase = \strtoupper($sAtomBuilder);
$sAtomBuilder = null; $sAtomBuilder = null;
} }
} }
@ -376,26 +374,20 @@ trait ResponseParser
return $sLiteral; return $sLiteral;
} }
private function partialResponseLiteralCallbackCallable(string $sParent, string $sLiteralAtomUpperCase, int $iLiteralLen) : bool private function partialResponseLiteralCallbacks(?string $sParent, ?string $sLiteralAtomUpperCase, int $iLiteralLen) : bool
{ {
if (!$this->aFetchCallbacks) { if (!$this->aFetchCallbacks || !$sLiteralAtomUpperCase || 'FETCH' !== $sParent) {
return false; return false;
} }
$sLiteralAtomUpperCasePeek = ''; $sLiteralAtomUpperCasePeek = '';
if (0 === \strpos($sLiteralAtomUpperCase, 'BODY')) if (0 === \strpos($sLiteralAtomUpperCase, 'BODY')) {
{
$sLiteralAtomUpperCasePeek = \str_replace('BODY', 'BODY.PEEK', $sLiteralAtomUpperCase); $sLiteralAtomUpperCasePeek = \str_replace('BODY', 'BODY.PEEK', $sLiteralAtomUpperCase);
} }
$sFetchKey = '';
if (\strlen($sLiteralAtomUpperCasePeek) && isset($this->aFetchCallbacks[$sLiteralAtomUpperCasePeek]))
{
$sFetchKey = $sLiteralAtomUpperCasePeek;
}
else if (\strlen($sLiteralAtomUpperCase) && isset($this->aFetchCallbacks[$sLiteralAtomUpperCase]))
{
$sFetchKey = $sLiteralAtomUpperCase; $sFetchKey = $sLiteralAtomUpperCase;
if ($sLiteralAtomUpperCasePeek && isset($this->aFetchCallbacks[$sLiteralAtomUpperCasePeek])) {
$sFetchKey = $sLiteralAtomUpperCasePeek;
} }
if (empty($this->aFetchCallbacks[$sFetchKey]) || !\is_callable($this->aFetchCallbacks[$sFetchKey])) { if (empty($this->aFetchCallbacks[$sFetchKey]) || !\is_callable($this->aFetchCallbacks[$sFetchKey])) {
@ -412,8 +404,7 @@ trait ResponseParser
try try
{ {
\call_user_func($this->aFetchCallbacks[$sFetchKey], $this->aFetchCallbacks[$sFetchKey]($sParent, $sLiteralAtomUpperCase, $rImapLiteralStream);
$sParent, $sLiteralAtomUpperCase, $rImapLiteralStream);
} }
catch (\Throwable $oException) catch (\Throwable $oException)
{ {
@ -421,8 +412,7 @@ trait ResponseParser
$this->writeLogException($oException); $this->writeLogException($oException);
} }
if ($rImapLiteralStream) if ($rImapLiteralStream) {
{
$iNotReadLiteralLen = 0; $iNotReadLiteralLen = 0;
$bFeof = \feof($rImapLiteralStream); $bFeof = \feof($rImapLiteralStream);
@ -430,13 +420,10 @@ trait ResponseParser
' - feof = '.($bFeof ? 'good' : 'BAD'), $bFeof ? ' - feof = '.($bFeof ? 'good' : 'BAD'), $bFeof ?
\MailSo\Log\Enumerations\Type::NOTE : \MailSo\Log\Enumerations\Type::WARNING); \MailSo\Log\Enumerations\Type::NOTE : \MailSo\Log\Enumerations\Type::WARNING);
if (!$bFeof) if (!$bFeof) {
{ while (!\feof($rImapLiteralStream)) {
while (!\feof($rImapLiteralStream))
{
$sBuf = \fread($rImapLiteralStream, 1024 * 1024); $sBuf = \fread($rImapLiteralStream, 1024 * 1024);
if (false === $sBuf || 0 === \strlen($sBuf) || null === $sBuf) if (!\strlen($sBuf)) {
{
break; break;
} }
@ -444,22 +431,18 @@ trait ResponseParser
$iNotReadLiteralLen += \strlen($sBuf); $iNotReadLiteralLen += \strlen($sBuf);
} }
if (!\feof($rImapLiteralStream)) if (!\feof($rImapLiteralStream)) {
{
\stream_get_contents($rImapLiteralStream); \stream_get_contents($rImapLiteralStream);
} }
} }
\fclose($rImapLiteralStream); \fclose($rImapLiteralStream);
if ($iNotReadLiteralLen > 0) if (0 < $iNotReadLiteralLen) {
{
$this->writeLog('Not read literal size is '.$iNotReadLiteralLen.' bytes.', $this->writeLog('Not read literal size is '.$iNotReadLiteralLen.' bytes.',
\MailSo\Log\Enumerations\Type::WARNING); \MailSo\Log\Enumerations\Type::WARNING);
} }
} } else {
else
{
$this->writeLog('Literal stream is not resource after callback.', $this->writeLog('Literal stream is not resource after callback.',
\MailSo\Log\Enumerations\Type::WARNING); \MailSo\Log\Enumerations\Type::WARNING);
} }

View file

@ -44,7 +44,7 @@ class Callback extends \MailSo\Log\Driver
{ {
if ($this->fWriteCallback) if ($this->fWriteCallback)
{ {
\call_user_func_array($this->fWriteCallback, array($mDesc)); ($this->fWriteCallback)($mDesc);
} }
return true; return true;
@ -54,7 +54,7 @@ class Callback extends \MailSo\Log\Driver
{ {
if ($this->fClearCallback) if ($this->fClearCallback)
{ {
\call_user_func($this->fClearCallback); ($this->fClearCallback)();
} }
return true; return true;

View file

@ -369,12 +369,12 @@ class MailClient
} }
$aFetchResponse = $this->oImapClient->Fetch(array( $aFetchResponse = $this->oImapClient->Fetch(array(
array(\MailSo\Imap\Enumerations\FetchType::BODY_PEEK.'['.$sMimeIndex.']', // Push in the aFetchCallbacks array and then called by \MailSo\Imap\Traits\ResponseParser::partialResponseLiteralCallbackCallable
array(
\MailSo\Imap\Enumerations\FetchType::BODY_PEEK.'['.$sMimeIndex.']',
function ($sParent, $sLiteralAtomUpperCase, $rImapLiteralStream) use ($mCallback, $sMimeIndex, $sMailEncodingName, $sContentType, $sFileName) function ($sParent, $sLiteralAtomUpperCase, $rImapLiteralStream) use ($mCallback, $sMimeIndex, $sMailEncodingName, $sContentType, $sFileName)
{ {
if (\strlen($sLiteralAtomUpperCase)) if (\strlen($sLiteralAtomUpperCase) && \is_resource($rImapLiteralStream) && 'FETCH' === $sParent)
{
if (\is_resource($rImapLiteralStream) && 'FETCH' === $sParent)
{ {
$rMessageMimeIndexStream = \strlen($sMailEncodingName) $rMessageMimeIndexStream = \strlen($sMailEncodingName)
? \MailSo\Base\StreamWrappers\Binary::CreateStream($rImapLiteralStream, ? \MailSo\Base\StreamWrappers\Binary::CreateStream($rImapLiteralStream,
@ -382,8 +382,7 @@ class MailClient
$sMailEncodingName, true)) $sMailEncodingName, true))
: $rImapLiteralStream; : $rImapLiteralStream;
\call_user_func($mCallback, $rMessageMimeIndexStream, $sContentType, $sFileName, $sMimeIndex); $mCallback($rMessageMimeIndexStream, $sContentType, $sFileName, $sMimeIndex);
}
} }
} }
)), $iIndex, $bIndexIsUid); )), $iIndex, $bIndexIsUid);

View file

@ -313,7 +313,7 @@ class Actions
return \trim(\trim($sS), ' /'); return \trim(\trim($sS), ' /');
}, $aSubQuery); }, $aSubQuery);
if (0 < \count($aSubQuery)) { if (\count($aSubQuery)) {
$sQuery .= '/' . \implode('/', $aSubQuery); $sQuery .= '/' . \implode('/', $aSubQuery);
} }
} }
@ -465,7 +465,7 @@ class Actions
$sFileName = \preg_replace('/[^a-zA-Z0-9@_+=\-\.\/!()\[\]]/', '', $sFileName); $sFileName = \preg_replace('/[^a-zA-Z0-9@_+=\-\.\/!()\[\]]/', '', $sFileName);
} }
if (0 === \strlen($sFileName)) { if (!\strlen($sFileName)) {
$sFileName = 'rainloop-log.txt'; $sFileName = 'rainloop-log.txt';
} }
@ -485,7 +485,7 @@ class Actions
$this->SetSpecAuthToken($sSpecAuthToken); $this->SetSpecAuthToken($sSpecAuthToken);
Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, $sSpecAuthToken); Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, $sSpecAuthToken);
if ($oAccount->SignMe() && 0 < \strlen($oAccount->SignMeToken())) { if ($oAccount->SignMe() && \strlen($oAccount->SignMeToken())) {
Utils::SetCookie(self::AUTH_SIGN_ME_TOKEN_KEY, Utils::SetCookie(self::AUTH_SIGN_ME_TOKEN_KEY,
Utils::EncodeKeyValuesQ(array( Utils::EncodeKeyValuesQ(array(
'e' => $oAccount->Email(), 'e' => $oAccount->Email(),
@ -861,7 +861,7 @@ class Actions
protected function LoginProvide(string $sEmail, string $sLogin, string $sPassword, string $sSignMeToken = '', string $sClientCert = '', bool $bThrowProvideException = false): ?Model\Account protected function LoginProvide(string $sEmail, string $sLogin, string $sPassword, string $sSignMeToken = '', string $sClientCert = '', bool $bThrowProvideException = false): ?Model\Account
{ {
$oAccount = null; $oAccount = null;
if (0 < \strlen($sEmail) && 0 < \strlen($sLogin) && 0 < \strlen($sPassword)) { if (\strlen($sEmail) && \strlen($sLogin) && \strlen($sPassword)) {
$oDomain = $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true); $oDomain = $this->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true);
if ($oDomain) { if ($oDomain) {
if ($oDomain->ValidateWhiteList($sEmail, $sLogin)) { if ($oDomain->ValidateWhiteList($sEmail, $sLogin)) {
@ -1368,7 +1368,7 @@ class Actions
$aDomainParts = \explode('.', $sUserHost); $aDomainParts = \explode('.', $sUserHost);
$oDomainProvider = $this->DomainProvider(); $oDomainProvider = $this->DomainProvider();
while (0 < \count($aDomainParts) && 0 < $iLimit) { while (\count($aDomainParts) && 0 < $iLimit) {
$sLine = \trim(\implode('.', $aDomainParts), '. '); $sLine = \trim(\implode('.', $aDomainParts), '. ');
$oDomain = $oDomainProvider->Load($sLine, false); $oDomain = $oDomainProvider->Load($sLine, false);
@ -1407,7 +1407,7 @@ class Actions
} }
$sDefDomain = \trim($this->Config()->Get('login', 'default_domain', '')); $sDefDomain = \trim($this->Config()->Get('login', 'default_domain', ''));
if (false === \strpos($sEmail, '@') && 0 < \strlen($sDefDomain)) { if (false === \strpos($sEmail, '@') && \strlen($sDefDomain)) {
$this->Logger()->Write('Default domain "' . $sDefDomain . '" was used. (' . $sEmail . ' > ' . $sEmail . '@' . $sDefDomain . ')', $this->Logger()->Write('Default domain "' . $sDefDomain . '" was used. (' . $sEmail . ' > ' . $sEmail . '@' . $sDefDomain . ')',
\MailSo\Log\Enumerations\Type::INFO, 'LOGIN'); \MailSo\Log\Enumerations\Type::INFO, 'LOGIN');
@ -1417,7 +1417,7 @@ class Actions
$this->Plugins()->RunHook('login.credentials.step-2', array(&$sEmail, &$sPassword)); $this->Plugins()->RunHook('login.credentials.step-2', array(&$sEmail, &$sPassword));
if (false === \strpos($sEmail, '@') || 0 === \strlen($sPassword)) { if (false === \strpos($sEmail, '@') || !\strlen($sPassword)) {
$this->loginErrorDelay(); $this->loginErrorDelay();
throw new Exceptions\ClientException(Notifications::InvalidInputArgument); throw new Exceptions\ClientException(Notifications::InvalidInputArgument);
@ -1472,7 +1472,7 @@ class Actions
$aAccounts = \json_decode($sAccounts, true); $aAccounts = \json_decode($sAccounts, true);
} }
if (\is_array($aAccounts) && 0 < \count($aAccounts)) { if (\is_array($aAccounts) && \count($aAccounts)) {
if (1 === \count($aAccounts)) { if (1 === \count($aAccounts)) {
$this->SetAccounts($oAccount, array()); $this->SetAccounts($oAccount, array());
@ -1571,7 +1571,7 @@ class Actions
case 'string': case 'string':
$sValue = (string)$sValue; $sValue = (string)$sValue;
if ($mStringCallback && is_callable($mStringCallback)) { if ($mStringCallback && is_callable($mStringCallback)) {
$sValue = call_user_func($mStringCallback, $sValue); $sValue = $mStringCallback($sValue);
} }
$oConfig->Set($sConfigSector, $sConfigName, (string)$sValue); $oConfig->Set($sConfigSector, $sConfigName, (string)$sValue);
@ -1615,7 +1615,7 @@ class Actions
public function MainClearFileName(string $sFileName, string $sContentType, string $sMimeIndex, int $iMaxLength = 250): string public function MainClearFileName(string $sFileName, string $sContentType, string $sMimeIndex, int $iMaxLength = 250): string
{ {
$sFileName = 0 === \strlen($sFileName) ? \preg_replace('/[^a-zA-Z0-9]/', '.', (empty($sMimeIndex) ? '' : $sMimeIndex . '.') . $sContentType) : $sFileName; $sFileName = !\strlen($sFileName) ? \preg_replace('/[^a-zA-Z0-9]/', '.', (empty($sMimeIndex) ? '' : $sMimeIndex . '.') . $sContentType) : $sFileName;
$sClearedFileName = \MailSo\Base\Utils::StripSpaces(\preg_replace('/[\.]+/', '.', $sFileName)); $sClearedFileName = \MailSo\Base\Utils::StripSpaces(\preg_replace('/[\.]+/', '.', $sFileName));
$sExt = \MailSo\Base\Utils::GetFileExtension($sClearedFileName); $sExt = \MailSo\Base\Utils::GetFileExtension($sClearedFileName);
@ -1736,7 +1736,7 @@ class Actions
$rData = $this->FilesProvider()->GetFile($oAccount, $sSavedName); $rData = $this->FilesProvider()->GetFile($oAccount, $sSavedName);
if (\is_resource($rData)) { if (\is_resource($rData)) {
$sData = \stream_get_contents($rData); $sData = \stream_get_contents($rData);
if (!empty($sData) && 0 < \strlen($sData)) { if (!empty($sData) && \strlen($sData)) {
$sName = $aFile['name']; $sName = $aFile['name'];
if (empty($sName)) { if (empty($sName)) {
$sName = '_'; $sName = '_';
@ -1826,7 +1826,7 @@ class Actions
} }
} }
if (0 < \count($aData)) { if (\count($aData)) {
$this->Logger()->Write('Import contacts from csv'); $this->Logger()->Write('Import contacts from csv');
$iCount = $oAddressBookProvider->ImportCsvArray($oAccount->ParentEmailHelper(), $aData); $iCount = $oAddressBookProvider->ImportCsvArray($oAccount->ParentEmailHelper(), $aData);
} }

View file

@ -42,7 +42,7 @@ trait User
$this->AuthToken($oAccount); $this->AuthToken($oAccount);
if ($oAccount && 0 < \strlen($sLanguage)) if ($oAccount && \strlen($sLanguage))
{ {
$oSettings = $this->SettingsProvider()->Load($oAccount); $oSettings = $this->SettingsProvider()->Load($oAccount);
if ($oSettings) if ($oSettings)
@ -80,7 +80,7 @@ trait User
$bError = false; $bError = false;
$aData = false; $aData = false;
if (\is_array($aHashes) && 0 < \count($aHashes)) if (\is_array($aHashes) && \count($aHashes))
{ {
$aData = array(); $aData = array();
foreach ($aHashes as $sZipHash) foreach ($aHashes as $sZipHash)
@ -99,7 +99,7 @@ trait User
} }
$oFilesProvider = $this->FilesProvider(); $oFilesProvider = $this->FilesProvider();
if (!empty($sAction) && !$bError && \is_array($aData) && 0 < \count($aData) && if (!empty($sAction) && !$bError && \is_array($aData) && \count($aData) &&
$oFilesProvider && $oFilesProvider->IsActive()) $oFilesProvider && $oFilesProvider->IsActive())
{ {
$bError = false; $bError = false;
@ -397,7 +397,7 @@ trait User
$this->Plugins()->RunHook('json.suggestions-pre', array(&$aResult, $sQuery, $oAccount, $iLimit)); $this->Plugins()->RunHook('json.suggestions-pre', array(&$aResult, $sQuery, $oAccount, $iLimit));
if ($iLimit > \count($aResult) && 0 < \strlen($sQuery)) if ($iLimit > \count($aResult) && \strlen($sQuery))
{ {
try try
{ {
@ -406,7 +406,7 @@ trait User
if ($oAddressBookProvider && $oAddressBookProvider->IsActive()) if ($oAddressBookProvider && $oAddressBookProvider->IsActive())
{ {
$aSuggestions = $oAddressBookProvider->GetSuggestions($oAccount->ParentEmailHelper(), $sQuery, $iLimit); $aSuggestions = $oAddressBookProvider->GetSuggestions($oAccount->ParentEmailHelper(), $sQuery, $iLimit);
if (0 === \count($aResult)) if (!\count($aResult))
{ {
$aResult = $aSuggestions; $aResult = $aSuggestions;
} }
@ -422,13 +422,13 @@ trait User
} }
} }
if ($iLimit > \count($aResult) && 0 < \strlen($sQuery)) if ($iLimit > \count($aResult) && \strlen($sQuery))
{ {
$oSuggestionsProvider = $this->SuggestionsProvider(); $oSuggestionsProvider = $this->SuggestionsProvider();
if ($oSuggestionsProvider && $oSuggestionsProvider->IsActive()) if ($oSuggestionsProvider && $oSuggestionsProvider->IsActive())
{ {
$aSuggestionsProviderResult = $oSuggestionsProvider->Process($oAccount, $sQuery, $iLimit); $aSuggestionsProviderResult = $oSuggestionsProvider->Process($oAccount, $sQuery, $iLimit);
if (\is_array($aSuggestionsProviderResult) && 0 < \count($aSuggestionsProviderResult)) if (\is_array($aSuggestionsProviderResult) && \count($aSuggestionsProviderResult))
{ {
$aResult = \array_merge($aResult, $aSuggestionsProviderResult); $aResult = \array_merge($aResult, $aSuggestionsProviderResult);
} }
@ -459,7 +459,7 @@ trait User
$mResult = false; $mResult = false;
$aExternals = $this->GetActionParam('Externals', array()); $aExternals = $this->GetActionParam('Externals', array());
if (\is_array($aExternals) && 0 < \count($aExternals)) if (\is_array($aExternals) && \count($aExternals))
{ {
$oHttp = \MailSo\Base\Http::SingletonInstance(); $oHttp = \MailSo\Base\Http::SingletonInstance();
@ -590,7 +590,7 @@ trait User
$sValue = (string) $sValue; $sValue = (string) $sValue;
if ($mStringCallback && is_callable($mStringCallback)) if ($mStringCallback && is_callable($mStringCallback))
{ {
$sValue = call_user_func($mStringCallback, $sValue); $sValue = $mStringCallback($sValue);
} }
$oSettings->SetConf($sConfigName, (string) $sValue); $oSettings->SetConf($sConfigName, (string) $sValue);

View file

@ -39,7 +39,7 @@ class Manager
$this->bIsEnabled = (bool) $oConfig->Get('plugins', 'enable', false); $this->bIsEnabled = (bool) $oConfig->Get('plugins', 'enable', false);
if ($this->bIsEnabled) { if ($this->bIsEnabled) {
$sList = $oConfig->Get('plugins', 'enabled_list', ''); $sList = $oConfig->Get('plugins', 'enabled_list', '');
if (0 < \strlen($sList)) { if (\strlen($sList)) {
$aList = \array_map('trim', \explode(',', $sList)); $aList = \array_map('trim', \explode(',', $sList));
foreach ($aList as $i => $sName) { foreach ($aList as $i => $sName) {
$oPlugin = $this->CreatePluginByName($sName); $oPlugin = $this->CreatePluginByName($sName);
@ -169,7 +169,7 @@ class Manager
public function HaveJs(bool $bAdminScope = false) : bool public function HaveJs(bool $bAdminScope = false) : bool
{ {
return $this->bIsEnabled && 0 < \count($this->aJs[$bAdminScope ? 1 : 0]); return $this->bIsEnabled && \count($this->aJs[$bAdminScope ? 1 : 0]);
} }
public function CompileCss(bool $bAdminScope = false) : string public function CompileCss(bool $bAdminScope = false) : string
@ -245,7 +245,7 @@ class Manager
$oPlugin->FilterAppDataPluginSection($bAdmin, $bAuth, $aConfig); $oPlugin->FilterAppDataPluginSection($bAdmin, $bAuth, $aConfig);
if (0 < \count($aConfig)) if (\count($aConfig))
{ {
$aAppData['Plugins'][$oPlugin->Name()] = $aConfig; $aAppData['Plugins'][$oPlugin->Name()] = $aConfig;
} }
@ -323,7 +323,7 @@ class Manager
foreach ($this->aHooks[$sHookName] as $mCallback) foreach ($this->aHooks[$sHookName] as $mCallback)
{ {
\call_user_func_array($mCallback, $aArg); $mCallback(...$aArg);
} }
} }
} }
@ -360,7 +360,7 @@ class Manager
{ {
foreach ($this->aAdditionalParts[$sActionName] as $mCallbak) foreach ($this->aAdditionalParts[$sActionName] as $mCallbak)
{ {
$bCallResult = \call_user_func_array($mCallbak, $aParts); $bCallResult = $mCallbak(...$aParts);
if ($bCallResult && !$bResult) if ($bCallResult && !$bResult)
{ {
$bResult = true; $bResult = true;
@ -404,7 +404,7 @@ class Manager
*/ */
public function AddAdditionalJsonAction(string $sActionName, $mCallback) : self public function AddAdditionalJsonAction(string $sActionName, $mCallback) : self
{ {
if ($this->bIsEnabled && \is_callable($mCallback) && 0 < \strlen($sActionName)) if ($this->bIsEnabled && \is_callable($mCallback) && \strlen($sActionName))
{ {
$sActionName = 'DoPlugin'.$sActionName; $sActionName = 'DoPlugin'.$sActionName;
@ -431,7 +431,7 @@ class Manager
{ {
if (isset($this->aAdditionalJson[$sActionName])) if (isset($this->aAdditionalJson[$sActionName]))
{ {
return \call_user_func($this->aAdditionalJson[$sActionName]); return $this->aAdditionalJson[$sActionName]();
} }
} }

View file

@ -51,7 +51,7 @@ class Service
} }
$sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', '')); $sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', ''));
if (0 < \strlen($sServer)) if (\strlen($sServer))
{ {
\header('Server: '.$sServer); \header('Server: '.$sServer);
} }
@ -114,7 +114,7 @@ class Service
$bIndex = true; $bIndex = true;
$sResult = ''; $sResult = '';
if (0 < \count($aPaths) && !empty($aPaths[0]) && !$bAdmin && 'index' !== \strtolower($aPaths[0])) if (\count($aPaths) && !empty($aPaths[0]) && !$bAdmin && 'index' !== \strtolower($aPaths[0]))
{ {
if (!\SnappyMail\HTTP\SecFetch::isSameOrigin()) { if (!\SnappyMail\HTTP\SecFetch::isSameOrigin()) {
\MailSo\Base\Http::StatusHeader(403); \MailSo\Base\Http::StatusHeader(403);
@ -129,13 +129,13 @@ class Service
$bIndex = false; $bIndex = false;
$sMethodName = 'Service'.\preg_replace('/@.+$/', '', $aPaths[0]); $sMethodName = 'Service'.\preg_replace('/@.+$/', '', $aPaths[0]);
$sMethodExtra = 0 < \strpos($aPaths[0], '@') ? \preg_replace('/^[^@]+@/', '', $aPaths[0]) : ''; $sMethodExtra = \strpos($aPaths[0], '@') ? \preg_replace('/^[^@]+@/', '', $aPaths[0]) : '';
if (\method_exists($this->oServiceActions, $sMethodName) && if (\method_exists($this->oServiceActions, $sMethodName) &&
\is_callable(array($this->oServiceActions, $sMethodName))) \is_callable(array($this->oServiceActions, $sMethodName)))
{ {
$this->oServiceActions->SetQuery($sQuery)->SetPaths($aPaths); $this->oServiceActions->SetQuery($sQuery)->SetPaths($aPaths);
$sResult = \call_user_func(array($this->oServiceActions, $sMethodName), $sMethodExtra); $sResult = $this->oServiceActions->{$sMethodName}($sMethodExtra);
} }
else if (!$this->oActions->Plugins()->RunAdditionalPart($aPaths[0], $aPaths)) else if (!$this->oActions->Plugins()->RunAdditionalPart($aPaths[0], $aPaths))
{ {

View file

@ -99,7 +99,7 @@ class ServiceActions
} }
else if (!empty($sAction)) else if (!empty($sAction))
{ {
if (0 === stripos($sAction, 'Admin') && 'AdminLogin' !== $sAction && 'AdminLogout' !== $sAction) { if (0 === \stripos($sAction, 'Admin') && 'AdminLogin' !== $sAction && 'AdminLogout' !== $sAction) {
$this->oActions->IsAdminLoggined(); $this->oActions->IsAdminLoggined();
} }
@ -140,7 +140,7 @@ class ServiceActions
\is_callable(array($this->oActions, $sMethodName))) \is_callable(array($this->oActions, $sMethodName)))
{ {
$this->Plugins()->RunHook('json.action-pre-call', array($sAction)); $this->Plugins()->RunHook('json.action-pre-call', array($sAction));
$aResponseItem = \call_user_func(array($this->oActions, $sMethodName)); $aResponseItem = $this->oActions->{$sMethodName}();
$this->Plugins()->RunHook('json.action-post-call', array($sAction, &$aResponseItem)); $this->Plugins()->RunHook('json.action-post-call', array($sAction, &$aResponseItem));
} }
else if ($this->Plugins()->HasAdditionalJson($sMethodName)) else if ($this->Plugins()->HasAdditionalJson($sMethodName))
@ -194,7 +194,7 @@ class ServiceActions
if ($this->Logger()->IsEnabled()) if ($this->Logger()->IsEnabled())
{ {
if (0 < \strlen($sObResult)) if (\strlen($sObResult))
{ {
$this->Logger()->Write($sObResult, \MailSo\Log\Enumerations\Type::ERROR, 'OB-DATA'); $this->Logger()->Write($sObResult, \MailSo\Log\Enumerations\Type::ERROR, 'OB-DATA');
} }
@ -223,7 +223,7 @@ class ServiceActions
\is_callable(array($this->oActions, 'Append'))) \is_callable(array($this->oActions, 'Append')))
{ {
isset($_POST) && $this->oActions->SetActionParams($_POST, 'Append'); isset($_POST) && $this->oActions->SetActionParams($_POST, 'Append');
$bResponse = \call_user_func(array($this->oActions, 'Append')); $bResponse = $this->oActions->Append();
} }
} }
catch (\Throwable $oException) catch (\Throwable $oException)
@ -235,7 +235,7 @@ class ServiceActions
$sResult = true === $bResponse ? '1' : '0'; $sResult = true === $bResponse ? '1' : '0';
$sObResult = \ob_get_clean(); $sObResult = \ob_get_clean();
if (0 < \strlen($sObResult)) if (\strlen($sObResult))
{ {
$this->Logger()->Write($sObResult, \MailSo\Log\Enumerations\Type::ERROR, 'OB-DATA'); $this->Logger()->Write($sObResult, \MailSo\Log\Enumerations\Type::ERROR, 'OB-DATA');
} }
@ -279,7 +279,7 @@ class ServiceActions
$aFile = $_FILES[$sInputName]; $aFile = $_FILES[$sInputName];
} }
} }
else if (!isset($_FILES) || !is_array($_FILES) || 0 === count($_FILES)) else if (!isset($_FILES) || !is_array($_FILES) || !\count($_FILES))
{ {
$iError = UPLOAD_ERR_INI_SIZE; $iError = UPLOAD_ERR_INI_SIZE;
} }
@ -298,7 +298,7 @@ class ServiceActions
$this->oActions->SetActionParams($aActionParams, $sAction); $this->oActions->SetActionParams($aActionParams, $sAction);
$aResponseItem = \call_user_func(array($this->oActions, $sAction)); $aResponseItem = $this->oActions->{$sAction}();
} }
if (!is_array($aResponseItem)) if (!is_array($aResponseItem))
@ -317,7 +317,7 @@ class ServiceActions
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem, $this->Logger()); $sResult = \MailSo\Base\Utils::Php2js($aResponseItem, $this->Logger());
$sObResult = \ob_get_clean(); $sObResult = \ob_get_clean();
if (0 < \strlen($sObResult)) if (\strlen($sObResult))
{ {
$this->Logger()->Write($sObResult, \MailSo\Log\Enumerations\Type::ERROR, 'OB-DATA'); $this->Logger()->Write($sObResult, \MailSo\Log\Enumerations\Type::ERROR, 'OB-DATA');
} }
@ -402,7 +402,7 @@ class ServiceActions
'Params' => $this->aPaths 'Params' => $this->aPaths
), $sMethodName); ), $sMethodName);
if (!\call_user_func(array($this->oActions, $sMethodName))) if (!$this->oActions->{$sMethodName}())
{ {
$sRawError = 'False result'; $sRawError = 'False result';
} }
@ -436,7 +436,7 @@ class ServiceActions
$sRawError = 'Exception as result'; $sRawError = 'Exception as result';
} }
if (0 < \strlen($sRawError)) if (\strlen($sRawError))
{ {
$this->oActions->Logger()->Write($sRawError, \MailSo\Log\Enumerations\Type::ERROR); $this->oActions->Logger()->Write($sRawError, \MailSo\Log\Enumerations\Type::ERROR);
$this->oActions->Logger()->WriteDump($this->aPaths, \MailSo\Log\Enumerations\Type::ERROR, 'PATHS'); $this->oActions->Logger()->WriteDump($this->aPaths, \MailSo\Log\Enumerations\Type::ERROR, 'PATHS');
@ -476,10 +476,10 @@ class ServiceActions
$sResult = $this->Cacher()->Get($sCacheFileName); $sResult = $this->Cacher()->Get($sCacheFileName);
} }
if (0 === \strlen($sResult)) if (!\strlen($sResult))
{ {
$sResult = $this->oActions->compileLanguage($sLanguage, $bAdmin); $sResult = $this->oActions->compileLanguage($sLanguage, $bAdmin);
if ($bCacheEnabled && 0 < \strlen($sCacheFileName)) if ($bCacheEnabled && \strlen($sCacheFileName))
{ {
$this->Cacher()->Set($sCacheFileName, $sResult); $this->Cacher()->Set($sCacheFileName, $sResult);
} }
@ -514,10 +514,10 @@ class ServiceActions
$sResult = $this->Cacher()->Get($sCacheFileName); $sResult = $this->Cacher()->Get($sCacheFileName);
} }
if (0 === strlen($sResult)) if (!\strlen($sResult))
{ {
$sResult = $this->Plugins()->CompileJs($bAdmin); $sResult = $this->Plugins()->CompileJs($bAdmin);
if ($bCacheEnabled && 0 < \strlen($sCacheFileName)) if ($bCacheEnabled && \strlen($sCacheFileName))
{ {
$this->Cacher()->Set($sCacheFileName, $sResult); $this->Cacher()->Set($sCacheFileName, $sResult);
} }
@ -678,7 +678,7 @@ class ServiceActions
$sPassword = $mData['Password']; $sPassword = $mData['Password'];
$aAdditionalOptions = isset($mData['AdditionalOptions']) && \is_array($mData['AdditionalOptions']) && $aAdditionalOptions = isset($mData['AdditionalOptions']) && \is_array($mData['AdditionalOptions']) &&
0 < \count($mData['AdditionalOptions']) ? $mData['AdditionalOptions'] : null; \count($mData['AdditionalOptions']) ? $mData['AdditionalOptions'] : null;
try try
{ {
@ -741,7 +741,7 @@ class ServiceActions
$sEmail = $_ENV['REMOTE_USER'] ?? ''; $sEmail = $_ENV['REMOTE_USER'] ?? '';
$sPassword = $_ENV['REMOTE_PASSWORD'] ?? ''; $sPassword = $_ENV['REMOTE_PASSWORD'] ?? '';
if (0 < \strlen($sEmail) && 0 < \strlen(\trim($sPassword))) if (\strlen($sEmail) && \strlen(\trim($sPassword)))
{ {
try try
{ {

View file

@ -1321,7 +1321,7 @@ class lessc {
if ($args[0] == 'list') if ($args[0] == 'list')
$args = self::compressList($args[2], $args[1]); $args = self::compressList($args[2], $args[1]);
$ret = call_user_func($f, $this->reduce($args, true), $this); $ret = $f($this->reduce($args, true), $this);
if (is_null($ret)) { if (is_null($ret)) {
return array("string", "", array( return array("string", "", array(