mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 08:57:03 +03:00
More params and returns to PHP 7.3+
This commit is contained in:
parent
3d246ae842
commit
26c38b3ec9
95 changed files with 1028 additions and 4865 deletions
|
|
@ -42,11 +42,6 @@ class Logger extends \MailSo\Base\Collection
|
|||
*/
|
||||
private $bHideErrorNotices;
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
*
|
||||
* @param bool $bRegPhpErrorHandler = false
|
||||
*/
|
||||
protected function __construct($bRegPhpErrorHandler = true)
|
||||
{
|
||||
parent::__construct();
|
||||
|
|
@ -65,22 +60,15 @@ class Logger extends \MailSo\Base\Collection
|
|||
\register_shutdown_function(array(&$this, '__loggerShutDown'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bRegPhpErrorHandler = false
|
||||
*
|
||||
* @return \MailSo\Log\Logger
|
||||
*/
|
||||
public static function NewInstance($bRegPhpErrorHandler = false)
|
||||
public static function NewInstance(bool $bRegPhpErrorHandler = false) : self
|
||||
{
|
||||
return new self($bRegPhpErrorHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @staticvar \MailSo\Log\Logger $oInstance;
|
||||
*
|
||||
* @return \MailSo\Log\Logger
|
||||
*/
|
||||
public static function SingletonInstance()
|
||||
public static function SingletonInstance() : self
|
||||
{
|
||||
static $oInstance = null;
|
||||
if (null === $oInstance)
|
||||
|
|
@ -91,34 +79,23 @@ class Logger extends \MailSo\Base\Collection
|
|||
return $oInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFormat
|
||||
* @param string $sTimeOffset = '0'
|
||||
* @param int $iTimestamp = 0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function DateHelper($sFormat, $sTimeOffset = '0', $iTimestamp = null)
|
||||
public static function DateHelper(string $sFormat, string $sTimeOffset = '0', int $iTimestamp = null) : string
|
||||
{
|
||||
$iTimestamp = null === $iTimestamp ? \time() : (int) $iTimestamp;
|
||||
return \gmdate($sFormat, $iTimestamp + \MailSo\Base\DateTimeHelper::TimeToSec((string) $sTimeOffset));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function IsSystemEnabled()
|
||||
public static function IsSystemEnabled() : bool
|
||||
{
|
||||
return !!(\MailSo\Config::$SystemLogger instanceof \MailSo\Log\Logger);
|
||||
return !!(\MailSo\Config::$SystemLogger instanceof Logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mData
|
||||
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
|
||||
*/
|
||||
public static function SystemLog($mData, $iType = \MailSo\Log\Enumerations\Type::INFO)
|
||||
public static function SystemLog($mData, int $iType = \MailSo\Log\Enumerations\Type::INFO)
|
||||
{
|
||||
if (\MailSo\Config::$SystemLogger instanceof \MailSo\Log\Logger)
|
||||
if (\MailSo\Config::$SystemLogger instanceof Logger)
|
||||
{
|
||||
\MailSo\Config::$SystemLogger->WriteMixed($mData, $iType);
|
||||
}
|
||||
|
|
@ -126,10 +103,8 @@ class Logger extends \MailSo\Base\Collection
|
|||
|
||||
/**
|
||||
* @staticvar string $sCache;
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function Guid()
|
||||
public static function Guid() : string
|
||||
{
|
||||
static $sCache = null;
|
||||
if (null === $sCache)
|
||||
|
|
@ -140,28 +115,17 @@ class Logger extends \MailSo\Base\Collection
|
|||
return $sCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function Ping()
|
||||
public function Ping() : bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsEnabled()
|
||||
public function IsEnabled() : bool
|
||||
{
|
||||
return 0 < $this->Count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sWord
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function AddSecret($sWord)
|
||||
public function AddSecret(string $sWord) : bool
|
||||
{
|
||||
if (\is_string($sWord) && 0 < \strlen(\trim($sWord)))
|
||||
{
|
||||
|
|
@ -170,68 +134,37 @@ class Logger extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bShow
|
||||
*
|
||||
* @return \MailSo\Log\Logger
|
||||
*/
|
||||
public function SetShowSecter($bShow)
|
||||
public function SetShowSecter(bool $bShow) : self
|
||||
{
|
||||
$this->bShowSecter = !!$bShow;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bValue
|
||||
*
|
||||
* @return \MailSo\Log\Logger
|
||||
*/
|
||||
public function HideErrorNotices($bValue)
|
||||
public function HideErrorNotices(bool $bValue) : self
|
||||
{
|
||||
$this->bHideErrorNotices = !!$bValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsShowSecter()
|
||||
public function IsShowSecter() : bool
|
||||
{
|
||||
return $this->bShowSecter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iType
|
||||
*
|
||||
* @return \MailSo\Log\Logger
|
||||
*/
|
||||
public function AddForbiddenType($iType)
|
||||
public function AddForbiddenType(int $iType) : self
|
||||
{
|
||||
$this->aForbiddenTypes[$iType] = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iType
|
||||
*
|
||||
* @return \MailSo\Log\Logger
|
||||
*/
|
||||
public function RemoveForbiddenType($iType)
|
||||
public function RemoveForbiddenType(int $iType) : self
|
||||
{
|
||||
$this->aForbiddenTypes[$iType] = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iErrNo
|
||||
* @param string $sErrStr
|
||||
* @param string $sErrFile
|
||||
* @param int $iErrLine
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __phpErrorHandler($iErrNo, $sErrStr, $sErrFile, $iErrLine)
|
||||
public function __phpErrorHandler(int $iErrNo, string $sErrStr, string $sErrFile, int $iErrLine) : bool
|
||||
{
|
||||
$iType = \MailSo\Log\Enumerations\Type::NOTICE_PHP;
|
||||
switch ($iErrNo)
|
||||
|
|
@ -271,10 +204,7 @@ class Logger extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function WriteEmptyLine()
|
||||
public function WriteEmptyLine() : bool
|
||||
{
|
||||
$iResult = 1;
|
||||
|
||||
|
|
@ -287,17 +217,8 @@ class Logger extends \MailSo\Base\Collection
|
|||
return (bool) $iResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sDesc
|
||||
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
|
||||
* @param string $sName = ''
|
||||
* @param bool $bSearchSecretWords = true
|
||||
* @param bool $bDiplayCrLf = false
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function Write($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO,
|
||||
$sName = '', $bSearchSecretWords = true, $bDiplayCrLf = false)
|
||||
public function Write(string $sDesc, int $iType = \MailSo\Log\Enumerations\Type::INFO,
|
||||
string $sName = '', bool $bSearchSecretWords = true, bool $bDiplayCrLf = false) : bool
|
||||
{
|
||||
if (isset($this->aForbiddenTypes[$iType]) && true === $this->aForbiddenTypes[$iType])
|
||||
{
|
||||
|
|
@ -326,32 +247,17 @@ class Logger extends \MailSo\Base\Collection
|
|||
|
||||
/**
|
||||
* @param mixed $oValue
|
||||
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
|
||||
* @param string $sName = ''
|
||||
* @param bool $bSearchSecretWords = false
|
||||
* @param bool $bDiplayCrLf = false
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function WriteDump($oValue, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '',
|
||||
$bSearchSecretWords = false, $bDiplayCrLf = false)
|
||||
public function WriteDump($oValue, int $iType = \MailSo\Log\Enumerations\Type::INFO, string $sName = '',
|
||||
bool $bSearchSecretWords = false, bool $bDiplayCrLf = false) : bool
|
||||
{
|
||||
return $this->Write(\print_r($oValue, true), $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Exception $oException
|
||||
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE
|
||||
* @param string $sName = ''
|
||||
* @param bool $bSearchSecretWords = true
|
||||
* @param bool $bDiplayCrLf = false
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function WriteException($oException, $iType = \MailSo\Log\Enumerations\Type::NOTICE, $sName = '',
|
||||
$bSearchSecretWords = true, $bDiplayCrLf = false)
|
||||
public function WriteException(\Throwable $oException, int $iType = \MailSo\Log\Enumerations\Type::NOTICE, string $sName = '',
|
||||
bool $bSearchSecretWords = true, bool $bDiplayCrLf = false) : bool
|
||||
{
|
||||
if ($oException instanceof \Exception)
|
||||
if ($oException instanceof \Throwable)
|
||||
{
|
||||
if (isset($oException->__LOGINNED__))
|
||||
{
|
||||
|
|
@ -366,19 +272,10 @@ class Logger extends \MailSo\Base\Collection
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Exception $oException
|
||||
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE
|
||||
* @param string $sName = ''
|
||||
* @param bool $bSearchSecretWords = true
|
||||
* @param bool $bDiplayCrLf = false
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function WriteExceptionShort($oException, $iType = \MailSo\Log\Enumerations\Type::NOTICE, $sName = '',
|
||||
$bSearchSecretWords = true, $bDiplayCrLf = false)
|
||||
public function WriteExceptionShort(\Throwable $oException, int $iType = \MailSo\Log\Enumerations\Type::NOTICE, string $sName = '',
|
||||
bool $bSearchSecretWords = true, bool $bDiplayCrLf = false) : bool
|
||||
{
|
||||
if ($oException instanceof \Exception)
|
||||
if ($oException instanceof \Throwable)
|
||||
{
|
||||
if (isset($oException->__LOGINNED__))
|
||||
{
|
||||
|
|
@ -395,20 +292,14 @@ class Logger extends \MailSo\Base\Collection
|
|||
|
||||
/**
|
||||
* @param mixed $mData
|
||||
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE
|
||||
* @param string $sName = ''
|
||||
* @param bool $bSearchSecretWords = true
|
||||
* @param bool $bDiplayCrLf = false
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function WriteMixed($mData, $iType = null, $sName = '',
|
||||
$bSearchSecretWords = true, $bDiplayCrLf = false)
|
||||
public function WriteMixed($mData, int $iType = null, string $sName = '',
|
||||
bool $bSearchSecretWords = true, bool $bDiplayCrLf = false) : bool
|
||||
{
|
||||
$iType = null === $iType ? \MailSo\Log\Enumerations\Type::INFO : $iType;
|
||||
if (\is_array($mData) || \is_object($mData))
|
||||
{
|
||||
if ($mData instanceof \Exception)
|
||||
if ($mData instanceof \Throwable)
|
||||
{
|
||||
$iType = null === $iType ? \MailSo\Log\Enumerations\Type::NOTICE : $iType;
|
||||
return $this->WriteException($mData, $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue