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