mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-10-27 23:53:32 +03:00
Use union and mixed type declaration
This commit is contained in:
parent
08bc097dd4
commit
03151d72a0
67 changed files with 773 additions and 963 deletions
|
|
@ -25,10 +25,7 @@ abstract class Collection extends \ArrayObject implements \JsonSerializable
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mItem
|
||||
*/
|
||||
public function append($mItem, bool $bToTop = false) : void
|
||||
public function append(mixed $mItem, bool $bToTop = false): void
|
||||
{
|
||||
if ($bToTop) {
|
||||
$array = $this->getArrayCopy();
|
||||
|
|
@ -39,18 +36,18 @@ abstract class Collection extends \ArrayObject implements \JsonSerializable
|
|||
}
|
||||
}
|
||||
|
||||
public function keys() : array
|
||||
public function keys(): array
|
||||
{
|
||||
return \array_keys($this->getArrayCopy());
|
||||
}
|
||||
|
||||
public function Add($mItem, bool $bToTop = false) : self
|
||||
public function Add($mItem, bool $bToTop = false): self
|
||||
{
|
||||
$this->append($mItem, $bToTop);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function Clear() : void
|
||||
public function Clear(): void
|
||||
{
|
||||
$this->exchangeArray([]);
|
||||
}
|
||||
|
|
@ -64,14 +61,14 @@ abstract class Collection extends \ArrayObject implements \JsonSerializable
|
|||
return $callable($this->getArrayCopy(), ...$arguments);
|
||||
}
|
||||
*/
|
||||
public function Slice(int $offset, ?int $length = null, bool $preserve_keys = false)
|
||||
public function Slice(int $offset, ?int $length = null, bool $preserve_keys = false)/*: static*/
|
||||
{
|
||||
return new static(
|
||||
\array_slice($this->getArrayCopy(), $offset, $length, $preserve_keys)
|
||||
);
|
||||
}
|
||||
|
||||
public function Crop(?int $length = null, int $offset = 0, bool $preserve_keys = false)
|
||||
public function Crop(?int $length = null, int $offset = 0, bool $preserve_keys = false): self
|
||||
{
|
||||
$this->exchangeArray(
|
||||
\array_slice($this->getArrayCopy(), $offset, $length, $preserve_keys)
|
||||
|
|
@ -79,8 +76,8 @@ abstract class Collection extends \ArrayObject implements \JsonSerializable
|
|||
return $this;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$aNames = \explode('\\', \get_class($this));
|
||||
return array(
|
||||
|
|
|
|||
|
|
@ -40,27 +40,27 @@ class BodyStructure implements \JsonSerializable
|
|||
*/
|
||||
private array $aSubParts;
|
||||
|
||||
public function Charset() : string
|
||||
public function Charset(): string
|
||||
{
|
||||
return $this->sCharset;
|
||||
}
|
||||
|
||||
public function ContentTransferEncoding() : string
|
||||
public function ContentTransferEncoding(): string
|
||||
{
|
||||
return $this->sContentTransferEncoding;
|
||||
}
|
||||
|
||||
public function ContentType() : string
|
||||
public function ContentType(): string
|
||||
{
|
||||
return $this->sContentType;
|
||||
}
|
||||
|
||||
public function PartID() : string
|
||||
public function PartID(): string
|
||||
{
|
||||
return $this->sPartID;
|
||||
}
|
||||
|
||||
public function FileName(bool $bCalculateOnEmpty = false) : string
|
||||
public function FileName(bool $bCalculateOnEmpty = false): string
|
||||
{
|
||||
$sFileName = \trim($this->sFileName);
|
||||
if (\strlen($sFileName) || !$bCalculateOnEmpty) {
|
||||
|
|
@ -90,7 +90,7 @@ class BodyStructure implements \JsonSerializable
|
|||
return ($this->isInline() ? 'inline' : 'part' ) . $sIdx;
|
||||
}
|
||||
|
||||
public function EstimatedSize() : int
|
||||
public function EstimatedSize(): int
|
||||
{
|
||||
$fCoefficient = 1;
|
||||
switch ($this->sContentTransferEncoding)
|
||||
|
|
@ -106,17 +106,17 @@ class BodyStructure implements \JsonSerializable
|
|||
return (int) ($this->iSize * $fCoefficient);
|
||||
}
|
||||
|
||||
public function SubParts() : array
|
||||
public function SubParts(): array
|
||||
{
|
||||
return $this->aSubParts;
|
||||
}
|
||||
|
||||
public function isInline() : bool
|
||||
public function isInline(): bool
|
||||
{
|
||||
return 'inline' === $this->sDisposition || \strlen($this->sContentID);
|
||||
}
|
||||
|
||||
public function isText() : bool
|
||||
public function isText(): bool
|
||||
{
|
||||
return 'text/html' === $this->sContentType
|
||||
|| 'text/plain' === $this->sContentType
|
||||
|
|
@ -125,7 +125,7 @@ class BodyStructure implements \JsonSerializable
|
|||
}
|
||||
|
||||
// https://datatracker.ietf.org/doc/html/rfc3156#section-4
|
||||
public function isPgpEncrypted() : bool
|
||||
public function isPgpEncrypted(): bool
|
||||
{
|
||||
return 'multipart/encrypted' === $this->sContentType
|
||||
&& !empty($this->aContentTypeParams['protocol'])
|
||||
|
|
@ -138,7 +138,7 @@ class BodyStructure implements \JsonSerializable
|
|||
}
|
||||
|
||||
// https://datatracker.ietf.org/doc/html/rfc3156#section-5
|
||||
public function isPgpSigned() : bool
|
||||
public function isPgpSigned(): bool
|
||||
{
|
||||
return 'multipart/signed' === $this->sContentType
|
||||
&& !empty($this->aContentTypeParams['protocol'])
|
||||
|
|
@ -149,7 +149,7 @@ class BodyStructure implements \JsonSerializable
|
|||
}
|
||||
|
||||
// https://datatracker.ietf.org/doc/html/rfc2633#section-3.3
|
||||
public function isSMimeEncrypted() : bool
|
||||
public function isSMimeEncrypted(): bool
|
||||
{
|
||||
$type = \strtolower(\trim($this->aContentTypeParams['smime-type'] ?? ''));
|
||||
return ContentType::isPkcs7Mime($this->sContentType)
|
||||
|
|
@ -158,7 +158,7 @@ class BodyStructure implements \JsonSerializable
|
|||
}
|
||||
|
||||
// https://www.rfc-editor.org/rfc/rfc8551.html#section-3.5
|
||||
public function isSMimeSigned() : bool
|
||||
public function isSMimeSigned(): bool
|
||||
{
|
||||
return ('multipart/signed' === $this->sContentType
|
||||
&& !empty($this->aContentTypeParams['protocol'])
|
||||
|
|
@ -172,7 +172,7 @@ class BodyStructure implements \JsonSerializable
|
|||
);
|
||||
}
|
||||
|
||||
protected function IsAttachment(/*BodyStructure*/ $oParent) : bool
|
||||
protected function IsAttachment(/*BodyStructure*/ $oParent): bool
|
||||
{
|
||||
// return 'application/pgp-encrypted' !== $this->sContentType
|
||||
return (!$oParent || !$oParent->isPgpEncrypted())
|
||||
|
|
@ -184,14 +184,14 @@ class BodyStructure implements \JsonSerializable
|
|||
);
|
||||
}
|
||||
|
||||
public function IsFlowedFormat() : bool
|
||||
public function IsFlowedFormat(): bool
|
||||
{
|
||||
return !empty($this->aContentTypeParams['format'])
|
||||
&& 'flowed' === \strtolower(\trim($this->aContentTypeParams['format']))
|
||||
&& !\in_array($this->sContentTransferEncoding, array('base64', 'quoted-printable'));
|
||||
}
|
||||
|
||||
public function GetHtmlAndPlainParts() : array
|
||||
public function GetHtmlAndPlainParts(): array
|
||||
{
|
||||
$aParts = [];
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ class BodyStructure implements \JsonSerializable
|
|||
return $aParts;
|
||||
}
|
||||
|
||||
public function SearchCharset() : string
|
||||
public function SearchCharset(): string
|
||||
{
|
||||
$gParts = $this->SearchByCallback(function ($oPart, $oParent) {
|
||||
return $oPart->Charset() && $oPart->isText() && !$oPart->IsAttachment($oParent);
|
||||
|
|
@ -246,7 +246,7 @@ class BodyStructure implements \JsonSerializable
|
|||
return $gParts->valid() ? $gParts->current()->Charset() : '';
|
||||
}
|
||||
|
||||
public function SearchByCallback(callable $fCallback, /*BodyStructure*/ $parent = null) : iterable
|
||||
public function SearchByCallback(callable $fCallback, /*?BodyStructure*/ $parent = null): iterable
|
||||
{
|
||||
if ($fCallback($this, $parent)) {
|
||||
yield $this;
|
||||
|
|
@ -256,7 +256,7 @@ class BodyStructure implements \JsonSerializable
|
|||
}
|
||||
}
|
||||
|
||||
public function SearchAttachmentsParts() : iterable
|
||||
public function SearchAttachmentsParts(): iterable
|
||||
{
|
||||
return $this->SearchByCallback(function ($oItem, $oParent) {
|
||||
// return $oItem->IsAttachment();
|
||||
|
|
@ -264,7 +264,7 @@ class BodyStructure implements \JsonSerializable
|
|||
});
|
||||
}
|
||||
|
||||
public function SearchByContentType(string $sContentType) : iterable
|
||||
public function SearchByContentType(string $sContentType): iterable
|
||||
{
|
||||
$sContentType = \strtolower($sContentType);
|
||||
return $this->SearchByCallback(function ($oItem) use ($sContentType) {
|
||||
|
|
@ -272,14 +272,14 @@ class BodyStructure implements \JsonSerializable
|
|||
});
|
||||
}
|
||||
|
||||
public function SearchByContentTypes(array $aContentTypes) : iterable
|
||||
public function SearchByContentTypes(array $aContentTypes): iterable
|
||||
{
|
||||
return $this->SearchByCallback(function ($oItem) use ($aContentTypes) {
|
||||
return \in_array($oItem->sContentType, $aContentTypes);
|
||||
});
|
||||
}
|
||||
|
||||
public function GetPartByMimeIndex(string $sMimeIndex) : self
|
||||
public function GetPartByMimeIndex(string $sMimeIndex): self
|
||||
{
|
||||
$oPart = null;
|
||||
if (\strlen($sMimeIndex)) {
|
||||
|
|
@ -300,7 +300,7 @@ class BodyStructure implements \JsonSerializable
|
|||
return $oPart;
|
||||
}
|
||||
|
||||
private static function decodeAttrParameter(array $aParams, string $sParamName, string $sCharset) : string
|
||||
private static function decodeAttrParameter(array $aParams, string $sParamName, string $sCharset): string
|
||||
{
|
||||
$sResult = '';
|
||||
if (isset($aParams[$sParamName])) {
|
||||
|
|
@ -349,7 +349,7 @@ class BodyStructure implements \JsonSerializable
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
public static function NewInstance(array $aBodyStructure, string $sPartID = '') : ?self
|
||||
public static function NewInstance(array $aBodyStructure, string $sPartID = ''): ?self
|
||||
{
|
||||
if (2 > \count($aBodyStructure)) {
|
||||
return null;
|
||||
|
|
@ -542,7 +542,7 @@ class BodyStructure implements \JsonSerializable
|
|||
* Returns dict with key="charset" and value="US-ASCII" for array ("CHARSET" "US-ASCII").
|
||||
* Keys are lowercased (StringDictionary itself does this), values are not altered.
|
||||
*/
|
||||
private static function getKeyValueListFromArrayList(array $aList) : array
|
||||
private static function getKeyValueListFromArrayList(array $aList): array
|
||||
{
|
||||
$aDict = array();
|
||||
$iLen = \count($aList);
|
||||
|
|
@ -557,8 +557,8 @@ class BodyStructure implements \JsonSerializable
|
|||
return $aDict;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array(
|
||||
'mimeIndex' => $this->sPartID,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class FetchResponse
|
|||
$this->oImapResponse = $oImapResponse;
|
||||
}
|
||||
|
||||
public function GetEnvelope(bool $bForce = false) : ?array
|
||||
public function GetEnvelope(bool $bForce = false): ?array
|
||||
{
|
||||
if (null === $this->aEnvelopeCache || $bForce) {
|
||||
$this->aEnvelopeCache = $this->GetFetchValue(Enumerations\FetchType::ENVELOPE);
|
||||
|
|
@ -34,15 +34,12 @@ class FetchResponse
|
|||
return $this->aEnvelopeCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetFetchEnvelopeValue(int $iIndex, ?string $mNullResult = null)
|
||||
public function GetFetchEnvelopeValue(int $iIndex, ?string $mNullResult = null): mixed
|
||||
{
|
||||
return self::findEnvelopeIndex($this->GetEnvelope(), $iIndex, $mNullResult);
|
||||
}
|
||||
|
||||
public function GetFetchEnvelopeEmailCollection(int $iIndex, string $sParentCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1) : ?\MailSo\Mime\EmailCollection
|
||||
public function GetFetchEnvelopeEmailCollection(int $iIndex, string $sParentCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1): ?\MailSo\Mime\EmailCollection
|
||||
{
|
||||
$oResult = null;
|
||||
$aEmails = $this->GetFetchEnvelopeValue($iIndex);
|
||||
|
|
@ -71,7 +68,7 @@ class FetchResponse
|
|||
return $oResult;
|
||||
}
|
||||
|
||||
public function GetFetchBodyStructure() : ?BodyStructure
|
||||
public function GetFetchBodyStructure(): ?BodyStructure
|
||||
{
|
||||
$aBodyStructureArray = $this->GetFetchValue(Enumerations\FetchType::BODYSTRUCTURE);
|
||||
|
||||
|
|
@ -82,9 +79,8 @@ class FetchResponse
|
|||
|
||||
/**
|
||||
* Like: UID, RFC822.SIZE, MODSEQ, INTERNALDATE, FLAGS, BODYSTRUCTURE
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetFetchValue(string $sFetchItemName)
|
||||
public function GetFetchValue(string $sFetchItemName): mixed
|
||||
{
|
||||
if (isset($this->oImapResponse->ResponseList[3]) && \is_array($this->oImapResponse->ResponseList[3])) {
|
||||
$bNextIsValue = false;
|
||||
|
|
@ -104,9 +100,8 @@ class FetchResponse
|
|||
|
||||
/**
|
||||
* Like: BODY[HEADER.FIELDS (RETURN-PATH RECEIVED MIME-VERSION MESSAGE-ID CONTENT-TYPE FROM TO CC BCC SENDER REPLY-TO DELIVERED-TO IN-REPLY-TO REFERENCES DATE SUBJECT SENSITIVITY X-MSMAIL-PRIORITY IMPORTANCE X-PRIORITY X-DRAFT-INFO RETURN-RECEIPT-TO DISPOSITION-NOTIFICATION-TO X-CONFIRM-READING-TO AUTHENTICATION-RESULTS X-DKIM-AUTHENTICATION-RESULTS LIST-UNSUBSCRIBE X-SPAM-STATUS X-SPAMD-RESULT X-BOGOSITY X-VIRUS X-VIRUS-SCANNED X-VIRUS-STATUS)]
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetHeaderFieldsValue() : string
|
||||
public function GetHeaderFieldsValue(): string
|
||||
{
|
||||
$bNextIsValue = false;
|
||||
|
||||
|
|
@ -129,7 +124,7 @@ class FetchResponse
|
|||
return '';
|
||||
}
|
||||
|
||||
public static function isValidImapResponse(Response $oImapResponse) : bool
|
||||
public static function isValidImapResponse(Response $oImapResponse): bool
|
||||
{
|
||||
return
|
||||
!$oImapResponse->IsStatusResponse
|
||||
|
|
@ -138,16 +133,13 @@ class FetchResponse
|
|||
&& \is_array($oImapResponse->ResponseList[3]);
|
||||
}
|
||||
|
||||
public static function hasUidAndSize(Response $oImapResponse) : bool
|
||||
public static function hasUidAndSize(Response $oImapResponse): bool
|
||||
{
|
||||
return \in_array(Enumerations\FetchType::UID, $oImapResponse->ResponseList[3])
|
||||
&& \in_array(Enumerations\FetchType::RFC822_SIZE, $oImapResponse->ResponseList[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
private static function findEnvelopeIndex(array $aEnvelope, int $iIndex, ?string $mNullResult)
|
||||
private static function findEnvelopeIndex(array $aEnvelope, int $iIndex, ?string $mNullResult): mixed
|
||||
{
|
||||
return (isset($aEnvelope[$iIndex]) && '' !== $aEnvelope[$iIndex])
|
||||
? $aEnvelope[$iIndex] : $mNullResult;
|
||||
|
|
|
|||
|
|
@ -53,22 +53,22 @@ class Folder implements \JsonSerializable
|
|||
*/
|
||||
}
|
||||
|
||||
public function setAttributes(array $aAttributes) : void
|
||||
public function setAttributes(array $aAttributes): void
|
||||
{
|
||||
$this->aAttributes = \array_map('mb_strtolower', $aAttributes);
|
||||
}
|
||||
|
||||
public function setSubscribed() : void
|
||||
public function setSubscribed(): void
|
||||
{
|
||||
$this->aAttributes = \array_unique(\array_merge($this->aAttributes, ['\\subscribed']));
|
||||
}
|
||||
|
||||
public function setDelimiter(?string $sDelimiter) : void
|
||||
public function setDelimiter(?string $sDelimiter): void
|
||||
{
|
||||
$this->sDelimiter = $sDelimiter;
|
||||
}
|
||||
|
||||
public function Name() : string
|
||||
public function Name(): string
|
||||
{
|
||||
$sNameRaw = $this->FullName;
|
||||
if ($this->sDelimiter) {
|
||||
|
|
@ -78,49 +78,49 @@ class Folder implements \JsonSerializable
|
|||
return $sNameRaw;
|
||||
}
|
||||
|
||||
public function Delimiter() : ?string
|
||||
public function Delimiter(): ?string
|
||||
{
|
||||
return $this->sDelimiter;
|
||||
}
|
||||
|
||||
public function Selectable() : bool
|
||||
public function Selectable(): bool
|
||||
{
|
||||
return !\in_array('\\noselect', $this->aAttributes)
|
||||
&& !\in_array('\\nonexistent', $this->aAttributes);
|
||||
}
|
||||
|
||||
public function IsSubscribed() : bool
|
||||
public function IsSubscribed(): bool
|
||||
{
|
||||
return \in_array('\\subscribed', $this->aAttributes);
|
||||
}
|
||||
|
||||
public function IsInbox() : bool
|
||||
public function IsInbox(): bool
|
||||
{
|
||||
return 'INBOX' === \strtoupper($this->FullName) || \in_array('\\inbox', $this->aAttributes);
|
||||
}
|
||||
|
||||
public function SetMetadata(string $sName, string $sData) : void
|
||||
public function SetMetadata(string $sName, string $sData): void
|
||||
{
|
||||
$this->aMetadata[$sName] = $sData;
|
||||
}
|
||||
|
||||
public function SetAllMetadata(array $aMetadata) : void
|
||||
public function SetAllMetadata(array $aMetadata): void
|
||||
{
|
||||
$this->aMetadata = $aMetadata;
|
||||
}
|
||||
|
||||
public function GetMetadata(string $sName) : ?string
|
||||
public function GetMetadata(string $sName): ?string
|
||||
{
|
||||
return isset($this->aMetadata[$sName]) ? $this->aMetadata[$sName] : null;
|
||||
}
|
||||
|
||||
public function Metadata() : array
|
||||
public function Metadata(): array
|
||||
{
|
||||
return $this->aMetadata;
|
||||
}
|
||||
|
||||
// JMAP RFC 8621
|
||||
public function Role() : ?string
|
||||
public function Role(): ?string
|
||||
{
|
||||
$role = \strtolower($this->GetMetadata(MetadataKeys::SPECIALUSE) ?: '');
|
||||
if (!$role) {
|
||||
|
|
@ -145,8 +145,8 @@ class Folder implements \JsonSerializable
|
|||
return $role ? \ltrim($role, '\\') : null;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$selectable = $this->Selectable();
|
||||
$result = array(
|
||||
|
|
|
|||
|
|
@ -19,14 +19,14 @@ class FolderCollection extends \MailSo\Base\Collection
|
|||
{
|
||||
// public bool $Optimized = false;
|
||||
|
||||
public function append($oFolder, bool $bToTop = false) : void
|
||||
public function append($oFolder, bool $bToTop = false): void
|
||||
{
|
||||
assert($oFolder instanceof Folder);
|
||||
parent::append($oFolder, $bToTop);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array(
|
||||
'@Object' => 'Collection/FolderCollection',
|
||||
|
|
|
|||
|
|
@ -40,15 +40,15 @@ class FolderInformation implements \JsonSerializable
|
|||
$this->IsWritable = $bIsWritable;
|
||||
}
|
||||
|
||||
public function IsFlagSupported(string $sFlag) : bool
|
||||
public function IsFlagSupported(string $sFlag): bool
|
||||
{
|
||||
return \in_array('\\*', $this->PermanentFlags)
|
||||
|| \in_array($sFlag, $this->PermanentFlags);
|
||||
// || \in_array($sFlag, $this->Flags);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$result = array(
|
||||
'id' => $this->MAILBOXID,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
*/
|
||||
private bool $UTF8 = false;
|
||||
|
||||
public function Hash() : string
|
||||
public function Hash(): string
|
||||
{
|
||||
return \md5('ImapClientHash/'.
|
||||
$this->Settings->username . '@' .
|
||||
|
|
@ -64,8 +64,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
// public function Connect(Settings $oSettings) : void
|
||||
public function Connect(\MailSo\Net\ConnectSettings $oSettings) : void
|
||||
// public function Connect(Settings $oSettings): void
|
||||
public function Connect(\MailSo\Net\ConnectSettings $oSettings): void
|
||||
{
|
||||
$this->aTagTimeouts['*'] = \microtime(true);
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
}
|
||||
}
|
||||
|
||||
private function StartTLS() : void
|
||||
private function StartTLS(): void
|
||||
{
|
||||
if ($this->hasCapability('STARTTLS')) {
|
||||
$this->SendRequestGetResponse('STARTTLS');
|
||||
|
|
@ -93,7 +93,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
}
|
||||
}
|
||||
|
||||
public function supportsAuthType(string $sasl_type) : bool
|
||||
public function supportsAuthType(string $sasl_type): bool
|
||||
{
|
||||
return $this->hasCapability("AUTH={$sasl_type}");
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function Login(Settings $oSettings) : self
|
||||
public function Login(Settings $oSettings): self
|
||||
{
|
||||
if ($this->bIsLoggined) {
|
||||
return $this;
|
||||
|
|
@ -242,7 +242,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function Logout() : void
|
||||
public function Logout(): void
|
||||
{
|
||||
if ($this->bIsLoggined) {
|
||||
$this->bIsLoggined = false;
|
||||
|
|
@ -250,12 +250,12 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
}
|
||||
}
|
||||
|
||||
public function IsLoggined() : bool
|
||||
public function IsLoggined(): bool
|
||||
{
|
||||
return $this->IsConnected() && $this->bIsLoggined;
|
||||
}
|
||||
|
||||
public function IsSelected() : bool
|
||||
public function IsSelected(): bool
|
||||
{
|
||||
return $this->IsLoggined() && $this->oCurrentFolderInfo;
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function Capability() : ?array
|
||||
public function Capability(): ?array
|
||||
{
|
||||
if (!$this->aCapaRaw) {
|
||||
$this->setCapabilities($this->SendRequestGetResponse('CAPABILITY'));
|
||||
|
|
@ -276,7 +276,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
return $this->aCapa;
|
||||
}
|
||||
|
||||
public function Capabilities() : ?array
|
||||
public function Capabilities(): ?array
|
||||
{
|
||||
if (!$this->aCapaRaw) {
|
||||
$this->Capability();
|
||||
|
|
@ -284,7 +284,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
return $this->aCapaRaw;
|
||||
}
|
||||
|
||||
public function CapabilityValue(string $sExtentionName) : ?string
|
||||
public function CapabilityValue(string $sExtentionName): ?string
|
||||
{
|
||||
$sExtentionName = \trim($sExtentionName) . '=';
|
||||
$aCapabilities = $this->Capability() ?: [];
|
||||
|
|
@ -296,7 +296,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
return null;
|
||||
}
|
||||
|
||||
private function setCapabilities(ResponseCollection $oResponseCollection) : void
|
||||
private function setCapabilities(ResponseCollection $oResponseCollection): void
|
||||
{
|
||||
$aList = $oResponseCollection->getCapabilityResult();
|
||||
$this->aCapaRaw = $aList;
|
||||
|
|
@ -330,7 +330,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function hasCapability(string $sExtentionName) : bool
|
||||
public function hasCapability(string $sExtentionName): bool
|
||||
{
|
||||
$sExtentionName = \trim($sExtentionName);
|
||||
return $sExtentionName && \in_array(\strtoupper($sExtentionName), $this->Capability() ?: []);
|
||||
|
|
@ -339,7 +339,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
/**
|
||||
* RFC 5161
|
||||
*/
|
||||
public function Enable(/*string|array*/ $mCapabilityNames) : void
|
||||
public function Enable(string|array $mCapabilityNames): void
|
||||
{
|
||||
if (\is_string($mCapabilityNames)) {
|
||||
$mCapabilityNames = [$mCapabilityNames];
|
||||
|
|
@ -354,7 +354,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function GetNamespaces() : ?NamespaceResult
|
||||
public function GetNamespaces(): ?NamespaceResult
|
||||
{
|
||||
if (!$this->hasCapability('NAMESPACE')) {
|
||||
return null;
|
||||
|
|
@ -382,7 +382,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* and that the client will need to discover upload limits for each mailbox,
|
||||
* as they might differ from mailbox to mailbox.
|
||||
*/
|
||||
public function AppendLimit() : ?int
|
||||
public function AppendLimit(): ?int
|
||||
{
|
||||
$string = $this->CapabilityValue('APPENDLIMIT');
|
||||
return \is_null($string) ? null : (int) $string;
|
||||
|
|
@ -393,7 +393,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function Noop() : self
|
||||
public function Noop(): self
|
||||
{
|
||||
$this->SendRequestGetResponse('NOOP');
|
||||
return $this;
|
||||
|
|
@ -405,7 +405,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function SendRequest(string $sCommand, array $aParams = array(), bool $bBreakOnLiteral = false) : string
|
||||
public function SendRequest(string $sCommand, array $aParams = array(), bool $bBreakOnLiteral = false): string
|
||||
{
|
||||
$sCommand = \trim($sCommand);
|
||||
if (!\strlen($sCommand)) {
|
||||
|
|
@ -438,13 +438,13 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function SendRequestGetResponse(string $sCommand, array $aParams = array()) : ResponseCollection
|
||||
public function SendRequestGetResponse(string $sCommand, array $aParams = array()): ResponseCollection
|
||||
{
|
||||
$this->SendRequest($sCommand, $aParams);
|
||||
return $this->getResponse();
|
||||
}
|
||||
|
||||
protected function getResponseValue(ResponseCollection $oResponseCollection, int $type = 0) : string
|
||||
protected function getResponseValue(ResponseCollection $oResponseCollection, int $type = 0): string
|
||||
{
|
||||
$oResponse = $oResponseCollection->getLast();
|
||||
if ($oResponse && (!$type || $type === $oResponse->ResponseType)) {
|
||||
|
|
@ -466,7 +466,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
protected function streamResponse(?string $sEndTag = null) : void
|
||||
protected function streamResponse(?string $sEndTag = null): void
|
||||
{
|
||||
try {
|
||||
if (\is_resource($this->ConnectionResource())) {
|
||||
|
|
@ -488,7 +488,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
}
|
||||
}
|
||||
|
||||
protected function getResponse(?string $sEndTag = null) : ResponseCollection
|
||||
protected function getResponse(?string $sEndTag = null): ResponseCollection
|
||||
{
|
||||
try {
|
||||
$oResult = new ResponseCollection;
|
||||
|
|
@ -535,8 +535,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
return $oResult;
|
||||
}
|
||||
|
||||
// public function yieldUntaggedResponses() : \Generator
|
||||
public function yieldUntaggedResponses() : iterable
|
||||
// public function yieldUntaggedResponses(): \Generator
|
||||
public function yieldUntaggedResponses(): iterable
|
||||
{
|
||||
try {
|
||||
$oResult = new ResponseCollection;
|
||||
|
|
@ -577,7 +577,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
}
|
||||
}
|
||||
|
||||
protected function prepareParamLine(array $aParams = array()) : string
|
||||
protected function prepareParamLine(array $aParams = array()): string
|
||||
{
|
||||
$sReturn = '';
|
||||
foreach ($aParams as $mParamItem) {
|
||||
|
|
@ -590,18 +590,18 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
return $sReturn;
|
||||
}
|
||||
|
||||
protected function getNewTag() : string
|
||||
protected function getNewTag(): string
|
||||
{
|
||||
++$this->iTagCount;
|
||||
return $this->getCurrentTag();
|
||||
}
|
||||
|
||||
protected function getCurrentTag() : string
|
||||
protected function getCurrentTag(): string
|
||||
{
|
||||
return $this->TAG_PREFIX.$this->iTagCount;
|
||||
}
|
||||
|
||||
public function EscapeString(?string $sStringForEscape) : string
|
||||
public function EscapeString(?string $sStringForEscape): string
|
||||
{
|
||||
if (null === $sStringForEscape) {
|
||||
return 'NIL';
|
||||
|
|
@ -617,7 +617,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
return '"' . \addcslashes($sStringForEscape, '\\"') . '"';
|
||||
}
|
||||
|
||||
public function getLogName() : string
|
||||
public function getLogName(): string
|
||||
{
|
||||
return 'IMAP';
|
||||
}
|
||||
|
|
@ -626,7 +626,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* RFC 2971
|
||||
* Don't have to be logged in to call this command
|
||||
*/
|
||||
public function ServerID() : string
|
||||
public function ServerID(): string
|
||||
{
|
||||
if ($this->hasCapability('ID')) {
|
||||
foreach ($this->SendRequestGetResponse('ID', [null]) as $oResponse) {
|
||||
|
|
@ -647,7 +647,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* RFC 4978
|
||||
* It is RECOMMENDED that the client uses TLS compression.
|
||||
*//*
|
||||
public function Compress() : bool
|
||||
public function Compress(): bool
|
||||
{
|
||||
try {
|
||||
if ($this->hasCapability('COMPRESS=DEFLATE')) {
|
||||
|
|
@ -663,12 +663,12 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
return false;
|
||||
}*/
|
||||
|
||||
public function EscapeFolderName(string $sFolderName) : string
|
||||
public function EscapeFolderName(string $sFolderName): string
|
||||
{
|
||||
return $this->EscapeString($this->UTF8 ? $sFolderName : \MailSo\Base\Utils::Utf8ToUtf7Modified($sFolderName));
|
||||
}
|
||||
|
||||
public function toUTF8(string $sText) : string
|
||||
public function toUTF8(string $sText): string
|
||||
{
|
||||
return $this->UTF8 ? $sText : \MailSo\Base\Utils::Utf7ModifiedToUtf8($sText);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class NamespaceResult implements \JsonSerializable
|
|||
}
|
||||
}
|
||||
|
||||
public function GetPersonalPrefix() : string
|
||||
public function GetPersonalPrefix(): string
|
||||
{
|
||||
$sPrefix = '';
|
||||
if (isset($this->aPersonal[0])) {
|
||||
|
|
@ -72,8 +72,8 @@ class NamespaceResult implements \JsonSerializable
|
|||
return $sPrefix;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array(
|
||||
'@Object' => 'Object/Namespaces',
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class THREAD extends Request
|
|||
parent::__construct($oImapClient);
|
||||
}
|
||||
|
||||
public function setAlgorithm(string $sAlgorithm) : void
|
||||
public function setAlgorithm(string $sAlgorithm): void
|
||||
{
|
||||
$sAlgorithm = \strtoupper($sAlgorithm);
|
||||
if (!$this->oImapClient->hasCapability("THREAD={$sAlgorithm}")) {
|
||||
|
|
@ -51,7 +51,7 @@ class THREAD extends Request
|
|||
$this->sAlgorithm = $sAlgorithm;
|
||||
}
|
||||
|
||||
public function SendRequestIterateResponse() : iterable
|
||||
public function SendRequestIterateResponse(): iterable
|
||||
{
|
||||
$this->oImapClient->SendRequest(
|
||||
($this->bUid ? 'UID THREAD' : 'THREAD'),
|
||||
|
|
@ -79,12 +79,7 @@ class THREAD extends Request
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mValue
|
||||
*
|
||||
* @return int | array | false
|
||||
*/
|
||||
private function validateThreadItem($mValue)
|
||||
private function validateThreadItem(mixed $mValue): int|array|false
|
||||
{
|
||||
if (\is_numeric($mValue)) {
|
||||
$mValue = (int) $mValue;
|
||||
|
|
|
|||
|
|
@ -28,19 +28,19 @@ class ACL implements \JsonSerializable
|
|||
$this->rights = $rights;
|
||||
}
|
||||
|
||||
public function identifier() : string
|
||||
public function identifier(): string
|
||||
{
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
/** PHP 8.1
|
||||
public function hasRight(string|\MailSo\Imap\Enumerations\FolderACL $right)
|
||||
public function hasRight(string|\MailSo\Imap\Enumerations\FolderACL $right): bool
|
||||
{
|
||||
if ($right instanceof \BackedEnum) {
|
||||
return \str_contains($this->rights, $right->value);
|
||||
}
|
||||
*/
|
||||
public function hasRight(string $right) : bool
|
||||
public function hasRight(string $right): bool
|
||||
{
|
||||
$const = '\\MailSo\\Imap\\Enumerations\\FolderACL::' . \strtoupper($right);
|
||||
if (\defined($const)) {
|
||||
|
|
@ -49,8 +49,8 @@ class ACL implements \JsonSerializable
|
|||
return \str_contains($this->rights, $right);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return [
|
||||
'@Object' => 'Object/FolderACLRights',
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class SequenceSet /*extends \SplFixedArray*/ implements \Countable
|
|||
return \in_array($value, $this->data);
|
||||
}
|
||||
|
||||
public function indexOf($value)/*: int|false*/
|
||||
public function indexOf($value): int|false
|
||||
{
|
||||
return \array_search($value, $this->data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
public array
|
||||
$disabled_capabilities = [];
|
||||
|
||||
public static function fromArray(array $aSettings) : self
|
||||
public static function fromArray(array $aSettings): self
|
||||
{
|
||||
$object = parent::fromArray($aSettings);
|
||||
|
||||
|
|
@ -119,8 +119,8 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
return $object;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
if (\in_array('SORT', $this->disabled_capabilities)) {
|
||||
$this->disabled_capabilities[] = 'ESORT';
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ abstract class Driver
|
|||
$this->oTimeZone = new \DateTimeZone('UTC');
|
||||
}
|
||||
|
||||
public function SetTimeZone(/*\DateTimeZone | string*/ $mTimeZone) : self
|
||||
public function SetTimeZone(\DateTimeZone|string $mTimeZone): self
|
||||
{
|
||||
$this->oTimeZone = $mTimeZone instanceof \DateTimeZone
|
||||
? $mTimeZone
|
||||
|
|
@ -56,43 +56,43 @@ abstract class Driver
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function DisableGuidPrefix() : self
|
||||
public function DisableGuidPrefix(): self
|
||||
{
|
||||
$this->bGuidPrefix = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function DisableTimePrefix() : self
|
||||
public function DisableTimePrefix(): self
|
||||
{
|
||||
$this->bTimePrefix = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function DisableTypedPrefix() : self
|
||||
public function DisableTypedPrefix(): self
|
||||
{
|
||||
$this->bTypedPrefix = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
abstract protected function writeImplementation($mDesc) : bool;
|
||||
abstract protected function writeImplementation($mDesc): bool;
|
||||
|
||||
protected function clearImplementation() : bool
|
||||
protected function clearImplementation(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getTimeWithMicroSec() : string
|
||||
protected function getTimeWithMicroSec(): string
|
||||
{
|
||||
return \substr((new \DateTime('now', $this->oTimeZone))->format('Y-m-d H:i:s.u'), 0, -3);
|
||||
}
|
||||
|
||||
protected function getTypedPrefix(int $iType, string $sName = '') : string
|
||||
protected function getTypedPrefix(int $iType, string $sName = ''): string
|
||||
{
|
||||
$sName = \strlen($sName) ? $sName : $this->sName;
|
||||
return isset(self::PREFIXES[$iType]) ? $sName . self::PREFIXES[$iType].': ' : '';
|
||||
}
|
||||
|
||||
final public function Write(string $sDesc, int $iType = \LOG_INFO, string $sName = '', bool $bDiplayCrLf = false)
|
||||
final public function Write(string $sDesc, int $iType = \LOG_INFO, string $sName = '', bool $bDiplayCrLf = false): bool
|
||||
{
|
||||
$sDesc = \ltrim(
|
||||
($this->bTimePrefix ? '['.$this->getTimeWithMicroSec().']' : '').
|
||||
|
|
@ -105,7 +105,7 @@ abstract class Driver
|
|||
return $this->writeImplementation($sDesc);
|
||||
}
|
||||
|
||||
final public function Clear() : bool
|
||||
final public function Clear(): bool
|
||||
{
|
||||
return $this->clearImplementation();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class Logger extends \SplFixedArray
|
|||
/**
|
||||
* @staticvar string $sCache;
|
||||
*/
|
||||
public static function Guid() : string
|
||||
public static function Guid(): string
|
||||
{
|
||||
static $sCache = null;
|
||||
if (null === $sCache) {
|
||||
|
|
@ -94,7 +94,7 @@ class Logger extends \SplFixedArray
|
|||
return $sCache;
|
||||
}
|
||||
|
||||
public function append($oDriver) : void
|
||||
public function append($oDriver): void
|
||||
{
|
||||
if ($oDriver) {
|
||||
$this->setSize(1);
|
||||
|
|
@ -102,7 +102,7 @@ class Logger extends \SplFixedArray
|
|||
}
|
||||
}
|
||||
|
||||
public function IsEnabled() : bool
|
||||
public function IsEnabled(): bool
|
||||
{
|
||||
return 0 < $this->count();
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ class Logger extends \SplFixedArray
|
|||
public function AddSecret(
|
||||
#[\SensitiveParameter]
|
||||
string $sWord
|
||||
) : void
|
||||
): void
|
||||
{
|
||||
// $this->bShowSecrets && $this->Write("AddSecret '{$sWord}'", \LOG_INFO);
|
||||
$sWord = \trim($sWord);
|
||||
|
|
@ -121,18 +121,18 @@ class Logger extends \SplFixedArray
|
|||
}
|
||||
}
|
||||
|
||||
public function SetShowSecrets(bool $bShow) : self
|
||||
public function SetShowSecrets(bool $bShow): self
|
||||
{
|
||||
$this->bShowSecrets = $bShow;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function ShowSecrets() : bool
|
||||
public function ShowSecrets(): bool
|
||||
{
|
||||
return $this->bShowSecrets;
|
||||
}
|
||||
|
||||
public function SetLevel(int $iLevel) : self
|
||||
public function SetLevel(int $iLevel): self
|
||||
{
|
||||
$this->iLevel = $iLevel;
|
||||
return $this;
|
||||
|
|
@ -174,7 +174,7 @@ class Logger extends \SplFixedArray
|
|||
\E_USER_DEPRECATED => '-USER_DEPRECATED'
|
||||
);
|
||||
|
||||
public function __phpErrorHandler(int $iErrNo, string $sErrStr, string $sErrFile, int $iErrLine) : bool
|
||||
public function __phpErrorHandler(int $iErrNo, string $sErrStr, string $sErrFile, int $iErrLine): bool
|
||||
{
|
||||
if (\error_reporting() & $iErrNo) {
|
||||
$this->Write(
|
||||
|
|
@ -196,7 +196,7 @@ class Logger extends \SplFixedArray
|
|||
\error_log('Uncaught exception: ' . $oException);
|
||||
}
|
||||
|
||||
public function __loggerShutDown() : void
|
||||
public function __loggerShutDown(): void
|
||||
{
|
||||
if ($this->bUsed) {
|
||||
$error = \error_get_last();
|
||||
|
|
@ -206,7 +206,7 @@ class Logger extends \SplFixedArray
|
|||
}
|
||||
}
|
||||
|
||||
public function signalHandler($signo, /*?array*/$siginfo = null)
|
||||
public function signalHandler(int $signo, mixed $siginfo = null): void
|
||||
{
|
||||
if (\SIGTERM == $signo) {
|
||||
exit;
|
||||
|
|
@ -219,7 +219,7 @@ class Logger extends \SplFixedArray
|
|||
}
|
||||
}
|
||||
|
||||
public function Write(string $sDesc, int $iType = \LOG_INFO, string $sName = '', bool $bDiplayCrLf = false) : bool
|
||||
public function Write(string $sDesc, int $iType = \LOG_INFO, string $sName = '', bool $bDiplayCrLf = false): bool
|
||||
{
|
||||
if ($this->iLevel < $iType) {
|
||||
return true;
|
||||
|
|
@ -241,17 +241,14 @@ class Logger extends \SplFixedArray
|
|||
return (bool) $iResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mValue
|
||||
*/
|
||||
public function WriteDump($mValue, int $iType = \LOG_INFO, string $sName = '') : bool
|
||||
public function WriteDump(mixed $mValue, int $iType = \LOG_INFO, string $sName = ''): bool
|
||||
{
|
||||
return $this->Write(\print_r($mValue, true), $iType, $sName);
|
||||
}
|
||||
|
||||
private $aExceptions = [];
|
||||
|
||||
public function WriteException(\Throwable $oException, int $iType = \LOG_NOTICE, string $sName = '') : void
|
||||
public function WriteException(\Throwable $oException, int $iType = \LOG_NOTICE, string $sName = ''): void
|
||||
{
|
||||
if (!\in_array($oException, $this->aExceptions)) {
|
||||
$this->Write((string) $oException, $iType, $sName);
|
||||
|
|
@ -259,7 +256,7 @@ class Logger extends \SplFixedArray
|
|||
}
|
||||
}
|
||||
|
||||
public function WriteExceptionShort(\Throwable $oException, int $iType = \LOG_NOTICE, string $sName = '') : void
|
||||
public function WriteExceptionShort(\Throwable $oException, int $iType = \LOG_NOTICE, string $sName = ''): void
|
||||
{
|
||||
if (!\in_array($oException, $this->aExceptions)) {
|
||||
$this->Write($oException->getMessage(), $iType, $sName);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Attachment implements \JsonSerializable
|
|||
$this->oBodyStructure = $oBodyStructure;
|
||||
}
|
||||
|
||||
public function Clear() : self
|
||||
public function Clear(): self
|
||||
{
|
||||
$this->sFolder = '';
|
||||
$this->iUid = 0;
|
||||
|
|
@ -41,23 +41,23 @@ class Attachment implements \JsonSerializable
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function Folder() : string
|
||||
public function Folder(): string
|
||||
{
|
||||
return $this->sFolder;
|
||||
}
|
||||
|
||||
public function Uid() : int
|
||||
public function Uid(): int
|
||||
{
|
||||
return $this->iUid;
|
||||
}
|
||||
|
||||
public function __call(string $name, array $arguments) //: mixed
|
||||
public function __call(string $name, array $arguments): mixed
|
||||
{
|
||||
return $this->oBodyStructure->{$name}(...$arguments);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return \array_merge([
|
||||
'@Object' => 'Object/Attachment',
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ class MailClient
|
|||
$this->oImapClient = new \MailSo\Imap\ImapClient;
|
||||
}
|
||||
|
||||
public function ImapClient() : \MailSo\Imap\ImapClient
|
||||
public function ImapClient(): \MailSo\Imap\ImapClient
|
||||
{
|
||||
return $this->oImapClient;
|
||||
}
|
||||
|
||||
private function getEnvelopeOrHeadersRequestString() : string
|
||||
private function getEnvelopeOrHeadersRequestString(): string
|
||||
{
|
||||
if ($this->oImapClient->Settings->message_all_headers) {
|
||||
return FetchType::BODY_HEADER_PEEK;
|
||||
|
|
@ -115,7 +115,7 @@ class MailClient
|
|||
* @throws \MailSo\Imap\Exceptions\*
|
||||
* @throws \MailSo\Mail\Exceptions\*
|
||||
*/
|
||||
public function MessageSetFlag(string $sFolderName, SequenceSet $oRange, string $sMessageFlag, bool $bSetAction = true, bool $bSkipUnsupportedFlag = false) : void
|
||||
public function MessageSetFlag(string $sFolderName, SequenceSet $oRange, string $sMessageFlag, bool $bSetAction = true, bool $bSkipUnsupportedFlag = false): void
|
||||
{
|
||||
if (\count($oRange)) {
|
||||
if ($this->oImapClient->FolderSelect($sFolderName)->IsFlagSupported($sMessageFlag)) {
|
||||
|
|
@ -133,7 +133,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function Message(string $sFolderName, int $iIndex, bool $bIndexIsUid = true, ?\MailSo\Cache\CacheClient $oCacher = null) : ?Message
|
||||
public function Message(string $sFolderName, int $iIndex, bool $bIndexIsUid = true, ?\MailSo\Cache\CacheClient $oCacher = null): ?Message
|
||||
{
|
||||
if (1 > $iIndex) {
|
||||
throw new \ValueError;
|
||||
|
|
@ -181,14 +181,12 @@ class MailClient
|
|||
/**
|
||||
* Streams mime part to $mCallback
|
||||
*
|
||||
* @param mixed $mCallback
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \MailSo\RuntimeException
|
||||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function MessageMimeStream($mCallback, string $sFolderName, int $iIndex, string $sMimeIndex) : bool
|
||||
public function MessageMimeStream(callable $mCallback, string $sFolderName, int $iIndex, string $sMimeIndex): bool
|
||||
{
|
||||
if (!\is_callable($mCallback)) {
|
||||
throw new \ValueError;
|
||||
|
|
@ -279,7 +277,7 @@ class MailClient
|
|||
return ($aFetchResponse && 1 === \count($aFetchResponse));
|
||||
}
|
||||
|
||||
public function MessageAppendFile(string $sMessageFileName, string $sFolderToSave, ?array $aAppendFlags = null) : int
|
||||
public function MessageAppendFile(string $sMessageFileName, string $sFolderToSave, ?array $aAppendFlags = null): int
|
||||
{
|
||||
if (!\is_file($sMessageFileName) || !\is_readable($sMessageFileName)) {
|
||||
throw new \ValueError;
|
||||
|
|
@ -299,7 +297,7 @@ class MailClient
|
|||
* Returns list of new messages since $iPrevUidNext
|
||||
* Currently only for INBOX
|
||||
*/
|
||||
private function getFolderNextMessageInformation(string $sFolderName, int $iPrevUidNext, int $iCurrentUidNext) : array
|
||||
private function getFolderNextMessageInformation(string $sFolderName, int $iPrevUidNext, int $iCurrentUidNext): array
|
||||
{
|
||||
$aNewMessages = array();
|
||||
|
||||
|
|
@ -349,7 +347,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, ?SequenceSet $oRange = null) : array
|
||||
public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, ?SequenceSet $oRange = null): array
|
||||
{
|
||||
if ($oRange) {
|
||||
// $aInfo = $this->oImapClient->FolderExamine($sFolderName)->jsonSerialize();
|
||||
|
|
@ -391,7 +389,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function FolderHash(string $sFolderName) : string
|
||||
public function FolderHash(string $sFolderName): string
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -405,7 +403,7 @@ class MailClient
|
|||
return '';
|
||||
}
|
||||
|
||||
public function MessageThread(string $sFolderName, string $sMessageID) : MessageCollection
|
||||
public function MessageThread(string $sFolderName, string $sMessageID): MessageCollection
|
||||
{
|
||||
$this->oImapClient->FolderExamine($sFolderName);
|
||||
|
||||
|
|
@ -434,7 +432,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
protected function ThreadsMap(string $sAlgorithm, MessageCollection $oMessageCollection, ?\MailSo\Cache\CacheClient $oCacher, bool $bBackground = false) : array
|
||||
protected function ThreadsMap(string $sAlgorithm, MessageCollection $oMessageCollection, ?\MailSo\Cache\CacheClient $oCacher, bool $bBackground = false): array
|
||||
{
|
||||
$oFolderInfo = $oMessageCollection->FolderInfo;
|
||||
$sFolderName = $oFolderInfo->FullName;
|
||||
|
|
@ -512,7 +510,7 @@ class MailClient
|
|||
}
|
||||
|
||||
// All threads UID's except the most recent UID of each thread
|
||||
protected function ThreadsOldUids(array $aAllThreads, MessageCollection $oMessageCollection, ?\MailSo\Cache\CacheClient $oCacher, bool $bBackground = false) : array
|
||||
protected function ThreadsOldUids(array $aAllThreads, MessageCollection $oMessageCollection, ?\MailSo\Cache\CacheClient $oCacher, bool $bBackground = false): array
|
||||
{
|
||||
$oFolderInfo = $oMessageCollection->FolderInfo;
|
||||
|
||||
|
|
@ -585,7 +583,7 @@ class MailClient
|
|||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
protected function MessageListByRequestIndexOrUids(MessageCollection $oMessageCollection, SequenceSet $oRange,
|
||||
array &$aAllThreads = [], array &$aUnseenUIDs = []) : void
|
||||
array &$aAllThreads = [], array &$aUnseenUIDs = []): void
|
||||
{
|
||||
if (\count($oRange)) {
|
||||
$aFetchItems = array(
|
||||
|
|
@ -633,7 +631,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
private function GetUids(MessageListParams $oParams, FolderInformation $oInfo, bool $onlyCache = false) : ?array
|
||||
private function GetUids(MessageListParams $oParams, FolderInformation $oInfo, bool $onlyCache = false): ?array
|
||||
{
|
||||
$oCacher = $oParams->oCacher;
|
||||
$sFolderName = $oParams->sFolderName;
|
||||
|
|
@ -725,7 +723,7 @@ class MailClient
|
|||
return $aResultUids;
|
||||
}
|
||||
|
||||
public function MessageListUnseen(MessageListParams $oParams, FolderInformation $oInfo) : array
|
||||
public function MessageListUnseen(MessageListParams $oParams, FolderInformation $oInfo): array
|
||||
{
|
||||
$oUnseenParams = new MessageListParams;
|
||||
$oUnseenParams->sFolderName = $oParams->sFolderName;
|
||||
|
|
@ -749,7 +747,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function MessageList(MessageListParams $oParams) : MessageCollection
|
||||
public function MessageList(MessageListParams $oParams): MessageCollection
|
||||
{
|
||||
if (0 > $oParams->iOffset || 0 > $oParams->iLimit) {
|
||||
throw new \ValueError;
|
||||
|
|
@ -911,7 +909,7 @@ class MailClient
|
|||
return $oMessageCollection;
|
||||
}
|
||||
|
||||
public function FindMessageUidByMessageId(string $sFolderName, string $sMessageId) : ?int
|
||||
public function FindMessageUidByMessageId(string $sFolderName, string $sMessageId): ?int
|
||||
{
|
||||
if (!\strlen($sMessageId)) {
|
||||
throw new \ValueError;
|
||||
|
|
@ -924,7 +922,7 @@ class MailClient
|
|||
return 1 === \count($aUids) && \is_numeric($aUids[0]) ? (int) $aUids[0] : null;
|
||||
}
|
||||
|
||||
public function Folders(string $sParent, string $sListPattern, bool $bUseListSubscribeStatus) : ?FolderCollection
|
||||
public function Folders(string $sParent, string $sListPattern, bool $bUseListSubscribeStatus): ?FolderCollection
|
||||
{
|
||||
$oFolderCollection = $this->oImapClient->FolderStatusList($sParent, $sListPattern);
|
||||
if (!$oFolderCollection->count()) {
|
||||
|
|
@ -957,7 +955,7 @@ class MailClient
|
|||
/**
|
||||
* @throws \ValueError
|
||||
*/
|
||||
public function FolderCreate(string $sFolderNameInUtf8, string $sFolderParentFullName = '', bool $bSubscribeOnCreation = true, string $sDelimiter = '') : ?\MailSo\Imap\Folder
|
||||
public function FolderCreate(string $sFolderNameInUtf8, string $sFolderParentFullName = '', bool $bSubscribeOnCreation = true, string $sDelimiter = ''): ?\MailSo\Imap\Folder
|
||||
{
|
||||
$sFolderNameInUtf8 = \trim($sFolderNameInUtf8);
|
||||
$sFolderParentFullName = \trim($sFolderParentFullName);
|
||||
|
|
@ -1004,7 +1002,7 @@ class MailClient
|
|||
/**
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function FolderRename(string $sPrevFolderFullName, string $sNewFolderFullName) : self
|
||||
public function FolderRename(string $sPrevFolderFullName, string $sNewFolderFullName): self
|
||||
{
|
||||
if (!\strlen($sPrevFolderFullName) || !\strlen($sNewFolderFullName)) {
|
||||
throw new \ValueError;
|
||||
|
|
@ -1047,7 +1045,7 @@ class MailClient
|
|||
/**
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function SetLogger(?\MailSo\Log\Logger $oLogger) : void
|
||||
public function SetLogger(?\MailSo\Log\Logger $oLogger): void
|
||||
{
|
||||
$this->oLogger = $oLogger;
|
||||
$this->oImapClient->SetLogger($oLogger);
|
||||
|
|
|
|||
|
|
@ -92,52 +92,52 @@ class Message implements \JsonSerializable
|
|||
return \property_exists($this, $k) ? $this->$k : null;
|
||||
}
|
||||
|
||||
public function Subject() : string
|
||||
public function Subject(): string
|
||||
{
|
||||
return $this->sSubject;
|
||||
}
|
||||
|
||||
public function From() : ?\MailSo\Mime\EmailCollection
|
||||
public function From(): ?\MailSo\Mime\EmailCollection
|
||||
{
|
||||
return $this->oFrom;
|
||||
}
|
||||
|
||||
public function Uid() : int
|
||||
public function Uid(): int
|
||||
{
|
||||
return $this->Uid;
|
||||
}
|
||||
|
||||
public function Attachments() : ?AttachmentCollection
|
||||
public function Attachments(): ?AttachmentCollection
|
||||
{
|
||||
return $this->Attachments;
|
||||
}
|
||||
|
||||
public function setPlain(string $value) : void
|
||||
public function setPlain(string $value): void
|
||||
{
|
||||
$this->sPlain = $value;
|
||||
}
|
||||
|
||||
public function setHtml(string $value) : void
|
||||
public function setHtml(string $value): void
|
||||
{
|
||||
$this->sHtml = $value;
|
||||
}
|
||||
|
||||
private function setSpamScore($value) : void
|
||||
private function setSpamScore($value): void
|
||||
{
|
||||
$this->SpamScore = \intval(\max(0, \min(100, $value)));
|
||||
}
|
||||
|
||||
public function SetThreads(array $aThreadUIDs)
|
||||
public function SetThreads(array $aThreadUIDs): void
|
||||
{
|
||||
$this->aThreadUIDs = $aThreadUIDs;
|
||||
}
|
||||
|
||||
public function SetThreadUnseen(array $aUnseenUIDs)
|
||||
public function SetThreadUnseen(array $aUnseenUIDs): void
|
||||
{
|
||||
$this->aThreadUnseenUIDs = $aUnseenUIDs;
|
||||
}
|
||||
|
||||
public static function fromFetchResponse(string $sFolder, \MailSo\Imap\FetchResponse $oFetchResponse, ?\MailSo\Imap\BodyStructure $oBodyStructure = null) : self
|
||||
public static function fromFetchResponse(string $sFolder, \MailSo\Imap\FetchResponse $oFetchResponse, ?\MailSo\Imap\BodyStructure $oBodyStructure = null): self
|
||||
{
|
||||
$oMessage = new self;
|
||||
|
||||
|
|
@ -463,7 +463,7 @@ class Message implements \JsonSerializable
|
|||
return $oMessage;
|
||||
}
|
||||
|
||||
public function ETag(string $sClientHash) : string
|
||||
public function ETag(string $sClientHash): string
|
||||
{
|
||||
return \md5('MessageHash/' . \implode('/', [
|
||||
$this->sFolder,
|
||||
|
|
@ -477,7 +477,7 @@ class Message implements \JsonSerializable
|
|||
// https://datatracker.ietf.org/doc/html/rfc5788#section-3.4.1
|
||||
// Thunderbird $label1 is same as $Important?
|
||||
// Thunderbird $label4 is same as $todo?
|
||||
protected function getFlags() : array
|
||||
protected function getFlags(): array
|
||||
{
|
||||
return \array_unique(\str_replace(
|
||||
['$readreceipt', '$replied', /* 'junk', 'nonjunk', '$queued', '$sent', 'sent'*/],
|
||||
|
|
@ -486,8 +486,8 @@ class Message implements \JsonSerializable
|
|||
));
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
/*
|
||||
// JMAP-only RFC8621 keywords (RFC5788)
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@ class MessageCollection extends \MailSo\Base\Collection
|
|||
|
||||
public int $ThreadUid = 0;
|
||||
|
||||
// MailSo\Imap\FolderInformation
|
||||
public $FolderInfo = null;
|
||||
public ?\MailSo\Imap\FolderInformation $FolderInfo = null;
|
||||
|
||||
public array $NewMessages = array();
|
||||
|
||||
|
|
@ -45,19 +44,19 @@ class MessageCollection extends \MailSo\Base\Collection
|
|||
|
||||
public bool $Limited = false;
|
||||
|
||||
public function append($oMessage, bool $bToTop = false) : void
|
||||
public function append($oMessage, bool $bToTop = false): void
|
||||
{
|
||||
assert($oMessage instanceof Message);
|
||||
parent::append($oMessage, $bToTop);
|
||||
}
|
||||
|
||||
public function Clear() : void
|
||||
public function Clear(): void
|
||||
{
|
||||
throw new \BadMethodCallException('disallowed');
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return \array_merge(parent::jsonSerialize(), array(
|
||||
'totalEmails' => $this->totalEmails,
|
||||
|
|
|
|||
|
|
@ -200,8 +200,8 @@ class Email implements \JsonSerializable
|
|||
return $this->ToString();
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array(
|
||||
'@Object' => 'Object/Email',
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
public function append($oEmail, bool $bToTop = false) : void
|
||||
public function append($oEmail, bool $bToTop = false): void
|
||||
{
|
||||
assert($oEmail instanceof Email);
|
||||
parent::append($oEmail, $bToTop);
|
||||
}
|
||||
|
||||
public function Unique() : self
|
||||
public function Unique(): self
|
||||
{
|
||||
$aReturn = array();
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
return new static($aReturn);
|
||||
}
|
||||
|
||||
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string
|
||||
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false): string
|
||||
{
|
||||
$aReturn = array();
|
||||
foreach ($this as $oEmail) {
|
||||
|
|
@ -57,12 +57,12 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
return \implode(', ', $aReturn);
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->ToString();
|
||||
}
|
||||
|
||||
private function parseEmailAddresses(string $sRawEmails) : void
|
||||
private function parseEmailAddresses(string $sRawEmails): void
|
||||
{
|
||||
// $sRawEmails = \MailSo\Base\Utils::Trim($sRawEmails);
|
||||
$sRawEmails = \trim($sRawEmails);
|
||||
|
|
@ -156,8 +156,8 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return \array_slice($this->getArrayCopy(), 0, 100);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Header implements \JsonSerializable
|
|||
$this->initInputData($sName, $sValue, $sEncodedValueForReparse);
|
||||
}
|
||||
|
||||
private function initInputData(string $sName, string $sValue, string $sEncodedValueForReparse) : void
|
||||
private function initInputData(string $sName, string $sValue, string $sEncodedValueForReparse): void
|
||||
{
|
||||
$this->sName = \trim($sName);
|
||||
$this->sFullValue = \trim($sValue);
|
||||
|
|
@ -62,7 +62,7 @@ class Header implements \JsonSerializable
|
|||
}
|
||||
}
|
||||
|
||||
public static function NewInstanceFromEncodedString(string $sEncodedLines, string $sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1) : Header
|
||||
public static function NewInstanceFromEncodedString(string $sEncodedLines, string $sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1): Header
|
||||
{
|
||||
if (empty($sIncomingCharset)) {
|
||||
$sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1;
|
||||
|
|
@ -81,27 +81,27 @@ class Header implements \JsonSerializable
|
|||
return false;
|
||||
}
|
||||
|
||||
public function Name() : string
|
||||
public function Name(): string
|
||||
{
|
||||
return $this->sName;
|
||||
}
|
||||
|
||||
public function Value() : string
|
||||
public function Value(): string
|
||||
{
|
||||
return $this->sValue;
|
||||
}
|
||||
|
||||
public function FullValue() : string
|
||||
public function FullValue(): string
|
||||
{
|
||||
return $this->sFullValue;
|
||||
}
|
||||
|
||||
public function EncodedValue() : string
|
||||
public function EncodedValue(): string
|
||||
{
|
||||
return $this->sEncodedValue ?: $this->sFullValue;
|
||||
}
|
||||
|
||||
public function SetParentCharset(string $sParentCharset) : Header
|
||||
public function SetParentCharset(string $sParentCharset): Header
|
||||
{
|
||||
if ($this->sParentCharset !== $sParentCharset && \strlen($this->sEncodedValue)) {
|
||||
$this->initInputData(
|
||||
|
|
@ -116,17 +116,17 @@ class Header implements \JsonSerializable
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function Parameters() : ?ParameterCollection
|
||||
public function Parameters(): ?ParameterCollection
|
||||
{
|
||||
return $this->oParameters;
|
||||
}
|
||||
|
||||
public function setParameter(string $sName, string $sValue) : void
|
||||
public function setParameter(string $sName, string $sValue): void
|
||||
{
|
||||
$this->oParameters->setParameter($sName, $sValue);
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
$sResult = $this->sFullValue;
|
||||
|
||||
|
|
@ -159,12 +159,12 @@ class Header implements \JsonSerializable
|
|||
return $sName . \wordwrap($sResult, 78 - \strlen($sName) - 1, "\r\n ");
|
||||
}
|
||||
|
||||
private function IsSubject() : bool
|
||||
private function IsSubject(): bool
|
||||
{
|
||||
return \strtolower(Enumerations\Header::SUBJECT) === \strtolower($this->Name());
|
||||
}
|
||||
|
||||
private function IsParameterized() : bool
|
||||
private function IsParameterized(): bool
|
||||
{
|
||||
return \in_array(\strtolower($this->sName), array(
|
||||
\strtolower(Enumerations\Header::CONTENT_TYPE),
|
||||
|
|
@ -173,7 +173,7 @@ class Header implements \JsonSerializable
|
|||
));
|
||||
}
|
||||
|
||||
private function IsEmail() : bool
|
||||
private function IsEmail(): bool
|
||||
{
|
||||
return \in_array(\strtolower($this->sName), array(
|
||||
\strtolower(Enumerations\Header::FROM_),
|
||||
|
|
@ -186,7 +186,7 @@ class Header implements \JsonSerializable
|
|||
));
|
||||
}
|
||||
|
||||
public function ValueWithCharsetAutoDetect() : string
|
||||
public function ValueWithCharsetAutoDetect(): string
|
||||
{
|
||||
if (!\MailSo\Base\Utils::IsAscii($this->Value())
|
||||
&& \strlen($this->sEncodedValue)
|
||||
|
|
@ -198,8 +198,8 @@ class Header implements \JsonSerializable
|
|||
return $this->Value();
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$aResult = array(
|
||||
'@Object' => 'Object/MimeHeader',
|
||||
|
|
|
|||
|
|
@ -27,30 +27,30 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
public function append($oHeader, bool $bToTop = false) : void
|
||||
public function append($oHeader, bool $bToTop = false): void
|
||||
{
|
||||
assert($oHeader instanceof Header);
|
||||
parent::append($oHeader, $bToTop);
|
||||
}
|
||||
|
||||
public function AddByName(string $sName, string $sValue, bool $bToTop = false) : self
|
||||
public function AddByName(string $sName, string $sValue, bool $bToTop = false): self
|
||||
{
|
||||
$this->append(new Header($sName, $sValue), $bToTop);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetByName(string $sName, string $sValue, bool $bToTop = false) : self
|
||||
public function SetByName(string $sName, string $sValue, bool $bToTop = false): self
|
||||
{
|
||||
return $this->RemoveByName($sName)->Add(new Header($sName, $sValue), $bToTop);
|
||||
}
|
||||
|
||||
public function ValueByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : string
|
||||
public function ValueByName(string $sHeaderName, bool $bCharsetAutoDetect = false): string
|
||||
{
|
||||
$oHeader = $this->GetByName($sHeaderName);
|
||||
return $oHeader ? ($bCharsetAutoDetect ? $oHeader->ValueWithCharsetAutoDetect() : $oHeader->Value()) : '';
|
||||
}
|
||||
|
||||
public function ValuesByName(string $sHeaderName) : array
|
||||
public function ValuesByName(string $sHeaderName): array
|
||||
{
|
||||
$aResult = array();
|
||||
$sHeaderNameLower = \strtolower($sHeaderName);
|
||||
|
|
@ -62,7 +62,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
public function RemoveByName(string $sHeaderName) : self
|
||||
public function RemoveByName(string $sHeaderName): self
|
||||
{
|
||||
$sHeaderName = \strtolower($sHeaderName);
|
||||
$this->exchangeArray(array_filter($this->getArrayCopy(), function ($oHeader) use ($sHeaderName) {
|
||||
|
|
@ -71,7 +71,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function GetAsEmailCollection(string $sHeaderName) : ?EmailCollection
|
||||
public function GetAsEmailCollection(string $sHeaderName): ?EmailCollection
|
||||
{
|
||||
if ($oHeader = $this->GetByName($sHeaderName)) {
|
||||
return new EmailCollection($oHeader->EncodedValue());
|
||||
|
|
@ -79,14 +79,14 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return new EmailCollection();
|
||||
}
|
||||
|
||||
public function ParameterValue(string $sHeaderName, string $sParamName) : string
|
||||
public function ParameterValue(string $sHeaderName, string $sParamName): string
|
||||
{
|
||||
$oHeader = $this->GetByName($sHeaderName);
|
||||
$oParameters = $oHeader ? $oHeader->Parameters() : null;
|
||||
return (null !== $oParameters) ? $oParameters->ParameterValueByName($sParamName) : '';
|
||||
}
|
||||
|
||||
public function GetByName(string $sHeaderName) : ?Header
|
||||
public function GetByName(string $sHeaderName): ?Header
|
||||
{
|
||||
$sHeaderNameLower = \strtolower($sHeaderName);
|
||||
foreach ($this as $oHeader) {
|
||||
|
|
@ -97,7 +97,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return null;
|
||||
}
|
||||
|
||||
public function SetParentCharset(string $sParentCharset) : self
|
||||
public function SetParentCharset(string $sParentCharset): self
|
||||
{
|
||||
if (\strlen($sParentCharset) && $this->sParentCharset !== $sParentCharset) {
|
||||
foreach ($this as $oHeader) {
|
||||
|
|
@ -108,7 +108,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function Parse(string $sRawHeaders, string $sParentCharset = '') : self
|
||||
public function Parse(string $sRawHeaders, string $sParentCharset = ''): self
|
||||
{
|
||||
$this->Clear();
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
* spf=pass (ORIGINATING: domain of "snappymail@domain.tld" designates 0.0.0.0 as permitted sender) smtp.mailfrom="snappymail@domain.tld";
|
||||
* dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=domain.tld (policy=none)
|
||||
*/
|
||||
public function AuthStatuses() : array
|
||||
public function AuthStatuses(): array
|
||||
{
|
||||
$aResult = [
|
||||
'dkim' => [],
|
||||
|
|
@ -222,13 +222,13 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
return \implode("\r\n", $this->getArrayCopy());
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array(
|
||||
'@Object' => 'Collection/MimeHeaderCollection',
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class Parameter implements \JsonSerializable
|
|||
$this->sValue = $sValue;
|
||||
}
|
||||
|
||||
public static function FromString(string $sRawParam) : self
|
||||
public static function FromString(string $sRawParam): self
|
||||
{
|
||||
$oParameter = new self('', '');
|
||||
|
||||
|
|
@ -40,22 +40,22 @@ class Parameter implements \JsonSerializable
|
|||
return $oParameter;
|
||||
}
|
||||
|
||||
public function Name() : string
|
||||
public function Name(): string
|
||||
{
|
||||
return $this->sName;
|
||||
}
|
||||
|
||||
public function Value() : string
|
||||
public function Value(): string
|
||||
{
|
||||
return $this->sValue;
|
||||
}
|
||||
|
||||
public function setValue(string $sValue) : void
|
||||
public function setValue(string $sValue): void
|
||||
{
|
||||
$this->sValue = $sValue;
|
||||
}
|
||||
|
||||
public function ToString(bool $bConvertSpecialsName = false) : string
|
||||
public function ToString(bool $bConvertSpecialsName = false): string
|
||||
{
|
||||
if (!\strlen($this->sName)) {
|
||||
return '';
|
||||
|
|
@ -72,13 +72,13 @@ class Parameter implements \JsonSerializable
|
|||
return $this->sName . '="' . $this->sValue . '"';
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->ToString();
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array(
|
||||
'name' => $this->sName,
|
||||
|
|
|
|||
|
|
@ -24,25 +24,25 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
\strlen($sRawParams) && $this->Parse($sRawParams);
|
||||
}
|
||||
|
||||
public function append($oParameter, bool $bToTop = false) : void
|
||||
public function append($oParameter, bool $bToTop = false): void
|
||||
{
|
||||
assert($oParameter instanceof Parameter);
|
||||
parent::offsetSet(\strtolower($oParameter->Name()), $oParameter);
|
||||
}
|
||||
|
||||
public function ParameterValueByName(string $sName) : string
|
||||
public function ParameterValueByName(string $sName): string
|
||||
{
|
||||
$oParam = $this->getParameter($sName);
|
||||
return $oParam ? $oParam->Value() : '';
|
||||
}
|
||||
|
||||
public function getParameter(string $sName) : ?Parameter
|
||||
public function getParameter(string $sName): ?Parameter
|
||||
{
|
||||
$sName = \strtolower(\trim($sName));
|
||||
return parent::offsetExists($sName) ? parent::offsetGet($sName) : null;
|
||||
}
|
||||
|
||||
public function setParameter(string $sName, string $sValue) : void
|
||||
public function setParameter(string $sName, string $sValue): void
|
||||
{
|
||||
$oParam = $this->getParameter($sName);
|
||||
if ($oParam) {
|
||||
|
|
@ -52,7 +52,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
public function Parse(string $sRawParams) : self
|
||||
public function Parse(string $sRawParams): self
|
||||
{
|
||||
$this->Clear();
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function ToString(bool $bConvertSpecialsName = false) : string
|
||||
public function ToString(bool $bConvertSpecialsName = false): string
|
||||
{
|
||||
$aResult = array();
|
||||
foreach ($this as $oParam) {
|
||||
|
|
@ -79,14 +79,14 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
return \count($aResult) ? \implode('; ', $aResult) : '';
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->ToString();
|
||||
}
|
||||
|
||||
/*
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$aResult = array();
|
||||
foreach ($this as $oParam) {
|
||||
|
|
@ -99,7 +99,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
*/
|
||||
|
||||
private function reParseParameters() : void
|
||||
private function reParseParameters(): void
|
||||
{
|
||||
$aDataToReParse = $this->getArrayCopy();
|
||||
$sCharset = \MailSo\Base\Enumerations\Charset::UTF_8;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class ConnectSettings implements \JsonSerializable
|
|||
}
|
||||
}
|
||||
|
||||
public function fixUsername(string $value, bool $allowShorten = true) : string
|
||||
public function fixUsername(string $value, bool $allowShorten = true): string
|
||||
{
|
||||
$value = \SnappyMail\IDN::emailToAscii($value);
|
||||
// $value = \SnappyMail\IDN::emailToAscii(\MailSo\Base\Utils::Trim($value));
|
||||
|
|
@ -104,7 +104,7 @@ class ConnectSettings implements \JsonSerializable
|
|||
return $value;
|
||||
}
|
||||
|
||||
public static function fromArray(array $aSettings) : self
|
||||
public static function fromArray(array $aSettings): self
|
||||
{
|
||||
$object = new static;
|
||||
$object->host = $aSettings['host'];
|
||||
|
|
@ -128,8 +128,8 @@ class ConnectSettings implements \JsonSerializable
|
|||
return $object;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array(
|
||||
// '@Object' => 'Object/ConnectSettings',
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class SSLContext implements \JsonSerializable
|
|||
$this->local_cert = \trim($oConfig->Get('ssl', 'local_cert', ''));
|
||||
}
|
||||
|
||||
public static function fromArray(array $settings) : self
|
||||
public static function fromArray(array $settings): self
|
||||
{
|
||||
$object = new static;
|
||||
foreach ($settings as $key => $value) {
|
||||
|
|
@ -59,8 +59,8 @@ class SSLContext implements \JsonSerializable
|
|||
return $object;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$aResult = \get_object_vars($this);
|
||||
// $aResult['@Object'] = 'Object/SSLContext';
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
|
||||
public bool $authLiteral = true;
|
||||
|
||||
public static function fromArray(array $aSettings) : self
|
||||
public static function fromArray(array $aSettings): self
|
||||
{
|
||||
$object = parent::fromArray($aSettings);
|
||||
$object->enabled = !empty($aSettings['enabled']);
|
||||
|
|
@ -31,8 +31,8 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
return $object;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return \array_merge(
|
||||
parent::jsonSerialize(),
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
$this->viewErrors = !!$oConfig->Get('labs', 'smtp_show_server_errors', false);
|
||||
}
|
||||
|
||||
public static function fromArray(array $aSettings) : self
|
||||
public static function fromArray(array $aSettings): self
|
||||
{
|
||||
$object = parent::fromArray($aSettings);
|
||||
$object->useAuth = !empty($aSettings['useAuth']);
|
||||
|
|
@ -48,8 +48,8 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
return $object;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return \array_merge(
|
||||
parent::jsonSerialize(),
|
||||
|
|
|
|||
|
|
@ -167,10 +167,7 @@ class Actions
|
|||
return $this->oConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function fabrica(string $sName, ?Model\Account $oAccount = null)
|
||||
protected function fabrica(string $sName, ?Model\Account $oAccount = null): mixed
|
||||
{
|
||||
$mResult = null;
|
||||
$this->oPlugins->RunHook('main.fabrica', array($sName, &$mResult), false);
|
||||
|
|
@ -958,12 +955,7 @@ class Actions
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mDefault = null
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetActionParam(string $sKey, ?mixed $mDefault = null)
|
||||
public function GetActionParam(string $sKey, mixed $mDefault = null): mixed
|
||||
{
|
||||
return isset($this->aCurrentActionParams[$sKey]) ?
|
||||
$this->aCurrentActionParams[$sKey] : $mDefault;
|
||||
|
|
|
|||
|
|
@ -7,10 +7,7 @@ use RainLoop\Utils;
|
|||
|
||||
trait Response
|
||||
{
|
||||
/**
|
||||
* @param mixed $mResult
|
||||
*/
|
||||
public function DefaultResponse($mResult, array $aAdditionalParams = array(), string $sActionName = '') : array
|
||||
public function DefaultResponse(mixed $mResult, array $aAdditionalParams = array(), string $sActionName = ''): array
|
||||
{
|
||||
if (false === $mResult) {
|
||||
if (!isset($aAdditionalParams['code'])) {
|
||||
|
|
@ -28,12 +25,12 @@ trait Response
|
|||
), $aAdditionalParams);
|
||||
}
|
||||
|
||||
public function TrueResponse(array $aAdditionalParams = array()) : array
|
||||
public function TrueResponse(array $aAdditionalParams = array()): array
|
||||
{
|
||||
return $this->DefaultResponse(true, $aAdditionalParams);
|
||||
}
|
||||
|
||||
public function FalseResponse(int $iErrorCode = 0, string $sErrorMessage = '', string $sAdditionalErrorMessage = '') : array
|
||||
public function FalseResponse(int $iErrorCode = 0, string $sErrorMessage = '', string $sAdditionalErrorMessage = ''): array
|
||||
{
|
||||
return $this->DefaultResponse(false, [
|
||||
'code' => $iErrorCode,
|
||||
|
|
@ -42,7 +39,7 @@ trait Response
|
|||
]);
|
||||
}
|
||||
|
||||
public function ExceptionResponse(\Throwable $oException) : array
|
||||
public function ExceptionResponse(\Throwable $oException): array
|
||||
{
|
||||
$iErrorCode = Notifications::UnknownError;
|
||||
$sErrorMessage = $oException->getMessage();
|
||||
|
|
@ -69,13 +66,8 @@ trait Response
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mResponse
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private $aCheckableFolder = null;
|
||||
private function responseObject($mResponse, string $sParent = '')
|
||||
private function responseObject(mixed $mResponse, string $sParent = ''): mixed
|
||||
{
|
||||
if (!($mResponse instanceof \JsonSerializable)) {
|
||||
if (\is_object($mResponse)) {
|
||||
|
|
|
|||
|
|
@ -33,56 +33,47 @@ abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
|
|||
\MailSo\Base\Utils::FunctionsCallable(array('apcu_fetch', 'apcu_store'));
|
||||
}
|
||||
|
||||
public function offsetExists($offset) : bool
|
||||
public function offsetExists(mixed $offset): bool
|
||||
{
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
public function offsetGet(mixed $offset): mixed
|
||||
{
|
||||
$offset = \explode('/', $offset, 2);
|
||||
$this->Get($offset[0], $offset[1]);
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) : void
|
||||
public function offsetSet(mixed $offset, mixed $value): void
|
||||
{
|
||||
$offset = \explode('/', $offset, 2);
|
||||
$this->Set($offset[0], $offset[1], $value);
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) : void
|
||||
public function offsetUnset(mixed $offset): void
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract function defaultValues() : array;
|
||||
protected abstract function defaultValues(): array;
|
||||
|
||||
public function IsInited() : bool
|
||||
public function IsInited(): bool
|
||||
{
|
||||
return \is_array($this->aData) && \count($this->aData);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return $this->aData;;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mDefault = null
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function Get(string $sSection, string $sName, $mDefault = null)
|
||||
public function Get(string $sSection, string $sName, mixed $mDefault = null): mixed
|
||||
{
|
||||
return isset($this->aData[$sSection][$sName][0])
|
||||
? $this->aData[$sSection][$sName][0]
|
||||
: $mDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mParamValue
|
||||
*/
|
||||
public function Set(string $sSectionKey, string $sParamKey, $mParamValue) : void
|
||||
public function Set(string $sSectionKey, string $sParamKey, mixed $mParamValue): void
|
||||
{
|
||||
if (isset($this->aData[$sSectionKey][$sParamKey][0])) {
|
||||
if (!\is_scalar($mParamValue)) {
|
||||
|
|
@ -109,7 +100,7 @@ abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
|
|||
}
|
||||
}
|
||||
|
||||
public function getDecrypted(string $sSection, string $sName, $mDefault = null)
|
||||
public function getDecrypted(string $sSection, string $sName, mixed $mDefault = null)
|
||||
{
|
||||
// $salt = \basename($this->sFile) not possible due to RainLoop\Plugins\Property
|
||||
if (!empty($this->aData[$sSection][$sName][0])) try {
|
||||
|
|
@ -119,19 +110,19 @@ abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
|
|||
return $mDefault;
|
||||
}
|
||||
|
||||
public function setEncrypted(string $sSectionKey, string $sParamKey, $mParamValue) : void
|
||||
public function setEncrypted(string $sSectionKey, string $sParamKey, mixed $mParamValue): void
|
||||
{
|
||||
// $salt = \basename($this->sFile) not possible due to RainLoop\Plugins\Property
|
||||
$mParamValue = \SnappyMail\Crypt::EncryptToJSON($mParamValue, \APP_SALT);
|
||||
$this->Set($sSectionKey, $sParamKey, $mParamValue);
|
||||
}
|
||||
|
||||
private function cacheKey() : string
|
||||
private function cacheKey(): string
|
||||
{
|
||||
return 'config:'.\sha1($this->sFile).':'.\sha1($this->sAdditionalFile).':';
|
||||
}
|
||||
|
||||
private function loadDataFromCache() : bool
|
||||
private function loadDataFromCache(): bool
|
||||
{
|
||||
if ($this->bUseApcCache) {
|
||||
$iMTime = \filemtime($this->sFile);
|
||||
|
|
@ -157,7 +148,7 @@ abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
|
|||
return false;
|
||||
}
|
||||
|
||||
private function storeDataToCache() : bool
|
||||
private function storeDataToCache(): bool
|
||||
{
|
||||
if ($this->bUseApcCache) {
|
||||
$iMTime = \filemtime($this->sFile);
|
||||
|
|
@ -179,7 +170,7 @@ abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
|
|||
return false;
|
||||
}
|
||||
|
||||
private function clearCache() : bool
|
||||
private function clearCache(): bool
|
||||
{
|
||||
if ($this->bUseApcCache) {
|
||||
$sKey = $this->cacheKey();
|
||||
|
|
@ -193,7 +184,7 @@ abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
|
|||
return false;
|
||||
}
|
||||
|
||||
public function Load() : bool
|
||||
public function Load(): bool
|
||||
{
|
||||
$sFile = $this->sFile;
|
||||
if (!\file_exists($sFile) && \str_ends_with($sFile, '.json')) {
|
||||
|
|
@ -248,7 +239,7 @@ abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
|
|||
return $this->Save();
|
||||
}
|
||||
|
||||
public function Save() : bool
|
||||
public function Save(): bool
|
||||
{
|
||||
if (\file_exists($this->sFile) && !\is_writable($this->sFile)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
APP_CONFIGURATION_NAME);
|
||||
}
|
||||
|
||||
public function Load() : bool
|
||||
public function Load(): bool
|
||||
{
|
||||
$bResult = parent::Load();
|
||||
|
||||
|
|
@ -64,12 +64,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
return $bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mDefault = null
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function Get(string $sSection, string $sName, $mDefault = null)
|
||||
public function Get(string $sSection, string $sName, mixed $mDefault = null): mixed
|
||||
{
|
||||
$mResult = parent::Get($sSection, $sName, $mDefault);
|
||||
if ($this->aReplaceEnv && \is_string($mResult)) {
|
||||
|
|
@ -92,7 +87,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
return $mResult;
|
||||
}
|
||||
|
||||
public function Set(string $sSectionKey, string $sParamKey, $mParamValue) : void
|
||||
public function Set(string $sSectionKey, string $sParamKey, $mParamValue): void
|
||||
{
|
||||
// Workarounds for the changed application structure
|
||||
if ('webmail' === $sSectionKey) {
|
||||
|
|
@ -143,17 +138,17 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
parent::Set($sSectionKey, $sParamKey, $mParamValue);
|
||||
}
|
||||
|
||||
public function SetPassword(\SnappyMail\SensitiveString $oPassword) : void
|
||||
public function SetPassword(\SnappyMail\SensitiveString $oPassword): void
|
||||
{
|
||||
$this->Set('security', 'admin_password', \password_hash($oPassword, PASSWORD_DEFAULT));
|
||||
}
|
||||
|
||||
public function ValidatePassword(\SnappyMail\SensitiveString $oPassword) : bool
|
||||
public function ValidatePassword(\SnappyMail\SensitiveString $oPassword): bool
|
||||
{
|
||||
return \strlen($oPassword) && \password_verify($oPassword, $this->Get('security', 'admin_password', ''));
|
||||
}
|
||||
|
||||
public function Save() : bool
|
||||
public function Save(): bool
|
||||
{
|
||||
$this->Set('version', 'current', APP_VERSION);
|
||||
$this->Set('version', 'saved', \gmdate('r'));
|
||||
|
|
@ -161,7 +156,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
return parent::Save();
|
||||
}
|
||||
|
||||
protected function defaultValues() : array
|
||||
protected function defaultValues(): array
|
||||
{
|
||||
$value = \ini_get('upload_max_filesize');
|
||||
$upload_max_filesize = \intval($value);
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ class Plugin extends \RainLoop\Config\AbstractConfig
|
|||
parent::__construct('plugin-'.$sPluginName.'.json');
|
||||
}
|
||||
|
||||
protected function defaultValues() : array
|
||||
protected function defaultValues(): array
|
||||
{
|
||||
return $this->aMap;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$aData = [];
|
||||
foreach (parent::jsonSerialize() as $sSectionKey => $aSectionValue) {
|
||||
|
|
|
|||
|
|
@ -23,38 +23,38 @@ abstract class Account implements \JsonSerializable
|
|||
|
||||
private ?Domain $oDomain = null;
|
||||
|
||||
public function Email() : string
|
||||
public function Email(): string
|
||||
{
|
||||
return $this->sEmail;
|
||||
}
|
||||
|
||||
public function Name() : string
|
||||
public function Name(): string
|
||||
{
|
||||
return $this->sName;
|
||||
}
|
||||
|
||||
public function ImapUser() : string
|
||||
public function ImapUser(): string
|
||||
{
|
||||
return $this->sImapUser;
|
||||
}
|
||||
|
||||
public function ImapPass() : string
|
||||
public function ImapPass(): string
|
||||
{
|
||||
return $this->oImapPass ? $this->oImapPass->getValue() : '';
|
||||
}
|
||||
|
||||
public function SmtpUser() : string
|
||||
public function SmtpUser(): string
|
||||
{
|
||||
return $this->sSmtpUser ?: ($this->oDomain ? $this->oDomain->SmtpSettings()->fixUsername($this->sEmail) : '');
|
||||
// return $this->sSmtpUser ?: $this->sEmail ?: $this->sImapUser;
|
||||
}
|
||||
|
||||
public function Domain() : ?Domain
|
||||
public function Domain(): ?Domain
|
||||
{
|
||||
return $this->oDomain;
|
||||
}
|
||||
|
||||
public function Hash() : string
|
||||
public function Hash(): string
|
||||
{
|
||||
return \sha1(\implode(APP_SALT, [
|
||||
$this->sEmail,
|
||||
|
|
@ -64,28 +64,28 @@ abstract class Account implements \JsonSerializable
|
|||
]));
|
||||
}
|
||||
|
||||
public function setImapUser(string $sImapUser) : void
|
||||
public function setImapUser(string $sImapUser): void
|
||||
{
|
||||
$this->sImapUser = $sImapUser;
|
||||
}
|
||||
|
||||
public function setImapPass(SensitiveString $oPassword) : void
|
||||
public function setImapPass(SensitiveString $oPassword): void
|
||||
{
|
||||
$this->oImapPass = $oPassword;
|
||||
}
|
||||
|
||||
public function setSmtpUser(string $sSmtpUser) : void
|
||||
public function setSmtpUser(string $sSmtpUser): void
|
||||
{
|
||||
$this->sSmtpUser = $sSmtpUser;
|
||||
}
|
||||
|
||||
public function setSmtpPass(SensitiveString $oPassword) : void
|
||||
public function setSmtpPass(SensitiveString $oPassword): void
|
||||
{
|
||||
$this->oSmtpPass = $oPassword;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$result = [
|
||||
'email' => $this->sEmail,
|
||||
|
|
@ -122,7 +122,7 @@ abstract class Account implements \JsonSerializable
|
|||
/**
|
||||
* Converts old numeric array to new associative array
|
||||
*/
|
||||
public static function convertArray(array $aAccount) : array
|
||||
public static function convertArray(array $aAccount): array
|
||||
{
|
||||
if (isset($aAccount['email'])) {
|
||||
return $aAccount;
|
||||
|
|
@ -193,7 +193,7 @@ abstract class Account implements \JsonSerializable
|
|||
return $oAccount;
|
||||
}
|
||||
|
||||
public function ImapConnectAndLogin(\RainLoop\Plugins\Manager $oPlugins, \MailSo\Imap\ImapClient $oImapClient, \RainLoop\Config\Application $oConfig) : bool
|
||||
public function ImapConnectAndLogin(\RainLoop\Plugins\Manager $oPlugins, \MailSo\Imap\ImapClient $oImapClient, \RainLoop\Config\Application $oConfig): bool
|
||||
{
|
||||
$oSettings = $this->Domain()->ImapSettings();
|
||||
$oSettings->timeout = \max($oSettings->timeout, (int) $oConfig->Get('imap', 'timeout', $oSettings->timeout));
|
||||
|
|
@ -218,7 +218,7 @@ abstract class Account implements \JsonSerializable
|
|||
return $this->netClientLogin($oImapClient, $oPlugins);
|
||||
}
|
||||
|
||||
public function SmtpConnectAndLogin(\RainLoop\Plugins\Manager $oPlugins, \MailSo\Smtp\SmtpClient $oSmtpClient) : bool
|
||||
public function SmtpConnectAndLogin(\RainLoop\Plugins\Manager $oPlugins, \MailSo\Smtp\SmtpClient $oSmtpClient): bool
|
||||
{
|
||||
$oSettings = $this->Domain()->SmtpSettings();
|
||||
$oSettings->username = $this->SmtpUser();
|
||||
|
|
@ -257,7 +257,7 @@ abstract class Account implements \JsonSerializable
|
|||
return $this->netClientLogin($oSieveClient, $oPlugins);
|
||||
}
|
||||
|
||||
private function netClientLogin(\MailSo\Net\NetClient $oClient, \RainLoop\Plugins\Manager $oPlugins) : bool
|
||||
private function netClientLogin(\MailSo\Net\NetClient $oClient, \RainLoop\Plugins\Manager $oPlugins): bool
|
||||
{
|
||||
/*
|
||||
$encrypted = !empty(\stream_get_meta_data($oClient->ConnectionResource())['crypto']);
|
||||
|
|
@ -280,7 +280,7 @@ abstract class Account implements \JsonSerializable
|
|||
|
||||
/*
|
||||
// Stores settings in AdditionalAccount else MainAccount
|
||||
public function settingsLocal() : \RainLoop\Settings
|
||||
public function settingsLocal(): \RainLoop\Settings
|
||||
{
|
||||
return \RainLoop\Api::Actions()->SettingsProvider(true)->Load($this);
|
||||
}
|
||||
|
|
@ -289,19 +289,19 @@ abstract class Account implements \JsonSerializable
|
|||
/**
|
||||
* @deprecated since v2.36.1
|
||||
*/
|
||||
public function IncLogin() : string
|
||||
public function IncLogin(): string
|
||||
{
|
||||
return $this->ImapUser();
|
||||
}
|
||||
public function IncPassword() : string
|
||||
public function IncPassword(): string
|
||||
{
|
||||
return $this->ImapPass();
|
||||
}
|
||||
public function OutLogin() : string
|
||||
public function OutLogin(): string
|
||||
{
|
||||
return $this->SmtpUser();
|
||||
}
|
||||
public function SetPassword(SensitiveString $oPassword) : void
|
||||
public function SetPassword(SensitiveString $oPassword): void
|
||||
{
|
||||
$this->oImapPass = $oPassword;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class Domain implements \JsonSerializable
|
|||
$this->whiteList = \trim($this->whiteList);
|
||||
}
|
||||
|
||||
public function Name() : string
|
||||
public function Name(): string
|
||||
{
|
||||
return $this->Name;
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ class Domain implements \JsonSerializable
|
|||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function IncHost() : string
|
||||
public function IncHost(): string
|
||||
{
|
||||
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
|
||||
return $this->IMAP->host;
|
||||
|
|
@ -56,7 +56,7 @@ class Domain implements \JsonSerializable
|
|||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function IncPort() : int
|
||||
public function IncPort(): int
|
||||
{
|
||||
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
|
||||
return $this->IMAP->port;
|
||||
|
|
@ -65,7 +65,7 @@ class Domain implements \JsonSerializable
|
|||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function IncShortLogin() : bool
|
||||
public function IncShortLogin(): bool
|
||||
{
|
||||
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
|
||||
return $this->IMAP->shortLogin;
|
||||
|
|
@ -74,7 +74,7 @@ class Domain implements \JsonSerializable
|
|||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function UseSieve() : bool
|
||||
public function UseSieve(): bool
|
||||
{
|
||||
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
|
||||
return $this->Sieve->enabled;
|
||||
|
|
@ -83,7 +83,7 @@ class Domain implements \JsonSerializable
|
|||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function OutHost() : string
|
||||
public function OutHost(): string
|
||||
{
|
||||
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
|
||||
return $this->SMTP->host;
|
||||
|
|
@ -92,19 +92,19 @@ class Domain implements \JsonSerializable
|
|||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function OutPort() : int
|
||||
public function OutPort(): int
|
||||
{
|
||||
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
|
||||
return $this->SMTP->port;
|
||||
}
|
||||
|
||||
public function SetAliasName(string $sAliasName) : void
|
||||
public function SetAliasName(string $sAliasName): void
|
||||
{
|
||||
// $this->aliasName = \SnappyMail\IDN::toAscii($sAliasName);
|
||||
$this->aliasName = \strtolower(\idn_to_ascii($sAliasName));
|
||||
}
|
||||
|
||||
public function ValidateWhiteList(string $sEmail) : bool
|
||||
public function ValidateWhiteList(string $sEmail): bool
|
||||
{
|
||||
$sW = $this->whiteList;
|
||||
if (!$sW) {
|
||||
|
|
@ -125,17 +125,17 @@ class Domain implements \JsonSerializable
|
|||
return false;
|
||||
}
|
||||
|
||||
public function ImapSettings() : \MailSo\Imap\Settings
|
||||
public function ImapSettings(): \MailSo\Imap\Settings
|
||||
{
|
||||
return $this->IMAP;
|
||||
}
|
||||
|
||||
public function SieveSettings() : \MailSo\Sieve\Settings
|
||||
public function SieveSettings(): \MailSo\Sieve\Settings
|
||||
{
|
||||
return $this->Sieve;
|
||||
}
|
||||
|
||||
public function SmtpSettings() : \MailSo\Smtp\Settings
|
||||
public function SmtpSettings(): \MailSo\Smtp\Settings
|
||||
{
|
||||
return $this->SMTP;
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ class Domain implements \JsonSerializable
|
|||
/**
|
||||
* See jsonSerialize() for valid values
|
||||
*/
|
||||
public static function fromArray(string $sName, array $aDomain) : ?self
|
||||
public static function fromArray(string $sName, array $aDomain): ?self
|
||||
{
|
||||
if (!\strlen($sName)) {
|
||||
return null;
|
||||
|
|
@ -186,7 +186,7 @@ class Domain implements \JsonSerializable
|
|||
/**
|
||||
* Used by old RainLoop ToIniString()
|
||||
*/
|
||||
public static function fromIniArray(string $sName, array $aDomain) : ?self
|
||||
public static function fromIniArray(string $sName, array $aDomain): ?self
|
||||
{
|
||||
$oDomain = null;
|
||||
if (\strlen($sName) && \strlen($aDomain['imap_host'])) {
|
||||
|
|
@ -220,7 +220,7 @@ class Domain implements \JsonSerializable
|
|||
/**
|
||||
* Use by old RainLoop fromIniArray()
|
||||
*/
|
||||
public static function StrConnectionSecurityTypeToCons(string $sType) : int
|
||||
public static function StrConnectionSecurityTypeToCons(string $sType): int
|
||||
{
|
||||
switch (\strtoupper($sType))
|
||||
{
|
||||
|
|
@ -232,8 +232,8 @@ class Domain implements \JsonSerializable
|
|||
return ConnectionSecurityType::NONE;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$aResult = array(
|
||||
// '@Object' => 'Object/Domain',
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class Identity implements \JsonSerializable
|
|||
}
|
||||
}
|
||||
|
||||
function toMime() : \MailSo\Mime\Email
|
||||
function toMime(): \MailSo\Mime\Email
|
||||
{
|
||||
return new \MailSo\Mime\Email($this->sEmail, $this->sName);
|
||||
}
|
||||
|
|
@ -143,8 +143,8 @@ class Identity implements \JsonSerializable
|
|||
);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array(
|
||||
'@Object' => 'Object/Identity',
|
||||
|
|
|
|||
|
|
@ -19,15 +19,15 @@ abstract class Base
|
|||
return !!\class_exists('PDO');
|
||||
}
|
||||
|
||||
abstract protected function getPdoSettings() : \RainLoop\Pdo\Settings;
|
||||
abstract protected function getPdoSettings(): \RainLoop\Pdo\Settings;
|
||||
|
||||
public function sqliteNoCaseCollationHelper(string $sStr1, string $sStr2) : int
|
||||
public function sqliteNoCaseCollationHelper(string $sStr1, string $sStr2): int
|
||||
{
|
||||
$this->oLogger->WriteDump(array($sStr1, $sStr2));
|
||||
return \strcmp(\mb_strtoupper($sStr1, 'UTF-8'), \mb_strtoupper($sStr2, 'UTF-8'));
|
||||
}
|
||||
|
||||
public static function getAvailableDrivers() : array
|
||||
public static function getAvailableDrivers(): array
|
||||
{
|
||||
return \class_exists('PDO', false)
|
||||
? \array_values(\array_intersect(['mysql', 'pgsql', 'sqlite'], \PDO::getAvailableDrivers()))
|
||||
|
|
@ -38,7 +38,7 @@ abstract class Base
|
|||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getPDO() : \PDO
|
||||
protected function getPDO(): \PDO
|
||||
{
|
||||
if ($this->oPDO) {
|
||||
return $this->oPDO;
|
||||
|
|
@ -100,7 +100,7 @@ abstract class Base
|
|||
return $oPdo;
|
||||
}
|
||||
|
||||
protected function lastInsertId(?string $sTabelName = null, ?string $sColumnName = null) : string
|
||||
protected function lastInsertId(?string $sTabelName = null, ?string $sColumnName = null): string
|
||||
{
|
||||
$mName = null;
|
||||
if ('pgsql' === $this->sDbType && null !== $sTabelName && $sColumnName !== null) {
|
||||
|
|
@ -110,22 +110,22 @@ abstract class Base
|
|||
return null === $mName ? $this->getPDO()->lastInsertId() : $this->getPDO()->lastInsertId($mName);
|
||||
}
|
||||
|
||||
protected function beginTransaction() : bool
|
||||
protected function beginTransaction(): bool
|
||||
{
|
||||
return $this->getPDO()->beginTransaction();
|
||||
}
|
||||
|
||||
protected function commit() : bool
|
||||
protected function commit(): bool
|
||||
{
|
||||
return $this->getPDO()->commit();
|
||||
}
|
||||
|
||||
protected function rollBack() : bool
|
||||
protected function rollBack(): bool
|
||||
{
|
||||
return $this->getPDO()->rollBack();
|
||||
}
|
||||
|
||||
protected function prepareAndExecute(string $sSql, array $aParams = array(), bool $bMultiplyParams = false, bool $bLogParams = false) : ?\PDOStatement
|
||||
protected function prepareAndExecute(string $sSql, array $aParams = array(), bool $bMultiplyParams = false, bool $bLogParams = false): ?\PDOStatement
|
||||
{
|
||||
if ($this->bExplain && !$bMultiplyParams) {
|
||||
$this->prepareAndExplain($sSql, $aParams);
|
||||
|
|
@ -180,10 +180,7 @@ abstract class Base
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mData
|
||||
*/
|
||||
protected function writeLog($mData)
|
||||
protected function writeLog(mixed $mData): void
|
||||
{
|
||||
if ($this->oLogger) {
|
||||
if ($mData instanceof \Throwable) {
|
||||
|
|
@ -196,13 +193,13 @@ abstract class Base
|
|||
}
|
||||
}
|
||||
|
||||
public function quoteValue(string $sValue) : string
|
||||
public function quoteValue(string $sValue): string
|
||||
{
|
||||
$oPdo = $this->getPDO();
|
||||
return $oPdo ? $oPdo->quote((string) $sValue, \PDO::PARAM_STR) : '\'\'';
|
||||
}
|
||||
|
||||
protected function getVersion(string $sName) : ?int
|
||||
protected function getVersion(string $sName): ?int
|
||||
{
|
||||
$oPdo = $this->getPDO();
|
||||
if ($oPdo) {
|
||||
|
|
@ -224,7 +221,7 @@ abstract class Base
|
|||
return null;
|
||||
}
|
||||
|
||||
protected function setVersion(string $sName, int $iVersion) : bool
|
||||
protected function setVersion(string $sName, int $iVersion): bool
|
||||
{
|
||||
$bResult = false;
|
||||
$oPdo = $this->getPDO();
|
||||
|
|
@ -283,7 +280,7 @@ abstract class Base
|
|||
return $bResult;
|
||||
}
|
||||
|
||||
protected function dataBaseUpgrade(string $sName, array $aData = array()) : bool
|
||||
protected function dataBaseUpgrade(string $sName, array $aData = array()): bool
|
||||
{
|
||||
$iFromVersion = null;
|
||||
try
|
||||
|
|
|
|||
|
|
@ -39,18 +39,18 @@ abstract class AbstractPlugin
|
|||
$this->sName = static::NAME;
|
||||
}
|
||||
|
||||
public function Name() : string
|
||||
public function Name(): string
|
||||
{
|
||||
return $this->sName;
|
||||
}
|
||||
|
||||
public function Description() : string
|
||||
public function Description(): string
|
||||
{
|
||||
$sFile = $this->Path().'/README';
|
||||
return \is_readable($sFile) ? \file_get_contents($sFile) : static::DESCRIPTION;
|
||||
}
|
||||
|
||||
public function UseLangs(?bool $bLangs = null) : bool
|
||||
public function UseLangs(?bool $bLangs = null): bool
|
||||
{
|
||||
if (null !== $bLangs) {
|
||||
$this->bLangs = $bLangs;
|
||||
|
|
@ -59,47 +59,47 @@ abstract class AbstractPlugin
|
|||
return $this->bLangs;
|
||||
}
|
||||
|
||||
protected function configMapping() : array
|
||||
protected function configMapping(): array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function Supported() : string
|
||||
public function Supported(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function Init() : void
|
||||
public function Init(): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function FilterAppDataPluginSection(bool $bAdmin, bool $bAuth, array &$aConfig) : void
|
||||
public function FilterAppDataPluginSection(bool $bAdmin, bool $bAuth, array &$aConfig): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
final public function Hash() : string
|
||||
final public function Hash(): string
|
||||
{
|
||||
return static::class . '@' . static::VERSION;
|
||||
}
|
||||
|
||||
final public function Config() : \RainLoop\Config\Plugin
|
||||
final public function Config(): \RainLoop\Config\Plugin
|
||||
{
|
||||
return $this->oPluginConfig;
|
||||
}
|
||||
|
||||
final public function Manager() : \RainLoop\Plugins\Manager
|
||||
final public function Manager(): \RainLoop\Plugins\Manager
|
||||
{
|
||||
return $this->oPluginManager;
|
||||
}
|
||||
|
||||
final public function Path() : string
|
||||
final public function Path(): string
|
||||
{
|
||||
return $this->sPath;
|
||||
}
|
||||
|
||||
final public function ConfigMap(bool $flatten = false) : array
|
||||
final public function ConfigMap(bool $flatten = false): array
|
||||
{
|
||||
if (null === $this->aConfigMap) {
|
||||
$this->aConfigMap = $this->configMapping();
|
||||
|
|
@ -126,28 +126,28 @@ abstract class AbstractPlugin
|
|||
return $this->aConfigMap;
|
||||
}
|
||||
|
||||
final public function SetPath(string $sPath) : self
|
||||
final public function SetPath(string $sPath): self
|
||||
{
|
||||
$this->sPath = $sPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function SetName(string $sName) : self
|
||||
final public function SetName(string $sName): self
|
||||
{
|
||||
$this->sName = $sName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function SetPluginManager(\RainLoop\Plugins\Manager $oPluginManager) : self
|
||||
final public function SetPluginManager(\RainLoop\Plugins\Manager $oPluginManager): self
|
||||
{
|
||||
$this->oPluginManager = $oPluginManager;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function SetPluginConfig(\RainLoop\Config\Plugin $oPluginConfig) : self
|
||||
final public function SetPluginConfig(\RainLoop\Config\Plugin $oPluginConfig): self
|
||||
{
|
||||
$this->oPluginConfig = $oPluginConfig;
|
||||
if ($oPluginConfig->IsInited() && !$oPluginConfig->Load()) {
|
||||
|
|
@ -156,7 +156,7 @@ abstract class AbstractPlugin
|
|||
return $this;
|
||||
}
|
||||
|
||||
final protected function addHook(string $sHookName, string $sFunctionName) : self
|
||||
final protected function addHook(string $sHookName, string $sFunctionName): self
|
||||
{
|
||||
if ($this->oPluginManager) {
|
||||
$this->oPluginManager->AddHook($sHookName, array($this, $sFunctionName));
|
||||
|
|
@ -165,7 +165,7 @@ abstract class AbstractPlugin
|
|||
return $this;
|
||||
}
|
||||
|
||||
final protected function addCss(string $sFile, bool $bAdminScope = false) : self
|
||||
final protected function addCss(string $sFile, bool $bAdminScope = false): self
|
||||
{
|
||||
if ($this->oPluginManager) {
|
||||
$this->oPluginManager->AddCss($this->sPath.'/'.$sFile, $bAdminScope);
|
||||
|
|
@ -174,7 +174,7 @@ abstract class AbstractPlugin
|
|||
return $this;
|
||||
}
|
||||
|
||||
final protected function addJs(string $sFile, bool $bAdminScope = false) : self
|
||||
final protected function addJs(string $sFile, bool $bAdminScope = false): self
|
||||
{
|
||||
if ($this->oPluginManager) {
|
||||
$this->oPluginManager->AddJs($this->sPath.'/'.$sFile, $bAdminScope);
|
||||
|
|
@ -183,7 +183,7 @@ abstract class AbstractPlugin
|
|||
return $this;
|
||||
}
|
||||
|
||||
final protected function addTemplate(string $sFile, bool $bAdminScope = false) : self
|
||||
final protected function addTemplate(string $sFile, bool $bAdminScope = false): self
|
||||
{
|
||||
if ($this->oPluginManager) {
|
||||
$this->oPluginManager->AddTemplate($this->sPath.'/'.$sFile, $bAdminScope);
|
||||
|
|
@ -192,7 +192,7 @@ abstract class AbstractPlugin
|
|||
return $this;
|
||||
}
|
||||
|
||||
final protected function addPartHook(string $sActionName, string $sFunctionName) : self
|
||||
final protected function addPartHook(string $sActionName, string $sFunctionName): self
|
||||
{
|
||||
if ($this->oPluginManager) {
|
||||
$this->oPluginManager->AddAdditionalPartAction($sActionName, array($this, $sFunctionName));
|
||||
|
|
@ -201,7 +201,7 @@ abstract class AbstractPlugin
|
|||
return $this;
|
||||
}
|
||||
|
||||
final protected function addJsonHook(string $sActionName, string $sFunctionName = '') : self
|
||||
final protected function addJsonHook(string $sActionName, string $sFunctionName = ''): self
|
||||
{
|
||||
if ($this->oPluginManager) {
|
||||
$this->oPluginManager->AddAdditionalJsonAction($sActionName, array($this, $sFunctionName ?: $sActionName));
|
||||
|
|
@ -210,10 +210,7 @@ abstract class AbstractPlugin
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed false|string|array
|
||||
*/
|
||||
final protected function jsonResponse(string $sFunctionName, $mData)
|
||||
final protected function jsonResponse(string $sFunctionName, mixed $mData): false|string|array
|
||||
{
|
||||
return $this->oPluginManager
|
||||
? $this->oPluginManager->JsonResponseHelper(
|
||||
|
|
@ -221,26 +218,21 @@ abstract class AbstractPlugin
|
|||
: \json_encode($mData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mDefault = null
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
final public function jsonParam(string $sKey, $mDefault = null)
|
||||
final public function jsonParam(string $sKey, mixed $mDefault = null): mixed
|
||||
{
|
||||
return $this->oPluginManager
|
||||
? $this->oPluginManager->Actions()->GetActionParam($sKey, $mDefault)
|
||||
: $mDefault;
|
||||
}
|
||||
|
||||
final public function getUserSettings() : array
|
||||
final public function getUserSettings(): array
|
||||
{
|
||||
return $this->oPluginManager
|
||||
? $this->oPluginManager->GetUserPluginSettings($this->Name())
|
||||
: array();
|
||||
}
|
||||
|
||||
final public function saveUserSettings(array $aSettings) : bool
|
||||
final public function saveUserSettings(array $aSettings): bool
|
||||
{
|
||||
return $this->oPluginManager
|
||||
&& $this->oPluginManager->SaveUserPluginSettings($this->Name(), $aSettings);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class Manager
|
|||
}
|
||||
}
|
||||
|
||||
public function loadPlugin(string $sName) : bool
|
||||
public function loadPlugin(string $sName): bool
|
||||
{
|
||||
if (!isset($this->aPlugins[$sName])) {
|
||||
$oPlugin = $this->CreatePluginByName($sName);
|
||||
|
|
@ -57,7 +57,7 @@ class Manager
|
|||
return isset($this->aPlugins[$sName]);
|
||||
}
|
||||
|
||||
protected static function getPluginPath(string $sName) : ?string
|
||||
protected static function getPluginPath(string $sName): ?string
|
||||
{
|
||||
$sPath = APP_PLUGINS_PATH.$sName;
|
||||
if (\is_readable("{$sPath}/index.php")) {
|
||||
|
|
@ -69,7 +69,7 @@ class Manager
|
|||
return null;
|
||||
}
|
||||
|
||||
public function CreatePluginByName(string $sName) : ?\RainLoop\Plugins\AbstractPlugin
|
||||
public function CreatePluginByName(string $sName): ?\RainLoop\Plugins\AbstractPlugin
|
||||
{
|
||||
$oPlugin = null;
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ class Manager
|
|||
return $oPlugin;
|
||||
}
|
||||
|
||||
public function InstalledPlugins() : array
|
||||
public function InstalledPlugins(): array
|
||||
{
|
||||
$aList = array();
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ class Manager
|
|||
return $aList;
|
||||
}
|
||||
|
||||
public function convertPluginFolderNameToClassName(string $sFolderName) : string
|
||||
public function convertPluginFolderNameToClassName(string $sFolderName): string
|
||||
{
|
||||
$aParts = \array_map('ucfirst', \array_map('strtolower',
|
||||
\explode(' ', \preg_replace('/[^a-z0-9]+/', ' ', $sFolderName))));
|
||||
|
|
@ -129,7 +129,7 @@ class Manager
|
|||
return \implode($aParts).'Plugin';
|
||||
}
|
||||
|
||||
public function loadPluginByName(string $sName) : ?string
|
||||
public function loadPluginByName(string $sName): ?string
|
||||
{
|
||||
if (\preg_match('/^[a-z0-9\\-]+$/', $sName)) {
|
||||
$sClassName = $this->convertPluginFolderNameToClassName($sName);
|
||||
|
|
@ -148,12 +148,12 @@ class Manager
|
|||
return null;
|
||||
}
|
||||
|
||||
public function Actions() : \RainLoop\Actions
|
||||
public function Actions(): \RainLoop\Actions
|
||||
{
|
||||
return $this->oActions;
|
||||
}
|
||||
|
||||
public function Hash() : string
|
||||
public function Hash(): string
|
||||
{
|
||||
return \md5(
|
||||
\array_reduce($this->aPlugins, function($sResult, $oPlugin){
|
||||
|
|
@ -164,12 +164,12 @@ class Manager
|
|||
);
|
||||
}
|
||||
|
||||
public function HaveJs(bool $bAdminScope = false) : bool
|
||||
public function HaveJs(bool $bAdminScope = false): bool
|
||||
{
|
||||
return $this->bIsEnabled && \count($this->aJs[$bAdminScope ? 1 : 0]);
|
||||
}
|
||||
|
||||
public function CompileCss(bool $bAdminScope, bool &$bLess, bool $bMinified) : string
|
||||
public function CompileCss(bool $bAdminScope, bool &$bLess, bool $bMinified): string
|
||||
{
|
||||
$aResult = array();
|
||||
if ($this->bIsEnabled) {
|
||||
|
|
@ -189,7 +189,7 @@ class Manager
|
|||
return \implode("\n", $aResult);
|
||||
}
|
||||
|
||||
public function CompileJs(bool $bAdminScope = false, bool $bMinified = false) : string
|
||||
public function CompileJs(bool $bAdminScope = false, bool $bMinified = false): string
|
||||
{
|
||||
$aResult = array();
|
||||
if ($this->bIsEnabled) {
|
||||
|
|
@ -209,7 +209,7 @@ class Manager
|
|||
return \implode("\n", $aResult);
|
||||
}
|
||||
|
||||
public function CompileTemplate(array &$aList, bool $bAdminScope = false) : void
|
||||
public function CompileTemplate(array &$aList, bool $bAdminScope = false): void
|
||||
{
|
||||
if ($this->bIsEnabled) {
|
||||
$aTemplates = $bAdminScope ? $this->aAdminTemplates : $this->aTemplates;
|
||||
|
|
@ -222,7 +222,7 @@ class Manager
|
|||
}
|
||||
}
|
||||
|
||||
public function InitAppData(bool $bAdmin, array &$aAppData, ?\RainLoop\Model\Account $oAccount = null) : self
|
||||
public function InitAppData(bool $bAdmin, array &$aAppData, ?\RainLoop\Model\Account $oAccount = null): self
|
||||
{
|
||||
if ($this->bIsEnabled && isset($aAppData['Plugins']) && \is_array($aAppData['Plugins'])) {
|
||||
$bAuth = !empty($aAppData['Auth']);
|
||||
|
|
@ -255,10 +255,7 @@ class Manager
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mCallbak
|
||||
*/
|
||||
public function AddHook(string $sHookName, $mCallbak) : self
|
||||
public function AddHook(string $sHookName, callable $mCallbak): self
|
||||
{
|
||||
if ($this->bIsEnabled && \is_callable($mCallbak)) {
|
||||
$sHookName = \strtolower($sHookName);
|
||||
|
|
@ -270,7 +267,7 @@ class Manager
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function AddCss(string $sFile, bool $bAdminScope = false) : self
|
||||
public function AddCss(string $sFile, bool $bAdminScope = false): self
|
||||
{
|
||||
if ($this->bIsEnabled) {
|
||||
$this->aCss[$bAdminScope ? 1 : 0][] = $sFile;
|
||||
|
|
@ -278,7 +275,7 @@ class Manager
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function AddJs(string $sFile, bool $bAdminScope = false) : self
|
||||
public function AddJs(string $sFile, bool $bAdminScope = false): self
|
||||
{
|
||||
if ($this->bIsEnabled) {
|
||||
$this->aJs[$bAdminScope ? 1 : 0][$sFile] = $sFile;
|
||||
|
|
@ -287,7 +284,7 @@ class Manager
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function AddTemplate(string $sFile, bool $bAdminScope = false) : self
|
||||
public function AddTemplate(string $sFile, bool $bAdminScope = false): self
|
||||
{
|
||||
if ($this->bIsEnabled) {
|
||||
if ($bAdminScope) {
|
||||
|
|
@ -324,7 +321,7 @@ class Manager
|
|||
}
|
||||
*/
|
||||
|
||||
public function RunHook(string $sHookName, array $aArg = array(), bool $bLogHook = true) : self
|
||||
public function RunHook(string $sHookName, array $aArg = array(), bool $bLogHook = true): self
|
||||
{
|
||||
if ($this->bIsEnabled) {
|
||||
$sHookName = \strtolower($sHookName);
|
||||
|
|
@ -344,10 +341,7 @@ class Manager
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mCallbak
|
||||
*/
|
||||
public function AddAdditionalPartAction(string $sActionName, $mCallbak) : self
|
||||
public function AddAdditionalPartAction(string $sActionName, callable $mCallbak): self
|
||||
{
|
||||
if ($this->bIsEnabled && \is_callable($mCallbak)) {
|
||||
$sActionName = \strtolower($sActionName);
|
||||
|
|
@ -361,7 +355,7 @@ class Manager
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function RunAdditionalPart(string $sActionName, array $aParts = array()) : bool
|
||||
public function RunAdditionalPart(string $sActionName, array $aParts = array()): bool
|
||||
{
|
||||
$bResult = false;
|
||||
if ($this->bIsEnabled) {
|
||||
|
|
@ -376,7 +370,7 @@ class Manager
|
|||
return $bResult;
|
||||
}
|
||||
|
||||
public function AddAdditionalJsonAction(string $sActionName, callable $mCallback) : self
|
||||
public function AddAdditionalJsonAction(string $sActionName, callable $mCallback): self
|
||||
{
|
||||
$sActionName = "DoPlugin{$sActionName}";
|
||||
if ($this->bIsEnabled && \strlen($sActionName) && !isset($this->aAdditionalJson[$sActionName])) {
|
||||
|
|
@ -385,28 +379,22 @@ class Manager
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function HasAdditionalJson(string $sActionName) : bool
|
||||
public function HasAdditionalJson(string $sActionName): bool
|
||||
{
|
||||
return $this->bIsEnabled && isset($this->aAdditionalJson[$sActionName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function RunAdditionalJson(string $sActionName)
|
||||
public function RunAdditionalJson(string $sActionName): mixed
|
||||
{
|
||||
return $this->HasAdditionalJson($sActionName) ? $this->aAdditionalJson[$sActionName]() : false;
|
||||
return $this->HasAdditionalJson($sActionName) ? $this->aAdditionalJson[$sActionName](): false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mData
|
||||
*/
|
||||
public function JsonResponseHelper(string $sFunctionName, $mData) : array
|
||||
public function JsonResponseHelper(string $sFunctionName, mixed $mData): array
|
||||
{
|
||||
return $this->oActions->DefaultResponse($mData, [], $sFunctionName);
|
||||
}
|
||||
|
||||
public function GetUserPluginSettings(string $sPluginName) : array
|
||||
public function GetUserPluginSettings(string $sPluginName): array
|
||||
{
|
||||
$oAccount = $this->oActions->getAccountFromToken();
|
||||
if ($oAccount) {
|
||||
|
|
@ -422,7 +410,7 @@ class Manager
|
|||
return array();
|
||||
}
|
||||
|
||||
public function SaveUserPluginSettings(string $sPluginName, array $aSettings) : bool
|
||||
public function SaveUserPluginSettings(string $sPluginName, array $aSettings): bool
|
||||
{
|
||||
$oAccount = $this->oActions->getAccountFromToken();
|
||||
if ($oAccount) {
|
||||
|
|
@ -452,7 +440,7 @@ class Manager
|
|||
return false;
|
||||
}
|
||||
|
||||
public function ReadLang(string $sLang, array &$aLang) : void
|
||||
public function ReadLang(string $sLang, array &$aLang): void
|
||||
{
|
||||
if ($this->bIsEnabled) {
|
||||
foreach ($this->aPlugins as $oPlugin) {
|
||||
|
|
@ -492,22 +480,22 @@ class Manager
|
|||
}
|
||||
}
|
||||
|
||||
public function IsEnabled() : bool
|
||||
public function IsEnabled(): bool
|
||||
{
|
||||
return $this->bIsEnabled;
|
||||
}
|
||||
|
||||
public function count() : int
|
||||
public function count(): int
|
||||
{
|
||||
return $this->bIsEnabled ? \count($this->aPlugins) : 0;
|
||||
}
|
||||
|
||||
public function WriteLog(string $sDesc, int $iType = \LOG_INFO) : void
|
||||
public function WriteLog(string $sDesc, int $iType = \LOG_INFO): void
|
||||
{
|
||||
$this->logWrite($sDesc, $iType, 'PLUGIN');
|
||||
}
|
||||
|
||||
public function WriteException(string $sDesc, int $iType = \LOG_INFO) : void
|
||||
public function WriteException(string $sDesc, int $iType = \LOG_INFO): void
|
||||
{
|
||||
$this->logException($sDesc, $iType, 'PLUGIN');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,7 @@ class Property implements \JsonSerializable
|
|||
{
|
||||
private string $sName;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $mValue;
|
||||
private mixed $mValue;
|
||||
|
||||
private string $sLabel = '';
|
||||
|
||||
|
|
@ -21,10 +18,7 @@ class Property implements \JsonSerializable
|
|||
|
||||
private bool $bAllowedInJs = false;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $mDefaultValue = '';
|
||||
private mixed $mDefaultValue = '';
|
||||
|
||||
private array $aOptions = [];
|
||||
|
||||
|
|
@ -37,21 +31,18 @@ class Property implements \JsonSerializable
|
|||
$this->sName = $sName;
|
||||
}
|
||||
|
||||
public static function NewInstance(string $sName) : self
|
||||
public static function NewInstance(string $sName): self
|
||||
{
|
||||
return new self($sName);
|
||||
}
|
||||
|
||||
public function SetType(int $iType) : self
|
||||
public function SetType(int $iType): self
|
||||
{
|
||||
$this->iType = (int) $iType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mValue
|
||||
*/
|
||||
public function SetValue($mValue) : void
|
||||
public function SetValue(mixed $mValue): void
|
||||
{
|
||||
$this->mValue = null;
|
||||
switch ($this->iType) {
|
||||
|
|
@ -87,7 +78,7 @@ class Property implements \JsonSerializable
|
|||
/**
|
||||
* @param mixed $mDefaultValue
|
||||
*/
|
||||
public function SetDefaultValue($mDefaultValue) : self
|
||||
public function SetDefaultValue($mDefaultValue): self
|
||||
{
|
||||
if (\is_array($mDefaultValue)) {
|
||||
$this->aOptions = $mDefaultValue;
|
||||
|
|
@ -97,95 +88,89 @@ class Property implements \JsonSerializable
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function SetOptions(array $aOptions) : self
|
||||
public function SetOptions(array $aOptions): self
|
||||
{
|
||||
$this->aOptions = $aOptions;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetPlaceholder(string $sPlaceholder) : self
|
||||
public function SetPlaceholder(string $sPlaceholder): self
|
||||
{
|
||||
$this->sPlaceholder = $sPlaceholder;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetLabel(string $sLabel) : self
|
||||
public function SetLabel(string $sLabel): self
|
||||
{
|
||||
$this->sLabel = $sLabel;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetDescription(string $sDesc) : self
|
||||
public function SetDescription(string $sDesc): self
|
||||
{
|
||||
$this->sDesc = $sDesc;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetAllowedInJs(bool $bValue = true) : self
|
||||
public function SetAllowedInJs(bool $bValue = true): self
|
||||
{
|
||||
$this->bAllowedInJs = $bValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetEncrypted(bool $bValue = true) : self
|
||||
public function SetEncrypted(bool $bValue = true): self
|
||||
{
|
||||
$this->encrypted = $bValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function Name() : string
|
||||
public function Name(): string
|
||||
{
|
||||
return $this->sName;
|
||||
}
|
||||
|
||||
public function AllowedInJs() : bool
|
||||
public function AllowedInJs(): bool
|
||||
{
|
||||
return $this->bAllowedInJs;
|
||||
}
|
||||
|
||||
public function Description() : string
|
||||
public function Description(): string
|
||||
{
|
||||
return $this->sDesc;
|
||||
}
|
||||
|
||||
public function Label() : string
|
||||
public function Label(): string
|
||||
{
|
||||
return $this->sLabel;
|
||||
}
|
||||
|
||||
public function Type() : int
|
||||
public function Type(): int
|
||||
{
|
||||
return $this->iType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function DefaultValue()
|
||||
public function DefaultValue(): mixed
|
||||
{
|
||||
return $this->mDefaultValue;
|
||||
}
|
||||
|
||||
public function Options() : array
|
||||
public function Options(): array
|
||||
{
|
||||
return $this->aOptions;
|
||||
}
|
||||
|
||||
public function Placeholder() : string
|
||||
public function Placeholder(): string
|
||||
{
|
||||
return $this->sPlaceholder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function Value()
|
||||
public function Value(): mixed
|
||||
{
|
||||
return $this->mValue;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
$mValue = $this->mValue;
|
||||
if ($this->encrypted && $mValue) try {
|
||||
|
|
|
|||
|
|
@ -5,18 +5,15 @@ namespace RainLoop\Plugins;
|
|||
//class PropertyCollection extends \MailSo\Base\Collection
|
||||
class PropertyCollection extends \ArrayObject implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sLabel;
|
||||
private string $sLabel;
|
||||
|
||||
function __construct(string $sLabel)
|
||||
{
|
||||
$this->sLabel = $sLabel;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array(
|
||||
'@Object' => 'Object/PluginProperty',
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ trait CardDAV
|
|||
return $mResult;
|
||||
}
|
||||
|
||||
protected function davClientRequest(DAVClient $oClient, string $sCmd, string $sUrl, $mData = null) : ?\SnappyMail\HTTP\Response
|
||||
protected function davClientRequest(DAVClient $oClient, string $sCmd, string $sUrl, mixed $mData = null): ?\SnappyMail\HTTP\Response
|
||||
{
|
||||
\MailSo\Base\Utils::ResetTimeLimit();
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ trait CardDAV
|
|||
return null;
|
||||
}
|
||||
|
||||
private function detectionPropFind(DAVClient $oClient, string $sPath) : ?array
|
||||
private function detectionPropFind(DAVClient $oClient, string $sPath): ?array
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -133,7 +133,7 @@ trait CardDAV
|
|||
private function getContactsPaths(DAVClient $oClient, string $sPath, string $sUser,
|
||||
#[\SensitiveParameter]
|
||||
string $sPassword,
|
||||
string $sProxy = '') : array
|
||||
string $sProxy = ''): array
|
||||
{
|
||||
$aContactsPaths = array();
|
||||
|
||||
|
|
@ -263,7 +263,7 @@ trait CardDAV
|
|||
/**
|
||||
* Checks if remote path resourcetype is an addressbook
|
||||
*/
|
||||
private function checkContactsPath(DAVClient $oClient, string $sPath) : bool
|
||||
private function checkContactsPath(DAVClient $oClient, string $sPath): bool
|
||||
{
|
||||
$aResponse = $oClient->propFind($sPath, array(
|
||||
'{DAV:}resourcetype'
|
||||
|
|
@ -290,7 +290,7 @@ trait CardDAV
|
|||
#[\SensitiveParameter]
|
||||
string $sPassword,
|
||||
string $sProxy = ''
|
||||
) : DAVClient
|
||||
): DAVClient
|
||||
{
|
||||
if (!\preg_match('/^http[s]?:\/\//i', $sUrl)) {
|
||||
$sUrl = \preg_replace('/^fruux\.com/i', 'dav.fruux.com', $sUrl);
|
||||
|
|
@ -331,7 +331,7 @@ trait CardDAV
|
|||
return $oClient;
|
||||
}
|
||||
|
||||
public function getDavClient() : ?DAVClient
|
||||
public function getDavClient(): ?DAVClient
|
||||
{
|
||||
if (!$this->aDAVConfig['Mode']) {
|
||||
return null;
|
||||
|
|
@ -408,7 +408,7 @@ trait CardDAV
|
|||
return $bGood ? $oClient : null;
|
||||
}
|
||||
|
||||
private static function hasDAVCollection($aItem)
|
||||
private static function hasDAVCollection($aItem): bool
|
||||
{
|
||||
return !empty($aItem['{DAV:}resourcetype'])
|
||||
&& \is_array($aItem['{DAV:}resourcetype'])
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ class Contact implements \JsonSerializable
|
|||
$this->IdContactStr = $sUid;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array(
|
||||
'@Object' => 'Object/Contact',
|
||||
|
|
|
|||
|
|
@ -6,30 +6,15 @@ use RainLoop\Providers\AddressBook\Enumerations\PropertyType;
|
|||
|
||||
class Property implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $IdProperty = 0;
|
||||
public int $IdProperty = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $Type;
|
||||
public int $Type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $TypeStr;
|
||||
public string $TypeStr;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Value;
|
||||
public string $Value;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $Frec = 0;
|
||||
public int $Frec = 0;
|
||||
|
||||
public function __construct(int $iType = PropertyType::UNKNOWN, string $sValue = '', string $sTypeStr = '')
|
||||
{
|
||||
|
|
@ -38,8 +23,7 @@ class Property implements \JsonSerializable
|
|||
$this->TypeStr = $sTypeStr;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
throw new \Exception('Obsolete ' . __CLASS__ . '::jsonSerialize()');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,7 @@ use
|
|||
|
||||
class Legacy
|
||||
{
|
||||
/**
|
||||
* @param mixed $oProp
|
||||
*/
|
||||
private static function yieldPropertyHelper($oArrayProp, int $iType) : iterable
|
||||
private static function yieldPropertyHelper(mixed $oArrayProp, int $iType): iterable
|
||||
{
|
||||
$aTmp = [];
|
||||
foreach ($oArrayProp as $oProp) {
|
||||
|
|
@ -31,10 +28,7 @@ class Legacy
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $oProp
|
||||
*/
|
||||
private static function getPropertyValueHelper($oProp, bool $bOldVersion) : string
|
||||
private static function getPropertyValueHelper(mixed $oProp, bool $bOldVersion): string
|
||||
{
|
||||
$sValue = \trim($oProp);
|
||||
if ($bOldVersion && !isset($oProp->parameters['CHARSET'])) {
|
||||
|
|
@ -48,7 +42,7 @@ class Legacy
|
|||
return \MailSo\Base\Utils::Utf8Clear($sValue);
|
||||
}
|
||||
|
||||
public static function VCardToProperties(\Sabre\VObject\Component\VCard $oVCard) : iterable
|
||||
public static function VCardToProperties(\Sabre\VObject\Component\VCard $oVCard): iterable
|
||||
{
|
||||
yield new Property(PropertyType::JCARD, \json_encode($oVCard));
|
||||
|
||||
|
|
|
|||
|
|
@ -70,26 +70,26 @@ class PdoAddressBook
|
|||
return \in_array($sType, static::getAvailableDrivers()) ? $sType : 'sqlite';
|
||||
}
|
||||
|
||||
public function IsSupported() : bool
|
||||
public function IsSupported(): bool
|
||||
{
|
||||
$aDrivers = static::getAvailableDrivers();
|
||||
return \is_array($aDrivers) && \in_array($this->settings->driver, $aDrivers);
|
||||
}
|
||||
|
||||
public function SetEmail(string $sEmail) : bool
|
||||
public function SetEmail(string $sEmail): bool
|
||||
{
|
||||
$this->iUserID = $this->getUserId($sEmail);
|
||||
return 0 < $this->iUserID;
|
||||
}
|
||||
|
||||
private function flushDeletedContacts() : bool
|
||||
private function flushDeletedContacts(): bool
|
||||
{
|
||||
return !!$this->prepareAndExecute('DELETE FROM rainloop_ab_contacts WHERE id_user = :id_user AND deleted = 1', array(
|
||||
':id_user' => array($this->iUserID, \PDO::PARAM_INT)
|
||||
));
|
||||
}
|
||||
|
||||
private function prepareDatabaseSyncData() : array
|
||||
private function prepareDatabaseSyncData(): array
|
||||
{
|
||||
$aResult = array();
|
||||
$oStmt = $this->prepareAndExecute('SELECT id_contact, id_contact_str, changed, deleted, etag
|
||||
|
|
@ -122,7 +122,7 @@ class PdoAddressBook
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
public function Sync() : bool
|
||||
public function Sync(): bool
|
||||
{
|
||||
if (1 > $this->iUserID) {
|
||||
\SnappyMail\Log::warning('PdoAddressBook', 'Sync() invalid $iUserID');
|
||||
|
|
@ -329,7 +329,7 @@ class PdoAddressBook
|
|||
return true;
|
||||
}
|
||||
|
||||
public function Export(string $sType = 'vcf') : bool
|
||||
public function Export(string $sType = 'vcf'): bool
|
||||
{
|
||||
if (1 > $this->iUserID) {
|
||||
\SnappyMail\Log::warning('PdoAddressBook', 'Export() invalid $iUserID');
|
||||
|
|
@ -364,7 +364,7 @@ class PdoAddressBook
|
|||
return true;
|
||||
}
|
||||
|
||||
public function ContactSave(Contact $oContact) : bool
|
||||
public function ContactSave(Contact $oContact): bool
|
||||
{
|
||||
if (1 > $this->iUserID) {
|
||||
\SnappyMail\Log::warning('PdoAddressBook', 'ContactSave() invalid $iUserID');
|
||||
|
|
@ -464,7 +464,7 @@ class PdoAddressBook
|
|||
return 0 < $iIdContact;
|
||||
}
|
||||
|
||||
public function DeleteContacts(array $aContactIds) : bool
|
||||
public function DeleteContacts(array $aContactIds): bool
|
||||
{
|
||||
if (1 > $this->iUserID) {
|
||||
\SnappyMail\Log::warning('PdoAddressBook', 'DeleteContacts() invalid $iUserID');
|
||||
|
|
@ -493,7 +493,7 @@ class PdoAddressBook
|
|||
return true;
|
||||
}
|
||||
|
||||
public function DeleteAllContacts(string $sEmail) : bool
|
||||
public function DeleteAllContacts(string $sEmail): bool
|
||||
{
|
||||
$iUserID = $this->getUserId($sEmail);
|
||||
|
||||
|
|
@ -505,7 +505,7 @@ class PdoAddressBook
|
|||
return true;
|
||||
}
|
||||
|
||||
protected function getContactsFromPDO(?\PDOStatement $oStmt) : array
|
||||
protected function getContactsFromPDO(?\PDOStatement $oStmt): array
|
||||
{
|
||||
if ($oStmt) {
|
||||
$aFetch = $oStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
|
@ -647,7 +647,7 @@ class PdoAddressBook
|
|||
return [];
|
||||
}
|
||||
|
||||
public function GetContacts(int $iOffset = 0, int $iLimit = 20, string $sSearch = '', int &$iResultCount = 0) : array
|
||||
public function GetContacts(int $iOffset = 0, int $iLimit = 20, string $sSearch = '', int &$iResultCount = 0): array
|
||||
{
|
||||
if (1 > $this->iUserID) {
|
||||
return [];
|
||||
|
|
@ -726,10 +726,7 @@ class PdoAddressBook
|
|||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mID
|
||||
*/
|
||||
public function GetContactByEmail(string $sEmail) : ?Contact
|
||||
public function GetContactByEmail(string $sEmail): ?Contact
|
||||
{
|
||||
$sLowerSearch = $this->specialConvertSearchValueLower($sEmail);
|
||||
|
||||
|
|
@ -766,10 +763,7 @@ class PdoAddressBook
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mID
|
||||
*/
|
||||
public function GetContactByID($mID, bool $bIsStrID = false) : ?Contact
|
||||
public function GetContactByID(mixed $mID, bool $bIsStrID = false): ?Contact
|
||||
{
|
||||
$mID = \trim($mID);
|
||||
|
||||
|
|
@ -812,7 +806,7 @@ class PdoAddressBook
|
|||
/**
|
||||
* @throws \ValueError
|
||||
*/
|
||||
public function GetSuggestions(string $sSearch, int $iLimit = 20) : array
|
||||
public function GetSuggestions(string $sSearch, int $iLimit = 20): array
|
||||
{
|
||||
if (1 > $this->iUserID) {
|
||||
return [];
|
||||
|
|
@ -977,7 +971,7 @@ class PdoAddressBook
|
|||
/**
|
||||
* @throws \ValueError
|
||||
*/
|
||||
public function IncFrec(array $aEmails, bool $bCreateAuto = true) : bool
|
||||
public function IncFrec(array $aEmails, bool $bCreateAuto = true): bool
|
||||
{
|
||||
if (1 > $this->iUserID) {
|
||||
return false;
|
||||
|
|
@ -1097,7 +1091,7 @@ class PdoAddressBook
|
|||
));
|
||||
}
|
||||
|
||||
public function Test() : string
|
||||
public function Test(): string
|
||||
{
|
||||
$sResult = '';
|
||||
try {
|
||||
|
|
@ -1120,7 +1114,7 @@ class PdoAddressBook
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
private function SyncDatabase() : bool
|
||||
private function SyncDatabase(): bool
|
||||
{
|
||||
static $mCache = null;
|
||||
if (null !== $mCache) {
|
||||
|
|
@ -1142,7 +1136,7 @@ class PdoAddressBook
|
|||
return $mCache;
|
||||
}
|
||||
|
||||
private function getContactFreq(int $iUserID, int $iIdContact) : array
|
||||
private function getContactFreq(int $iUserID, int $iIdContact): array
|
||||
{
|
||||
$aResult = array();
|
||||
|
||||
|
|
@ -1168,7 +1162,7 @@ class PdoAddressBook
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
private function specialConvertSearchValue(string $sSearch, string $sEscapeSign = '=') : string
|
||||
private function specialConvertSearchValue(string $sSearch, string $sEscapeSign = '='): string
|
||||
{
|
||||
return '%'.\str_replace(array($sEscapeSign, '_', '%'),
|
||||
array($sEscapeSign.$sEscapeSign, $sEscapeSign.'_', $sEscapeSign.'%'), $sSearch).'%';
|
||||
|
|
@ -1181,7 +1175,7 @@ class PdoAddressBook
|
|||
(string) \mb_strtolower($sSearch)).'%';
|
||||
}
|
||||
|
||||
protected function getPdoSettings() : \RainLoop\Pdo\Settings
|
||||
protected function getPdoSettings(): \RainLoop\Pdo\Settings
|
||||
{
|
||||
$sSslCa = $this->settings->sslCa;
|
||||
if ($sSslCa && !\is_file($sSslCa)) {
|
||||
|
|
@ -1195,7 +1189,7 @@ class PdoAddressBook
|
|||
/**
|
||||
* @throws \ValueError
|
||||
*/
|
||||
protected function getUserId(string $sEmail, bool $bSkipInsert = false, bool $bCache = true) : int
|
||||
protected function getUserId(string $sEmail, bool $bSkipInsert = false, bool $bCache = true): int
|
||||
{
|
||||
static $aCache = array();
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class Utils
|
|||
*/
|
||||
);
|
||||
|
||||
public static function CsvStreamToContacts(/*resource*/ $rFile, string $sDelimiter) : iterable
|
||||
public static function CsvStreamToContacts(/*resource*/ $rFile, string $sDelimiter): iterable
|
||||
{
|
||||
\setlocale(LC_CTYPE, 'en_US.UTF-8');
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ class Utils
|
|||
}
|
||||
}
|
||||
|
||||
public static function VCardToCsv($stream, VCard $oVCard, bool $bWithHeader = false)/* : int|false*/
|
||||
public static function VCardToCsv($stream, VCard $oVCard, bool $bWithHeader = false): int|false
|
||||
{
|
||||
$aData = array();
|
||||
if ($bWithHeader) {
|
||||
|
|
@ -198,7 +198,7 @@ class Utils
|
|||
));
|
||||
}
|
||||
|
||||
public static function VcfStreamToContacts(/*resource*/ $rFile) : iterable
|
||||
public static function VcfStreamToContacts(/*resource*/ $rFile): iterable
|
||||
{
|
||||
$oVCardSplitter = new \Sabre\VObject\Splitter\VCard($rFile);
|
||||
if ($oVCardSplitter) {
|
||||
|
|
@ -213,7 +213,7 @@ class Utils
|
|||
}
|
||||
}
|
||||
/*
|
||||
public static function QrCode(string $sVcfData) : string
|
||||
public static function QrCode(string $sVcfData): string
|
||||
{
|
||||
MECARD:N:djmaze;ORG:SnappyMail;TEL:+31012345678;URL:https\://snappymail.eu;EMAIL:info@snappymail.eu;ADR:address line;;
|
||||
VCARD
|
||||
|
|
|
|||
|
|
@ -4,28 +4,21 @@ namespace RainLoop\Providers\Files;
|
|||
|
||||
class FileStorage implements \RainLoop\Providers\Files\IFiles
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aResources;
|
||||
private array $aResources = array();
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sDataPath;
|
||||
private ?string $sDataPath;
|
||||
|
||||
public function __construct(string $sStoragePath)
|
||||
{
|
||||
$this->aResources = array();
|
||||
$this->sDataPath = \rtrim(\trim($sStoragePath), '\\/');
|
||||
}
|
||||
|
||||
public function GenerateLocalFullFileName(\RainLoop\Model\Account $oAccount, string $sKey) : string
|
||||
public function GenerateLocalFullFileName(\RainLoop\Model\Account $oAccount, string $sKey): string
|
||||
{
|
||||
return $this->generateFullFileName($oAccount, $sKey, true);
|
||||
}
|
||||
|
||||
public function PutFile(\RainLoop\Model\Account $oAccount, string $sKey, /*resource*/ $rSource) : bool
|
||||
public function PutFile(\RainLoop\Model\Account $oAccount, string $sKey, /*resource*/ $rSource): bool
|
||||
{
|
||||
$bResult = false;
|
||||
if ($rSource) {
|
||||
|
|
@ -38,7 +31,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
|
|||
return $bResult;
|
||||
}
|
||||
|
||||
public function MoveUploadedFile(\RainLoop\Model\Account $oAccount, string $sKey, string $sSource) : bool
|
||||
public function MoveUploadedFile(\RainLoop\Model\Account $oAccount, string $sKey, string $sSource): bool
|
||||
{
|
||||
return \move_uploaded_file($sSource,
|
||||
$this->generateFullFileName($oAccount, $sKey, true));
|
||||
|
|
@ -66,13 +59,13 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
|
|||
return $mResult;
|
||||
}
|
||||
|
||||
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey) /*: string|false*/
|
||||
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey): string|false
|
||||
{
|
||||
$sFileName = $this->generateFullFileName($oAccount, $sKey);
|
||||
return \file_exists($sFileName) ? $sFileName : false;
|
||||
}
|
||||
|
||||
public function Clear(\RainLoop\Model\Account $oAccount, string $sKey) : bool
|
||||
public function Clear(\RainLoop\Model\Account $oAccount, string $sKey): bool
|
||||
{
|
||||
$sFileName = $this->generateFullFileName($oAccount, $sKey);
|
||||
if (\file_exists($sFileName)) {
|
||||
|
|
@ -84,18 +77,18 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
|
|||
return false;
|
||||
}
|
||||
|
||||
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey) /*: int|false*/
|
||||
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey): int|false
|
||||
{
|
||||
$sFileName = $this->generateFullFileName($oAccount, $sKey);
|
||||
return \file_exists($sFileName) ? \filesize($sFileName) : false;
|
||||
}
|
||||
|
||||
public function FileExists(\RainLoop\Model\Account $oAccount, string $sKey) : bool
|
||||
public function FileExists(\RainLoop\Model\Account $oAccount, string $sKey): bool
|
||||
{
|
||||
return \file_exists($this->generateFullFileName($oAccount, $sKey));
|
||||
}
|
||||
|
||||
public function GC(int $iTimeToClearInHours = 24) : bool
|
||||
public function GC(int $iTimeToClearInHours = 24): bool
|
||||
{
|
||||
if (0 < $iTimeToClearInHours) {
|
||||
$iTimeToClear = 3600 * $iTimeToClearInHours;
|
||||
|
|
@ -113,7 +106,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
|
|||
return false;
|
||||
}
|
||||
|
||||
public function CloseAllOpenedFiles() : bool
|
||||
public function CloseAllOpenedFiles(): bool
|
||||
{
|
||||
if (\is_array($this->aResources) && \count($this->aResources))
|
||||
{
|
||||
|
|
@ -129,7 +122,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
|
|||
return true;
|
||||
}
|
||||
|
||||
private function generateFullFileName(\RainLoop\Model\Account $oAccount, string $sKey, bool $bMkDir = false) : string
|
||||
private function generateFullFileName(\RainLoop\Model\Account $oAccount, string $sKey, bool $bMkDir = false): string
|
||||
{
|
||||
if ($oAccount instanceof \RainLoop\Model\AdditionalAccount) {
|
||||
$sEmail = $oAccount->ParentEmail();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace RainLoop\Providers;
|
||||
|
||||
use RainLoop\Model\Account;
|
||||
|
||||
class Storage extends \RainLoop\Providers\AbstractProvider
|
||||
{
|
||||
/**
|
||||
|
|
@ -14,77 +16,55 @@ class Storage extends \RainLoop\Providers\AbstractProvider
|
|||
$this->oDriver = $oDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
*/
|
||||
private function verifyAccount($mAccount, int $iStorageType) : bool
|
||||
private function verifyAccount(Account|string|null $mAccount, int $iStorageType): bool
|
||||
{
|
||||
return \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY === $iStorageType
|
||||
|| $mAccount instanceof \RainLoop\Model\Account
|
||||
|| $mAccount instanceof Account
|
||||
|| \is_string($mAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
* @param mixed $sValue
|
||||
*/
|
||||
public function Put($mAccount, int $iStorageType, string $sKey, string $sValue) : bool
|
||||
public function Put(Account|string|null $mAccount, int $iStorageType, string $sKey, string $sValue): bool
|
||||
{
|
||||
return $this->verifyAccount($mAccount, $iStorageType)
|
||||
? $this->oDriver->Put($mAccount, $iStorageType, $sKey, $sValue)
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
* @param mixed $mDefault = false
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function Get($mAccount, int $iStorageType, string $sKey, $mDefault = false)
|
||||
public function Get(Account|string|null $mAccount, int $iStorageType, string $sKey, mixed $mDefault = false): mixed
|
||||
{
|
||||
return $this->verifyAccount($mAccount, $iStorageType)
|
||||
? $this->oDriver->Get($mAccount, $iStorageType, $sKey, $mDefault)
|
||||
: $mDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
*/
|
||||
public function Clear($mAccount, int $iStorageType, string $sKey) : bool
|
||||
public function Clear(Account|string|null $mAccount, int $iStorageType, string $sKey): bool
|
||||
{
|
||||
return $this->verifyAccount($mAccount, $iStorageType)
|
||||
? $this->oDriver->Clear($mAccount, $iStorageType, $sKey)
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string $mAccount
|
||||
*/
|
||||
public function DeleteStorage($mAccount) : bool
|
||||
public function DeleteStorage(Account|string $mAccount): bool
|
||||
{
|
||||
return $this->oDriver->DeleteStorage($mAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
*/
|
||||
public function GenerateFilePath($mAccount, int $iStorageType, bool $bMkDir = false) : string
|
||||
public function GenerateFilePath(Account|string|null $mAccount, int $iStorageType, bool $bMkDir = false): string
|
||||
{
|
||||
return $this->oDriver->GenerateFilePath($mAccount, $iStorageType, $bMkDir);
|
||||
}
|
||||
|
||||
public function IsActive() : bool
|
||||
public function IsActive(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function IsLocal() : bool
|
||||
public function IsLocal(): bool
|
||||
{
|
||||
return $this->oDriver->IsLocal();
|
||||
}
|
||||
|
||||
public function GC() : void
|
||||
public function GC(): void
|
||||
{
|
||||
$this->oDriver->GC();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace RainLoop\Providers\Storage;
|
||||
|
||||
use RainLoop\Providers\Storage\Enumerations\StorageType;
|
||||
use RainLoop\Model\Account;
|
||||
|
||||
class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
||||
{
|
||||
|
|
@ -18,10 +19,7 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
|||
$this->bLocal = $bLocal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
*/
|
||||
public function Put($mAccount, int $iStorageType, string $sKey, string $sValue) : bool
|
||||
public function Put(Account|string|null $mAccount, int $iStorageType, string $sKey, string $sValue): bool
|
||||
{
|
||||
$sFileName = $this->generateFileName($mAccount, $iStorageType, $sKey, true);
|
||||
try {
|
||||
|
|
@ -33,13 +31,7 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
* @param mixed $mDefault = false
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function Get($mAccount, int $iStorageType, string $sKey, $mDefault = false)
|
||||
public function Get(Account|string|null $mAccount, int $iStorageType, string $sKey, mixed $mDefault = false): mixed
|
||||
{
|
||||
$mValue = false;
|
||||
$sFileName = $this->generateFileName($mAccount, $iStorageType, $sKey);
|
||||
|
|
@ -53,19 +45,13 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
|||
return false === $mValue ? $mDefault : $mValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
*/
|
||||
public function Clear($mAccount, int $iStorageType, string $sKey) : bool
|
||||
public function Clear(Account|string|null $mAccount, int $iStorageType, string $sKey): bool
|
||||
{
|
||||
$sFileName = $this->generateFileName($mAccount, $iStorageType, $sKey);
|
||||
return $sFileName && \file_exists($sFileName) && \unlink($sFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string $mAccount
|
||||
*/
|
||||
public function DeleteStorage($mAccount) : bool
|
||||
public function DeleteStorage(Account|string|null $mAccount): bool
|
||||
{
|
||||
$sPath = $this->generateFileName($mAccount, StorageType::CONFIG, '');
|
||||
if ($sPath && \is_dir($sPath)) {
|
||||
|
|
@ -79,10 +65,7 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
|||
return $this->bLocal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
*/
|
||||
public function GenerateFilePath($mAccount, int $iStorageType, bool $bMkDir = false) : string
|
||||
public function GenerateFilePath(Account|string|null $mAccount, int $iStorageType, bool $bMkDir = false): string
|
||||
{
|
||||
$sEmail = $sSubFolder = $sFilePath = '';
|
||||
if (null === $mAccount || StorageType::NOBODY === $iStorageType) {
|
||||
|
|
@ -142,10 +125,7 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
|||
return $sFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
*/
|
||||
protected function generateFileName($mAccount, int $iStorageType, string $sKey, bool $bMkDir = false) : string
|
||||
protected function generateFileName(Account|string|null $mAccount, int $iStorageType, string $sKey, bool $bMkDir = false): string
|
||||
{
|
||||
$sFilePath = $this->GenerateFilePath($mAccount, $iStorageType, $bMkDir);
|
||||
if ($sFilePath) {
|
||||
|
|
@ -158,7 +138,7 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
|||
return $sFilePath;
|
||||
}
|
||||
|
||||
public function GC() : void
|
||||
public function GC(): void
|
||||
{
|
||||
\clearstatcache();
|
||||
foreach (\glob("{$this->sDataPath}/*", GLOB_ONLYDIR) as $sDomain) {
|
||||
|
|
|
|||
|
|
@ -2,25 +2,15 @@
|
|||
|
||||
namespace RainLoop\Providers\Storage;
|
||||
|
||||
use RainLoop\Model\Account;
|
||||
|
||||
interface IStorage
|
||||
{
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|null $mAccount
|
||||
*/
|
||||
public function Put($mAccount, int $iStorageType, string $sKey, string $sValue) : bool;
|
||||
public function Put(Account|string|null $mAccount, int $iStorageType, string $sKey, string $sValue): bool;
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|null $mAccount
|
||||
* @param mixed $mDefault = false
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function Get($mAccount, int $iStorageType, string $sKey, $mDefault = false);
|
||||
public function Get(Account|string|null $mAccount, int $iStorageType, string $sKey, mixed $mDefault = false): mixed;
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|null $mAccount
|
||||
*/
|
||||
public function Clear($mAccount, int $iStorageType, string $sKey) : bool;
|
||||
public function Clear(Account|string|null $mAccount, int $iStorageType, string $sKey): bool;
|
||||
|
||||
public function IsLocal() : bool;
|
||||
public function IsLocal(): bool;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,26 +38,18 @@ class Settings implements \JsonSerializable
|
|||
return $this->aData;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
// public function jsonSerialize(): array
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return $this->aData;;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mDefValue = null
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetConf(string $sName, $mDefValue = null)
|
||||
public function GetConf(string $sName, mixed $mDefValue = null): mixed
|
||||
{
|
||||
return isset($this->aData[$sName]) ? $this->aData[$sName] : $mDefValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mValue
|
||||
*/
|
||||
public function SetConf(string $sName, $mValue) : void
|
||||
public function SetConf(string $sName, mixed $mValue): void
|
||||
{
|
||||
$this->aData[$sName] = $mValue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class Utils
|
|||
* @param mixed $value
|
||||
* @param int $flags Bitmask
|
||||
*/
|
||||
public static function jsonEncode($value, int $flags = \JSON_INVALID_UTF8_SUBSTITUTE) : string
|
||||
public static function jsonEncode(mixed $value, int $flags = \JSON_INVALID_UTF8_SUBSTITUTE): string
|
||||
{
|
||||
try {
|
||||
/* Issue with \SnappyMail\HTTP\Stream
|
||||
|
|
@ -36,7 +36,7 @@ class Utils
|
|||
return '';
|
||||
}
|
||||
|
||||
public static function EncodeKeyValuesQ(array $aValues, string $sCustomKey = '') : string
|
||||
public static function EncodeKeyValuesQ(array $aValues, string $sCustomKey = ''): string
|
||||
{
|
||||
return \SnappyMail\Crypt::EncryptUrlSafe(
|
||||
$aValues,
|
||||
|
|
@ -44,7 +44,7 @@ class Utils
|
|||
);
|
||||
}
|
||||
|
||||
public static function DecodeKeyValuesQ(string $sEncodedValues, string $sCustomKey = '') : array
|
||||
public static function DecodeKeyValuesQ(string $sEncodedValues, string $sCustomKey = ''): array
|
||||
{
|
||||
return \SnappyMail\Crypt::DecryptUrlSafe(
|
||||
$sEncodedValues,
|
||||
|
|
@ -52,7 +52,7 @@ class Utils
|
|||
) ?: array();
|
||||
}
|
||||
|
||||
public static function GetSessionToken(bool $generate = true) : ?string
|
||||
public static function GetSessionToken(bool $generate = true): ?string
|
||||
{
|
||||
$sToken = \SnappyMail\Cookies::get(self::SESSION_TOKEN);
|
||||
if (!$sToken) {
|
||||
|
|
@ -66,7 +66,7 @@ class Utils
|
|||
return \sha1('Session'.APP_SALT.$sToken.'Token'.APP_SALT);
|
||||
}
|
||||
|
||||
public static function GetConnectionToken() : string
|
||||
public static function GetConnectionToken(): string
|
||||
{
|
||||
$oActions = \RainLoop\Api::Actions();
|
||||
$oAccount = $oActions->getAccountFromToken(false);
|
||||
|
|
@ -85,13 +85,13 @@ class Utils
|
|||
return '0-' . \sha1('Connection'.APP_SALT.$sToken.'Token'.APP_SALT);
|
||||
}
|
||||
|
||||
public static function GetCsrfToken() : string
|
||||
public static function GetCsrfToken(): string
|
||||
{
|
||||
return self::GetConnectionToken();
|
||||
// return \sha1('Csrf'.APP_SALT.self::GetConnectionToken().'Token'.APP_SALT);
|
||||
}
|
||||
|
||||
public static function UpdateConnectionToken() : void
|
||||
public static function UpdateConnectionToken(): void
|
||||
{
|
||||
$sToken = \SnappyMail\Cookies::get(self::CONNECTION_TOKEN);
|
||||
if ($sToken) {
|
||||
|
|
@ -99,7 +99,7 @@ class Utils
|
|||
}
|
||||
}
|
||||
|
||||
public static function ClearHtmlOutput(string $sHtml) : string
|
||||
public static function ClearHtmlOutput(string $sHtml): string
|
||||
{
|
||||
// return $sHtml;
|
||||
return \preg_replace('/>\\s+</', '> <', \preg_replace(
|
||||
|
|
@ -109,7 +109,7 @@ class Utils
|
|||
));
|
||||
}
|
||||
|
||||
public static function WebPath() : string
|
||||
public static function WebPath(): string
|
||||
{
|
||||
static $sAppPath;
|
||||
if (!$sAppPath) {
|
||||
|
|
@ -120,7 +120,7 @@ class Utils
|
|||
return $sAppPath;
|
||||
}
|
||||
|
||||
public static function WebVersionPath() : string
|
||||
public static function WebVersionPath(): string
|
||||
{
|
||||
return self::WebPath() . 'snappymail/v/' . APP_VERSION . '/';
|
||||
/**
|
||||
|
|
@ -130,12 +130,12 @@ class Utils
|
|||
// return self::WebPath() . \str_replace(APP_INDEX_ROOT_PATH, '', APP_VERSION_ROOT_PATH);
|
||||
}
|
||||
|
||||
public static function WebStaticPath(string $path = '') : string
|
||||
public static function WebStaticPath(string $path = ''): string
|
||||
{
|
||||
return self::WebVersionPath() . 'static/' . $path;
|
||||
}
|
||||
|
||||
public static function inOpenBasedir(string $name) : string
|
||||
public static function inOpenBasedir(string $name): string
|
||||
{
|
||||
static $open_basedir;
|
||||
if (null === $open_basedir) {
|
||||
|
|
@ -153,7 +153,7 @@ class Utils
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function saveFile(string $filename, string $data) : void
|
||||
public static function saveFile(string $filename, string $data): void
|
||||
{
|
||||
$dir = \dirname($filename);
|
||||
if (!\is_dir($dir) && !\mkdir($dir, 0700, true)) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ abstract class Crypt
|
|||
{
|
||||
protected static $cipher = '';
|
||||
|
||||
public static function listCiphers() : array
|
||||
public static function listCiphers(): array
|
||||
{
|
||||
$list = array();
|
||||
if (\function_exists('openssl_get_cipher_methods')) {
|
||||
|
|
@ -25,12 +25,12 @@ abstract class Crypt
|
|||
return $list;
|
||||
}
|
||||
|
||||
public static function cipherSupported(string $cipher) : bool
|
||||
public static function cipherSupported(string $cipher): bool
|
||||
{
|
||||
return \in_array($cipher, static::listCiphers());
|
||||
}
|
||||
|
||||
public static function setCipher(string $cipher) : bool
|
||||
public static function setCipher(string $cipher): bool
|
||||
{
|
||||
if (static::cipherSupported($cipher)) {
|
||||
static::$cipher = $cipher;
|
||||
|
|
@ -46,7 +46,7 @@ abstract class Crypt
|
|||
private static function Passphrase(
|
||||
#[\SensitiveParameter]
|
||||
?string $key
|
||||
) : string
|
||||
): string
|
||||
{
|
||||
if (!$key) {
|
||||
if (empty($_COOKIE['smctoken'])) {
|
||||
|
|
@ -61,7 +61,7 @@ abstract class Crypt
|
|||
public static function Decrypt(array $data,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) /* : mixed */
|
||||
): mixed
|
||||
{
|
||||
if (3 === \count($data) && isset($data[0], $data[1], $data[2]) && \strlen($data[0])) {
|
||||
$fn = "{$data[0]}Decrypt";
|
||||
|
|
@ -86,7 +86,7 @@ abstract class Crypt
|
|||
public static function DecryptFromJSON(string $data,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) /* : mixed */
|
||||
): mixed
|
||||
{
|
||||
$data = static::jsonDecode($data);
|
||||
if (!\is_array($data)) {
|
||||
|
|
@ -99,7 +99,7 @@ abstract class Crypt
|
|||
public static function DecryptUrlSafe(string $data,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) /* : mixed */
|
||||
): mixed
|
||||
{
|
||||
$data = \explode('.', $data);
|
||||
if (!\is_array($data)) {
|
||||
|
|
@ -114,7 +114,7 @@ abstract class Crypt
|
|||
$data,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) : array
|
||||
): array
|
||||
{
|
||||
$data = \json_encode($data);
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ abstract class Crypt
|
|||
$data,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) : string
|
||||
): string
|
||||
{
|
||||
return \json_encode(\array_map('base64_encode', static::Encrypt($data, $key)));
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ abstract class Crypt
|
|||
$data,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) : string
|
||||
): string
|
||||
{
|
||||
return \implode('.', \array_map('MailSo\\Base\\Utils::UrlSafeBase64Encode', static::Encrypt($data, $key)));
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ abstract class Crypt
|
|||
public static function SodiumDecrypt(string $data, string $nonce,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) /* : string|false */
|
||||
): string|false
|
||||
{
|
||||
if (!\is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) {
|
||||
throw new \Exception('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt not callable');
|
||||
|
|
@ -189,7 +189,7 @@ abstract class Crypt
|
|||
string $nonce,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) : string
|
||||
): string
|
||||
{
|
||||
if (!\is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) {
|
||||
throw new \Exception('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt not callable');
|
||||
|
|
@ -209,7 +209,7 @@ abstract class Crypt
|
|||
public static function OpenSSLDecrypt(string $data, string $iv,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) /* : string|false */
|
||||
): string|false
|
||||
{
|
||||
if (!$data || !$iv) {
|
||||
throw new \ValueError('$data or $iv is empty string');
|
||||
|
|
@ -236,7 +236,7 @@ abstract class Crypt
|
|||
string $iv,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) : string
|
||||
): string
|
||||
{
|
||||
if (!$data || !$iv) {
|
||||
throw new \ValueError('$data or $iv is empty string');
|
||||
|
|
@ -264,7 +264,7 @@ abstract class Crypt
|
|||
public static function XxteaDecrypt(string $data, string $salt,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) /* : mixed */
|
||||
): mixed
|
||||
{
|
||||
if (!$data || !$salt) {
|
||||
throw new \ValueError('$data or $salt is empty string');
|
||||
|
|
@ -281,7 +281,7 @@ abstract class Crypt
|
|||
string $salt,
|
||||
#[\SensitiveParameter]
|
||||
?string $key = null
|
||||
) : string
|
||||
): string
|
||||
{
|
||||
if (!$data || !$salt) {
|
||||
throw new \ValueError('$data or $salt is empty string');
|
||||
|
|
@ -296,7 +296,7 @@ abstract class Crypt
|
|||
return $result;
|
||||
}
|
||||
|
||||
private static function jsonDecode(string $data) /*: mixed*/
|
||||
private static function jsonDecode(string $data): mixed
|
||||
{
|
||||
return \json_decode($data, true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class Temporary
|
|||
return $this->fp;
|
||||
}
|
||||
|
||||
public function writeFromStream(/*resource*/ $from)/* : int|false*/
|
||||
public function writeFromStream(/*resource*/ $from): int|false
|
||||
{
|
||||
$fp = $this->fopen();
|
||||
// return \stream_copy_to_stream($from, $fp); // Fails
|
||||
|
|
@ -51,12 +51,12 @@ class Temporary
|
|||
return $bytes;
|
||||
}
|
||||
|
||||
public function putContents($data, int $flags = 0)/* : int|false*/
|
||||
public function putContents(mixed $data, int $flags = 0): int|false
|
||||
{
|
||||
return \file_put_contents($this->filename, $data /*, $flags, $context*/);
|
||||
}
|
||||
|
||||
public function getContents()/* : string|false*/
|
||||
public function getContents(): string|false
|
||||
{
|
||||
return \file_get_contents($this->filename);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ abstract class Base
|
|||
}
|
||||
}
|
||||
|
||||
public static function isSupported() : bool
|
||||
public static function isSupported(): bool
|
||||
{
|
||||
return \is_callable('shell_exec') && \is_callable('proc_open');
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ abstract class Base
|
|||
/**
|
||||
* Decrypts a given text
|
||||
*/
|
||||
public function decrypt(string $text) /*: string|false */
|
||||
public function decrypt(string $text): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ abstract class Base
|
|||
/**
|
||||
* Decrypts a given file
|
||||
*/
|
||||
public function decryptFile(string $filename) /*: string|false */
|
||||
public function decryptFile(string $filename): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ abstract class Base
|
|||
/**
|
||||
* Decrypts a given stream
|
||||
*/
|
||||
public function decryptStream($fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function decryptStream($fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ abstract class Base
|
|||
/**
|
||||
* Decrypts and verifies a given text
|
||||
*/
|
||||
public function decryptVerify(string $text, string &$plaintext) /*: array|false*/
|
||||
public function decryptVerify(string $text, string &$plaintext): array|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ abstract class Base
|
|||
/**
|
||||
* Decrypts and verifies a given file
|
||||
*/
|
||||
public function decryptVerifyFile(string $filename, string &$plaintext) /*: array|false*/
|
||||
public function decryptVerifyFile(string $filename, string &$plaintext): array|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ abstract class Base
|
|||
/**
|
||||
* Encrypts a given text
|
||||
*/
|
||||
public function encrypt(string $plaintext, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function encrypt(string $plaintext, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -152,12 +152,12 @@ abstract class Base
|
|||
/**
|
||||
* Encrypts a given text
|
||||
*/
|
||||
public function encryptFile(string $filename, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function encryptFile(string $filename, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function encryptStream(/*resource*/ $fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function encryptStream(/*resource*/ $fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -165,7 +165,7 @@ abstract class Base
|
|||
/**
|
||||
* Encrypts and signs a given text
|
||||
*/
|
||||
public function encryptSign(string $plaintext) /*: string|false*/
|
||||
public function encryptSign(string $plaintext): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ abstract class Base
|
|||
/**
|
||||
* Encrypts and signs a given text
|
||||
*/
|
||||
public function encryptSignFile(string $filename) /*: string|false*/
|
||||
public function encryptSignFile(string $filename): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ abstract class Base
|
|||
/**
|
||||
* Exports a public or private key
|
||||
*/
|
||||
public function export(string $fingerprint, ?SensitiveString $passphrase = null) /*: string|false*/
|
||||
public function export(string $fingerprint, ?SensitiveString $passphrase = null): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -189,7 +189,7 @@ abstract class Base
|
|||
/**
|
||||
* Imports a key
|
||||
*/
|
||||
public function import(string $keydata) /*: array|false*/
|
||||
public function import(string $keydata): array|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -197,7 +197,7 @@ abstract class Base
|
|||
/**
|
||||
* Imports a key
|
||||
*/
|
||||
public function importFile(string $filename) /*: array|false*/
|
||||
public function importFile(string $filename): array|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ abstract class Base
|
|||
/**
|
||||
* Returns an array with information about all keys that matches the given pattern
|
||||
*/
|
||||
public function keyInfo(string $pattern, bool $private = false) : array
|
||||
public function keyInfo(string $pattern, bool $private = false): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
@ -220,14 +220,14 @@ abstract class Base
|
|||
* GNUPG_ERROR_WARNING, GNUPG_ERROR_EXCEPTION and GNUPG_ERROR_SILENT.
|
||||
* By default GNUPG_ERROR_SILENT is used.
|
||||
*/
|
||||
public function setErrorMode(int $errormode) : void
|
||||
public function setErrorMode(int $errormode): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs a given text
|
||||
*/
|
||||
public function sign(string $plaintext, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function sign(string $plaintext, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ abstract class Base
|
|||
/**
|
||||
* Signs a given file
|
||||
*/
|
||||
public function signFile(string $filename, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function signFile(string $filename, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -243,7 +243,7 @@ abstract class Base
|
|||
/**
|
||||
* Signs a given file
|
||||
*/
|
||||
public function signStream($fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function signStream($fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -251,7 +251,7 @@ abstract class Base
|
|||
/**
|
||||
* Verifies a signed text
|
||||
*/
|
||||
public function verify(string $signed_text, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verify(string $signed_text, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -259,7 +259,7 @@ abstract class Base
|
|||
/**
|
||||
* Verifies a signed file
|
||||
*/
|
||||
public function verifyFile(string $filename, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verifyFile(string $filename, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -267,12 +267,12 @@ abstract class Base
|
|||
/**
|
||||
* Verifies a signed file
|
||||
*/
|
||||
public function verifyStream($fp, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verifyStream($fp, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getEncryptedMessageKeys(/*string|resource*/ $data) : array
|
||||
public function getEncryptedMessageKeys(/*string|resource*/ $data): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ abstract class Base
|
|||
/**
|
||||
* Add a key for decryption
|
||||
*/
|
||||
public function addDecryptKey(string $fingerprint, SensitiveString $passphrase) : bool
|
||||
public function addDecryptKey(string $fingerprint, SensitiveString $passphrase): bool
|
||||
{
|
||||
$this->addPinentry($fingerprint, $passphrase);
|
||||
return true;
|
||||
|
|
@ -293,7 +293,7 @@ abstract class Base
|
|||
/**
|
||||
* Add a key for encryption
|
||||
*/
|
||||
public function addEncryptKey(string $fingerprint) : bool
|
||||
public function addEncryptKey(string $fingerprint): bool
|
||||
{
|
||||
$this->encryptKeys[$fingerprint] = 1;
|
||||
return true;
|
||||
|
|
@ -302,13 +302,13 @@ abstract class Base
|
|||
/**
|
||||
* Add a key for signing
|
||||
*/
|
||||
public function addSignKey(string $fingerprint, SensitiveString $passphrase) : bool
|
||||
public function addSignKey(string $fingerprint, SensitiveString $passphrase): bool
|
||||
{
|
||||
$this->addPinentry($fingerprint, $passphrase);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function clear() : bool
|
||||
public function clear(): bool
|
||||
{
|
||||
$this->clearPinentries();
|
||||
$this->clearEncryptKeys();
|
||||
|
|
@ -318,7 +318,7 @@ abstract class Base
|
|||
/**
|
||||
* Removes all keys which were set for decryption before
|
||||
*/
|
||||
public function clearDecryptKeys() : bool
|
||||
public function clearDecryptKeys(): bool
|
||||
{
|
||||
return $this->clearPinentries();
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ abstract class Base
|
|||
/**
|
||||
* Removes all keys which were set for encryption before
|
||||
*/
|
||||
public function clearEncryptKeys() : bool
|
||||
public function clearEncryptKeys(): bool
|
||||
{
|
||||
$this->encryptKeys = [];
|
||||
return true;
|
||||
|
|
@ -335,7 +335,7 @@ abstract class Base
|
|||
/**
|
||||
* Removes all keys which were set for signing before
|
||||
*/
|
||||
public function clearSignKeys() : bool
|
||||
public function clearSignKeys(): bool
|
||||
{
|
||||
return $this->clearPinentries();
|
||||
}
|
||||
|
|
@ -343,7 +343,7 @@ abstract class Base
|
|||
/**
|
||||
* Returns the engine info
|
||||
*/
|
||||
public function getEngineInfo() : array
|
||||
public function getEngineInfo(): array
|
||||
{
|
||||
return [
|
||||
'protocol' => null,
|
||||
|
|
@ -357,7 +357,7 @@ abstract class Base
|
|||
* Add private key passphrase for decrypt, sign or export
|
||||
* $keyId or fingerprint
|
||||
*/
|
||||
public function addPinentry(string $keyId, SensitiveString $passphrase)
|
||||
public function addPinentry(string $keyId, SensitiveString $passphrase): self
|
||||
{
|
||||
/**
|
||||
* Test first?
|
||||
|
|
@ -378,7 +378,7 @@ abstract class Base
|
|||
/**
|
||||
* Removes all keys which were set for decryption, signing and export
|
||||
*/
|
||||
public function clearPinentries() : bool
|
||||
public function clearPinentries(): bool
|
||||
{
|
||||
$this->pinentries = [];
|
||||
return true;
|
||||
|
|
@ -388,18 +388,18 @@ abstract class Base
|
|||
* Toggle the armored output
|
||||
* When true the output is ASCII
|
||||
*/
|
||||
public function setArmor(bool $armor = true) : bool
|
||||
public function setArmor(bool $armor = true): bool
|
||||
{
|
||||
$this->armor = $armor;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function _debug(string $msg) : void
|
||||
protected function _debug(string $msg): void
|
||||
{
|
||||
\SnappyMail\Log::debug('GPG', $msg);
|
||||
}
|
||||
|
||||
protected function setInput(&$input) : void
|
||||
protected function setInput(&$input): void
|
||||
{
|
||||
if (\is_resource($input)) {
|
||||
// https://github.com/the-djmaze/snappymail/issues/331
|
||||
|
|
@ -437,7 +437,7 @@ abstract class Base
|
|||
// echo \shell_exec('gpg-agent --daemon --homedir $home 2>&1');
|
||||
}
|
||||
|
||||
protected function getPassphrase($key)
|
||||
protected function getPassphrase($key): string
|
||||
{
|
||||
$passphrase = '';
|
||||
$keyIdLength = \strlen($key);
|
||||
|
|
@ -454,7 +454,7 @@ abstract class Base
|
|||
return '';
|
||||
}
|
||||
|
||||
protected function proc_close() : int
|
||||
protected function proc_close(): int
|
||||
{
|
||||
$exitCode = 0;
|
||||
|
||||
|
|
@ -485,7 +485,7 @@ abstract class Base
|
|||
return $exitCode;
|
||||
}
|
||||
|
||||
protected static function findBinary($name) : ?string
|
||||
protected static function findBinary($name): ?string
|
||||
{
|
||||
$binary = \function_exists('shell_exec') ? \trim((string) \shell_exec('which ' . \escapeshellarg($name))) : '';
|
||||
if ($binary && \RainLoop\Utils::inOpenBasedir($binary) && \is_executable($binary)) {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
}
|
||||
}
|
||||
|
||||
public static function isSupported() : bool
|
||||
public static function isSupported(): bool
|
||||
{
|
||||
return parent::isSupported() && static::findBinary('gpg');
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Decrypts a given text
|
||||
*/
|
||||
public function decrypt(string $text) /*: string|false */
|
||||
public function decrypt(string $text): string|false
|
||||
{
|
||||
return $this->_decrypt($text);
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Decrypts a given file
|
||||
*/
|
||||
public function decryptFile(string $filename) /*: string|false */
|
||||
public function decryptFile(string $filename): string|false
|
||||
{
|
||||
$fp = \fopen($filename, 'rb');
|
||||
try {
|
||||
|
|
@ -123,7 +123,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Decrypts a given stream
|
||||
*/
|
||||
public function decryptStream($fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function decryptStream($fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
if (!$fp || !\is_resource($fp)) {
|
||||
throw new \Exception('Invalid stream resource');
|
||||
|
|
@ -135,7 +135,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Decrypts and verifies a given text
|
||||
*/
|
||||
public function decryptVerify(string $text, string &$plaintext) /*: array|false*/
|
||||
public function decryptVerify(string $text, string &$plaintext): array|false
|
||||
{
|
||||
// TODO: https://github.com/the-djmaze/snappymail/issues/89
|
||||
return false;
|
||||
|
|
@ -144,7 +144,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Decrypts and verifies a given file
|
||||
*/
|
||||
public function decryptVerifyFile(string $filename, string &$plaintext) /*: array|false*/
|
||||
public function decryptVerifyFile(string $filename, string &$plaintext): array|false
|
||||
{
|
||||
// TODO: https://github.com/the-djmaze/snappymail/issues/89
|
||||
return false;
|
||||
|
|
@ -175,7 +175,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Encrypts a given text
|
||||
*/
|
||||
public function encrypt(string $plaintext, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function encrypt(string $plaintext, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return $this->_encrypt($plaintext, $output);
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Encrypts a given text
|
||||
*/
|
||||
public function encryptFile(string $filename, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function encryptFile(string $filename, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
$fp = \fopen($filename, 'rb');
|
||||
try {
|
||||
|
|
@ -196,7 +196,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
}
|
||||
}
|
||||
|
||||
public function encryptStream(/*resource*/ $fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function encryptStream(/*resource*/ $fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
if (!$fp || !\is_resource($fp)) {
|
||||
throw new \Exception('Invalid stream resource');
|
||||
|
|
@ -208,7 +208,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Encrypts and signs a given text
|
||||
*/
|
||||
public function encryptSign(string $plaintext) /*: string|false*/
|
||||
public function encryptSign(string $plaintext): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -216,7 +216,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Encrypts and signs a given text
|
||||
*/
|
||||
public function encryptSignFile(string $filename) /*: string|false*/
|
||||
public function encryptSignFile(string $filename): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Exports a public or private key
|
||||
*/
|
||||
public function export(string $fingerprint, ?SensitiveString $passphrase = null) /*: string|false*/
|
||||
public function export(string $fingerprint, ?SensitiveString $passphrase = null): string|false
|
||||
{
|
||||
// \SnappyMail\Log::debug('GnuPG', "export({$fingerprint}, {$passphrase})");
|
||||
$private = null !== $passphrase;
|
||||
|
|
@ -246,7 +246,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Returns the errortext, if a function fails
|
||||
*/
|
||||
public function getError() /*: string|false*/
|
||||
public function getError(): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -254,7 +254,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Returns the error info
|
||||
*/
|
||||
public function getErrorInfo() : array
|
||||
public function getErrorInfo(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
|
@ -262,7 +262,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Returns the currently active protocol for all operations
|
||||
*/
|
||||
public function getProtocol() : int
|
||||
public function getProtocol(): int
|
||||
{
|
||||
return 0; // GPGME_PROTOCOL_OpenPGP
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
* Also saves revocation certificate in {homedir}/openpgp-revocs.d/
|
||||
* https://www.gnupg.org/documentation/manuals/gnupg/OpenPGP-Key-Management.html
|
||||
*/
|
||||
public function generateKey(string $uid, SensitiveString $passphrase) /*: string|false*/
|
||||
public function generateKey(string $uid, SensitiveString $passphrase): string|false
|
||||
{
|
||||
$settings = new PGPKeySettings;
|
||||
$settings->name = $uid;
|
||||
|
|
@ -338,7 +338,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
return $fingerprint;
|
||||
}
|
||||
|
||||
protected function _importKey($input) /*: array|false*/
|
||||
protected function _importKey($input): array|false
|
||||
{
|
||||
$arguments = ['--import'];
|
||||
|
||||
|
|
@ -374,7 +374,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Imports a key
|
||||
*/
|
||||
public function import(string $keydata) /*: array|false*/
|
||||
public function import(string $keydata): array|false
|
||||
{
|
||||
if (!$keydata) {
|
||||
throw new \Exception('No valid input data found.');
|
||||
|
|
@ -385,7 +385,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Imports a key
|
||||
*/
|
||||
public function importFile(string $filename) /*: array|false*/
|
||||
public function importFile(string $filename): array|false
|
||||
{
|
||||
$fp = \fopen($filename, 'rb');
|
||||
try {
|
||||
|
|
@ -398,7 +398,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
}
|
||||
}
|
||||
|
||||
public function deleteKey(string $keyId, bool $private) : bool
|
||||
public function deleteKey(string $keyId, bool $private): bool
|
||||
{
|
||||
$key = $this->keyInfo($keyId, $private);
|
||||
if (!$key) {
|
||||
|
|
@ -425,7 +425,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Returns an array with information about all keys that matches the given pattern
|
||||
*/
|
||||
public function keyInfo(string $pattern, bool $private = false) : array
|
||||
public function keyInfo(string $pattern, bool $private = false): array
|
||||
{
|
||||
// According to The file 'doc/DETAILS' in the GnuPG distribution, using
|
||||
// double '--with-fingerprint' also prints the fingerprint for subkeys.
|
||||
|
|
@ -554,7 +554,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Returns an array with information about all keys that matches the given pattern
|
||||
*/
|
||||
public function allKeysInfo(string $pattern) : array
|
||||
public function allKeysInfo(string $pattern): array
|
||||
{
|
||||
$keys = [
|
||||
'public' => [],
|
||||
|
|
@ -580,7 +580,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
* GNUPG_ERROR_WARNING, GNUPG_ERROR_EXCEPTION and GNUPG_ERROR_SILENT.
|
||||
* By default GNUPG_ERROR_SILENT is used.
|
||||
*/
|
||||
public function setErrorMode(int $errormode) : void
|
||||
public function setErrorMode(int $errormode): void
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -589,13 +589,13 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
* GNUPG_SIG_MODE_NORMAL, GNUPG_SIG_MODE_DETACH, GNUPG_SIG_MODE_CLEAR
|
||||
* By default GNUPG_SIG_MODE_CLEAR
|
||||
*/
|
||||
public function setSignMode(int $signmode) : bool
|
||||
public function setSignMode(int $signmode): bool
|
||||
{
|
||||
$this->signmode = $signmode;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function _sign(/*string|resource*/ $input, /*string|resource*/ $output = null, bool $textmode = true) /*: string|false*/
|
||||
protected function _sign(/*string|resource*/ $input, /*string|resource*/ $output = null, bool $textmode = true): string|false
|
||||
{
|
||||
if (empty($this->pinentries)) {
|
||||
throw new \Exception('No signing keys specified.');
|
||||
|
|
@ -639,7 +639,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Signs a given text
|
||||
*/
|
||||
public function sign(string $plaintext, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function sign(string $plaintext, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return $this->_sign($plaintext, $output);
|
||||
}
|
||||
|
|
@ -647,7 +647,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Signs a given file
|
||||
*/
|
||||
public function signFile(string $filename, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function signFile(string $filename, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
$fp = \fopen($filename, 'rb');
|
||||
try {
|
||||
|
|
@ -663,7 +663,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Signs a given file
|
||||
*/
|
||||
public function signStream($fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function signStream($fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
if (!$fp || !\is_resource($fp)) {
|
||||
throw new \Exception('Invalid stream resource');
|
||||
|
|
@ -672,7 +672,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
return $this->_sign($fp, $output);
|
||||
}
|
||||
|
||||
protected function _verify($input, string $signature) /*: array|false*/
|
||||
protected function _verify($input, string $signature): array|false
|
||||
{
|
||||
$arguments = ['--verify'];
|
||||
if ($signature) {
|
||||
|
|
@ -739,7 +739,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Verifies a signed text
|
||||
*/
|
||||
public function verify(string $signed_text, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verify(string $signed_text, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
return $this->_verify($signed_text, $signature);
|
||||
}
|
||||
|
|
@ -747,7 +747,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Verifies a signed file
|
||||
*/
|
||||
public function verifyFile(string $filename, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verifyFile(string $filename, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
$fp = \fopen($filename, 'rb');
|
||||
try {
|
||||
|
|
@ -763,7 +763,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Verifies a signed file
|
||||
*/
|
||||
public function verifyStream($fp, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verifyStream($fp, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
if (!$fp || !\is_resource($fp)) {
|
||||
throw new \Exception('Invalid stream resource');
|
||||
|
|
@ -772,7 +772,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
return $this->_verify($fp, $signature);
|
||||
}
|
||||
|
||||
public function getEncryptedMessageKeys(/*string|resource*/ $data) : array
|
||||
public function getEncryptedMessageKeys(/*string|resource*/ $data): array
|
||||
{
|
||||
$this->_debug('BEGIN DETECT MESSAGE KEY IDs');
|
||||
$this->setInput($data);
|
||||
|
|
@ -803,7 +803,7 @@ class PGP extends Base implements \SnappyMail\PGP\PGPInterface
|
|||
return $output ? true : ($result ? $result['output'] : false);
|
||||
}
|
||||
|
||||
private function exec(array $arguments, bool $throw = true) /*: array|false*/
|
||||
private function exec(array $arguments, bool $throw = true): array|false
|
||||
{
|
||||
if (\version_compare($this->version, '2.2.5', '<')) {
|
||||
\SnappyMail\Log::error('GPG', "{$this->version} too old");
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class SMIME extends Base
|
|||
}
|
||||
}
|
||||
|
||||
public static function isSupported() : bool
|
||||
public static function isSupported(): bool
|
||||
{
|
||||
return parent::isSupported() && static::findBinary('gpgsm');
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Decrypts a given text
|
||||
*/
|
||||
public function decrypt(string $text) /*: string|false */
|
||||
public function decrypt(string $text): string|false
|
||||
{
|
||||
return $this->_decrypt($text);
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Decrypts a given file
|
||||
*/
|
||||
public function decryptFile(string $filename) /*: string|false */
|
||||
public function decryptFile(string $filename): string|false
|
||||
{
|
||||
$fp = \fopen($filename, 'rb');
|
||||
try {
|
||||
|
|
@ -121,7 +121,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Decrypts a given stream
|
||||
*/
|
||||
public function decryptStream($fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function decryptStream($fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
if (!$fp || !\is_resource($fp)) {
|
||||
throw new \Exception('Invalid stream resource');
|
||||
|
|
@ -132,7 +132,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Decrypts and verifies a given text
|
||||
*/
|
||||
public function decryptVerify(string $text, string &$plaintext) /*: array|false*/
|
||||
public function decryptVerify(string $text, string &$plaintext): array|false
|
||||
{
|
||||
// TODO: https://github.com/the-djmaze/snappymail/issues/89
|
||||
return false;
|
||||
|
|
@ -141,7 +141,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Decrypts and verifies a given file
|
||||
*/
|
||||
public function decryptVerifyFile(string $filename, string &$plaintext) /*: array|false*/
|
||||
public function decryptVerifyFile(string $filename, string &$plaintext): array|false
|
||||
{
|
||||
// TODO: https://github.com/the-djmaze/snappymail/issues/89
|
||||
return false;
|
||||
|
|
@ -178,7 +178,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Encrypts a given text
|
||||
*/
|
||||
public function encrypt(string $plaintext, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function encrypt(string $plaintext, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return $this->_encrypt($plaintext, $output);
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Encrypts a given text
|
||||
*/
|
||||
public function encryptFile(string $filename, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function encryptFile(string $filename, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
$fp = \fopen($filename, 'rb');
|
||||
try {
|
||||
|
|
@ -199,7 +199,7 @@ class SMIME extends Base
|
|||
}
|
||||
}
|
||||
|
||||
public function encryptStream(/*resource*/ $fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function encryptStream(/*resource*/ $fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
if (!$fp || !\is_resource($fp)) {
|
||||
throw new \Exception('Invalid stream resource');
|
||||
|
|
@ -210,7 +210,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Encrypts and signs a given text
|
||||
*/
|
||||
public function encryptSign(string $plaintext) /*: string|false*/
|
||||
public function encryptSign(string $plaintext): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Encrypts and signs a given text
|
||||
*/
|
||||
public function encryptSignFile(string $filename) /*: string|false*/
|
||||
public function encryptSignFile(string $filename): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -226,7 +226,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Exports a public or private key
|
||||
*/
|
||||
public function export(string $fingerprint, ?SensitiveString $passphrase = null) /*: string|false*/
|
||||
public function export(string $fingerprint, ?SensitiveString $passphrase = null): string|false
|
||||
{
|
||||
$private = null !== $passphrase;
|
||||
$keys = $this->keyInfo($fingerprint, $private);
|
||||
|
|
@ -244,7 +244,7 @@ class SMIME extends Base
|
|||
return $result['output'];
|
||||
}
|
||||
|
||||
protected function _importKey($input) /*: array|false*/
|
||||
protected function _importKey($input): array|false
|
||||
{
|
||||
$arguments = ['--import'];
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Imports a key
|
||||
*/
|
||||
public function import(string $keydata) /*: array|false*/
|
||||
public function import(string $keydata): array|false
|
||||
{
|
||||
if (!$keydata) {
|
||||
throw new \Exception('No valid input data found.');
|
||||
|
|
@ -295,7 +295,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Imports a key
|
||||
*/
|
||||
public function importFile(string $filename) /*: array|false*/
|
||||
public function importFile(string $filename): array|false
|
||||
{
|
||||
$fp = \fopen($filename, 'rb');
|
||||
try {
|
||||
|
|
@ -335,7 +335,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Returns an array with information about all keys that matches the given pattern
|
||||
*/
|
||||
public function keyInfo(string $pattern, bool $private = false) : array
|
||||
public function keyInfo(string $pattern, bool $private = false): array
|
||||
{
|
||||
// According to The file 'doc/DETAILS' in the GnuPG distribution, using
|
||||
// double '--with-fingerprint' also prints the fingerprint for subkeys.
|
||||
|
|
@ -457,7 +457,7 @@ class SMIME extends Base
|
|||
return $keys;
|
||||
}
|
||||
|
||||
protected function _sign(/*string|resource*/ $input, /*string|resource*/ $output = null) /*: string|false*/
|
||||
protected function _sign(/*string|resource*/ $input, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
if (empty($this->pinentries)) {
|
||||
throw new \Exception('No signing keys specified.');
|
||||
|
|
@ -492,7 +492,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Signs a given text
|
||||
*/
|
||||
public function sign(string $plaintext, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function sign(string $plaintext, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
return $this->_sign($plaintext, $output);
|
||||
}
|
||||
|
|
@ -500,7 +500,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Signs a given file
|
||||
*/
|
||||
public function signFile(string $filename, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function signFile(string $filename, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
$fp = \fopen($filename, 'rb');
|
||||
try {
|
||||
|
|
@ -516,7 +516,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Signs a given file
|
||||
*/
|
||||
public function signStream($fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function signStream($fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
if (!$fp || !\is_resource($fp)) {
|
||||
throw new \Exception('Invalid stream resource');
|
||||
|
|
@ -524,7 +524,7 @@ class SMIME extends Base
|
|||
return $this->_sign($fp, $output);
|
||||
}
|
||||
|
||||
protected function _verify($input, string $signature) /*: array|false*/
|
||||
protected function _verify($input, string $signature): array|false
|
||||
{
|
||||
$arguments = ['--verify'];
|
||||
if ($signature) {
|
||||
|
|
@ -589,7 +589,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Verifies a signed text
|
||||
*/
|
||||
public function verify(string $signed_text, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verify(string $signed_text, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
return $this->_verify($signed_text, $signature);
|
||||
}
|
||||
|
|
@ -597,7 +597,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Verifies a signed file
|
||||
*/
|
||||
public function verifyFile(string $filename, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verifyFile(string $filename, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
$fp = \fopen($filename, 'rb');
|
||||
try {
|
||||
|
|
@ -613,7 +613,7 @@ class SMIME extends Base
|
|||
/**
|
||||
* Verifies a signed file
|
||||
*/
|
||||
public function verifyStream($fp, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verifyStream($fp, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
if (!$fp || !\is_resource($fp)) {
|
||||
throw new \Exception('Invalid stream resource');
|
||||
|
|
@ -621,7 +621,7 @@ class SMIME extends Base
|
|||
return $this->_verify($fp, $signature);
|
||||
}
|
||||
|
||||
public function getEncryptedMessageKeys(/*string|resource*/ $data) : array
|
||||
public function getEncryptedMessageKeys(/*string|resource*/ $data): array
|
||||
{
|
||||
$this->_debug('BEGIN DETECT MESSAGE KEY IDs');
|
||||
$this->setInput($data);
|
||||
|
|
@ -643,7 +643,7 @@ class SMIME extends Base
|
|||
return $info['ENC_TO'];
|
||||
}
|
||||
|
||||
private function exec(array $arguments, bool $throw = true) /*: array|false*/
|
||||
private function exec(array $arguments, bool $throw = true): array|false
|
||||
{
|
||||
if (\version_compare($this->version, '2.2.5', '<')) {
|
||||
\SnappyMail\Log::error('GPG', "{$this->version} too old");
|
||||
|
|
@ -1032,7 +1032,7 @@ class SMIME extends Base
|
|||
return '';
|
||||
}
|
||||
|
||||
protected function proc_close() : int
|
||||
protected function proc_close(): int
|
||||
{
|
||||
$exitCode = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Response
|
|||
return \property_exists($this, $k) ? $this->$k : null;
|
||||
}
|
||||
|
||||
public function decoded()/*: string|false*/
|
||||
public function decoded(): string|false
|
||||
{
|
||||
$body = $this->body;
|
||||
if (\function_exists('gzinflate') && isset($this->headers['content-encoding'])
|
||||
|
|
@ -61,10 +61,7 @@ class Response
|
|||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns string, array or null
|
||||
*/
|
||||
public function getHeader($names)
|
||||
public function getHeader(mixed $names): string|array|null
|
||||
{
|
||||
$names = \is_array($names) ? $names : array($names);
|
||||
foreach ($names as $n) {
|
||||
|
|
@ -76,12 +73,12 @@ class Response
|
|||
return null;
|
||||
}
|
||||
|
||||
public function getHeaders() : array
|
||||
public function getHeaders(): array
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
public function getRedirectLocation() : ?string
|
||||
public function getRedirectLocation(): ?string
|
||||
{
|
||||
if ($location = $this->getHeader('location')) {
|
||||
$uri = \is_array($location) ? $location[0] : $location;
|
||||
|
|
|
|||
|
|
@ -6,15 +6,15 @@ use MailSo\Base\Utils;
|
|||
|
||||
abstract class JWT
|
||||
{
|
||||
private static function jsonEncode($data)
|
||||
private static function jsonEncode(mixed $data): string|false
|
||||
{
|
||||
return Utils::UrlSafeBase64Encode(\json_encode($payload, JSON_THROW_ON_ERROR));
|
||||
return Utils::UrlSafeBase64Encode(\json_encode($payload, \JSON_THROW_ON_ERROR));
|
||||
}
|
||||
|
||||
private static function jsonDecode($data)
|
||||
private static function jsonDecode(string $data): mixed
|
||||
{
|
||||
$data = Utils::UrlSafeBase64Decode($data);
|
||||
return \json_decode($data, false, 8, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR);
|
||||
return \json_decode($data, false, 8, \JSON_BIGINT_AS_STRING | \JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -26,7 +26,7 @@ abstract class JWT
|
|||
* @param int $timestamp Allow the current timestamp to be specified. default time()
|
||||
* @param int $leeway When checking nbf (Not Before) Claim, iat (Issued At) Claim or expiration times, we want to provide some extra leeway time to account for clock skew.
|
||||
*/
|
||||
public static function decode(string $jwt, $key, ?int $timestamp = null, int $leeway = 0) : object
|
||||
public static function decode(string $jwt, string|array $key, ?int $timestamp = null, int $leeway = 0): object
|
||||
{
|
||||
$timestamp = $timestamp ?: \time();
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ abstract class JWT
|
|||
*
|
||||
* @return string A signed JWT
|
||||
*/
|
||||
public static function encode($payload, string $key, string $alg = 'HS256', $keyId = null, array $header = array()) : string
|
||||
public static function encode(object|array $payload, string $key, string $alg = 'HS256', mixed $keyId = null, array $header = array()): string
|
||||
{
|
||||
$header = \array_merge($header, array('typ' => 'JWT', 'alg' => $alg));
|
||||
if ($keyId) {
|
||||
|
|
@ -125,7 +125,10 @@ abstract class JWT
|
|||
*
|
||||
* @return string An encrypted message
|
||||
*/
|
||||
public static function sign(string $msg, $key, string $alg = 'HS256', string $passphrase = '') : string
|
||||
public static function sign(string $msg, $key, string $alg = 'HS256',
|
||||
#[\SensitiveParameter]
|
||||
string $passphrase = ''
|
||||
): string
|
||||
{
|
||||
switch ($alg)
|
||||
{
|
||||
|
|
@ -173,7 +176,7 @@ abstract class JWT
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function verify(string $msg, string $signature, $key, string $alg) : bool
|
||||
private static function verify(string $msg, string $signature, $key, string $alg): bool
|
||||
{
|
||||
switch ($alg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ abstract class Keyservers
|
|||
* Sends a PGP public key to a public keyserver.
|
||||
*
|
||||
* @param string $host
|
||||
* @param mixed $key The PGP public key.
|
||||
* @param string $key The PGP public key.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
$this->GnuPG->clearsignkeys();
|
||||
}
|
||||
|
||||
public static function isSupported() : bool
|
||||
public static function isSupported(): bool
|
||||
{
|
||||
// Disabled due to failures with "no passphrase" while a passphrase does exist
|
||||
return false && \class_exists('gnupg') && \version_compare(\phpversion('gnupg'), '1.5', '>=');
|
||||
|
|
@ -68,7 +68,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
}
|
||||
}
|
||||
|
||||
public function getGPG(bool $throw = true) : ?GPG
|
||||
public function getGPG(bool $throw = true): ?GPG
|
||||
{
|
||||
if (!$this->GPG) {
|
||||
if (GPG::isSupported()) {
|
||||
|
|
@ -83,7 +83,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Add a key for decryption
|
||||
*/
|
||||
public function addDecryptKey(string $fingerprint, SensitiveString $passphrase) : bool
|
||||
public function addDecryptKey(string $fingerprint, SensitiveString $passphrase): bool
|
||||
{
|
||||
// \SnappyMail\Log::debug('GnuPG', "addDecryptKey({$fingerprint}, {$passphrase})");
|
||||
return $this->GnuPG->adddecryptkey($fingerprint, \strval($passphrase)) || $this->gnupgError();
|
||||
|
|
@ -92,7 +92,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Add a key for encryption
|
||||
*/
|
||||
public function addEncryptKey(string $fingerprint) : bool
|
||||
public function addEncryptKey(string $fingerprint): bool
|
||||
{
|
||||
return $this->GnuPG->addencryptkey($fingerprint) || $this->gnupgError();
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Add a key for signing
|
||||
*/
|
||||
public function addSignKey(string $fingerprint, SensitiveString $passphrase) : bool
|
||||
public function addSignKey(string $fingerprint, SensitiveString $passphrase): bool
|
||||
{
|
||||
// \SnappyMail\Log::debug('GnuPG', "addSignKey({$fingerprint}, {$passphrase})");
|
||||
return $this->GnuPG->addsignkey($fingerprint, \strval($passphrase)) || $this->gnupgError();
|
||||
|
|
@ -109,7 +109,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Removes all keys which were set for decryption before
|
||||
*/
|
||||
public function clearDecryptKeys() : bool
|
||||
public function clearDecryptKeys(): bool
|
||||
{
|
||||
return $this->GnuPG->cleardecryptkeys();
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Removes all keys which were set for encryption before
|
||||
*/
|
||||
public function clearEncryptKeys() : bool
|
||||
public function clearEncryptKeys(): bool
|
||||
{
|
||||
return $this->GnuPG->clearencryptkeys();
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Removes all keys which were set for signing before
|
||||
*/
|
||||
public function clearSignKeys() : bool
|
||||
public function clearSignKeys(): bool
|
||||
{
|
||||
return $this->GnuPG->clearsignkeys();
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Decrypts a given text
|
||||
*/
|
||||
public function decrypt(string $text) /*: string|false */
|
||||
public function decrypt(string $text): string|false
|
||||
{
|
||||
$result = $this->GnuPG->decrypt($text);
|
||||
(false === $result) && $this->gnupgError();
|
||||
|
|
@ -143,7 +143,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Decrypts a given file
|
||||
*/
|
||||
public function decryptFile(string $filename) /*: string|false */
|
||||
public function decryptFile(string $filename): string|false
|
||||
{
|
||||
$result = $this->GnuPG->decrypt(\file_get_contents($filename));
|
||||
(false === $result) && $this->gnupgError();
|
||||
|
|
@ -153,7 +153,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Decrypts a given resource
|
||||
*/
|
||||
public function decryptStream(/*resource*/ $fp, /*string|resource*/ $output = null) /*: string|false */
|
||||
public function decryptStream(/*resource*/ $fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
if (!$fp || !\is_resource($fp)) {
|
||||
throw new \Exception('Invalid stream resource');
|
||||
|
|
@ -167,7 +167,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Decrypts and verifies a given text
|
||||
*/
|
||||
public function decryptVerify(string $text, string &$plaintext) /*: array|false*/
|
||||
public function decryptVerify(string $text, string &$plaintext): array|false
|
||||
{
|
||||
$result = $this->GnuPG->decryptverify($text, $plaintext);
|
||||
(false === $result) && $this->gnupgError();
|
||||
|
|
@ -177,14 +177,14 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Decrypts and verifies a given file
|
||||
*/
|
||||
public function decryptVerifyFile(string $filename, string &$plaintext) /*: array|false*/
|
||||
public function decryptVerifyFile(string $filename, string &$plaintext): array|false
|
||||
{
|
||||
$result = $this->GnuPG->decryptverify(\file_get_contents($filename), $plaintext);
|
||||
(false === $result) && $this->gnupgError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function deleteKey(string $keyId, bool $private) : bool
|
||||
public function deleteKey(string $keyId, bool $private): bool
|
||||
{
|
||||
return $this->getGPG()->deleteKey($keyId, $private);
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Encrypts a given text
|
||||
*/
|
||||
public function encrypt(string $plaintext) /*: string|false*/
|
||||
public function encrypt(string $plaintext): string|false
|
||||
{
|
||||
return $this->GnuPG->encrypt($plaintext) ?: $this->gnupgError();
|
||||
}
|
||||
|
|
@ -200,12 +200,12 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Encrypts a given text
|
||||
*/
|
||||
public function encryptFile(string $filename) /*: string|false*/
|
||||
public function encryptFile(string $filename): string|false
|
||||
{
|
||||
return $this->GnuPG->encrypt(\file_get_contents($filename)) ?: $this->gnupgError();
|
||||
}
|
||||
|
||||
public function encryptStream(/*resource*/ $fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function encryptStream(/*resource*/ $fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
\rewind($fp);
|
||||
return $this->GnuPG->encrypt(\stream_get_contents($fp)) ?: $this->gnupgError();
|
||||
|
|
@ -214,7 +214,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Exports a key
|
||||
*/
|
||||
public function export(string $fingerprint, ?SensitiveString $passphrase = null) /*: string|false*/
|
||||
public function export(string $fingerprint, ?SensitiveString $passphrase = null): string|false
|
||||
{
|
||||
if (null !== $passphrase) {
|
||||
return $this->getGPG()->export($fingerprint, $passphrase);
|
||||
|
|
@ -225,7 +225,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Returns the engine info
|
||||
*/
|
||||
public function getEngineInfo() : array
|
||||
public function getEngineInfo(): array
|
||||
{
|
||||
return $this->GnuPG->getengineinfo();
|
||||
}
|
||||
|
|
@ -233,7 +233,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Returns the errortext, if a function fails
|
||||
*/
|
||||
public function getError() /*: string|false*/
|
||||
public function getError(): string|false
|
||||
{
|
||||
return $this->GnuPG->geterror();
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Returns the error info
|
||||
*/
|
||||
public function getErrorInfo() : array
|
||||
public function getErrorInfo(): array
|
||||
{
|
||||
return $this->GnuPG->geterrorinfo();
|
||||
}
|
||||
|
|
@ -249,7 +249,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Returns the currently active protocol for all operations
|
||||
*/
|
||||
public function getProtocol() : int
|
||||
public function getProtocol(): int
|
||||
{
|
||||
return $this->GnuPG->getprotocol();
|
||||
}
|
||||
|
|
@ -257,7 +257,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Generates a key
|
||||
*/
|
||||
public function generateKey(string $uid, SensitiveString $passphrase) /*: string|false*/
|
||||
public function generateKey(string $uid, SensitiveString $passphrase): string|false
|
||||
{
|
||||
$GPG = $this->getGPG(false);
|
||||
return $GPG ? $GPG->generateKey($uid, $passphrase) : false;
|
||||
|
|
@ -266,7 +266,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Imports a key
|
||||
*/
|
||||
public function import(string $keydata) /*: array|false*/
|
||||
public function import(string $keydata): array|false
|
||||
{
|
||||
return $this->GnuPG->import($keydata);
|
||||
}
|
||||
|
|
@ -274,12 +274,12 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Imports a key
|
||||
*/
|
||||
public function importFile(string $filename) /*: array|false*/
|
||||
public function importFile(string $filename): array|false
|
||||
{
|
||||
return $this->GnuPG->import(\file_get_contents($filename)) ?: $this->gnupgError();
|
||||
}
|
||||
|
||||
public function keyInfo(string $pattern, bool $private = false) : array
|
||||
public function keyInfo(string $pattern, bool $private = false): array
|
||||
{
|
||||
return $this->GnuPG->keyinfo($pattern, $private ? 1 : 0);
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Returns an array with information about all keys that matches the given pattern
|
||||
*/
|
||||
public function allKeysInfo(string $pattern) : array
|
||||
public function allKeysInfo(string $pattern): array
|
||||
{
|
||||
$keys = [
|
||||
'public' => [],
|
||||
|
|
@ -312,7 +312,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
* Toggle armored output
|
||||
* When true the output is ASCII
|
||||
*/
|
||||
public function setArmor(bool $armor = true) : bool
|
||||
public function setArmor(bool $armor = true): bool
|
||||
{
|
||||
return $this->GnuPG->setarmor($armor ? 1 : 0);
|
||||
}
|
||||
|
|
@ -322,7 +322,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
* GNUPG_ERROR_WARNING, GNUPG_ERROR_EXCEPTION and GNUPG_ERROR_SILENT.
|
||||
* By default GNUPG_ERROR_SILENT is used.
|
||||
*/
|
||||
public function setErrorMode(int $errormode) : void
|
||||
public function setErrorMode(int $errormode): void
|
||||
{
|
||||
$this->GnuPG->seterrormode($errormode);
|
||||
}
|
||||
|
|
@ -332,7 +332,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
* GNUPG_SIG_MODE_NORMAL, GNUPG_SIG_MODE_DETACH and GNUPG_SIG_MODE_CLEAR.
|
||||
* By default GNUPG_SIG_MODE_CLEAR
|
||||
*/
|
||||
public function setSignMode(int $signmode) : bool
|
||||
public function setSignMode(int $signmode): bool
|
||||
{
|
||||
return $this->GnuPG->setsignmode($signmode);
|
||||
}
|
||||
|
|
@ -340,7 +340,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Signs a given text
|
||||
*/
|
||||
public function sign(string $plaintext) /*: string|false*/
|
||||
public function sign(string $plaintext): string|false
|
||||
{
|
||||
return $this->GnuPG->sign($plaintext) ?: $this->gnupgError();
|
||||
}
|
||||
|
|
@ -348,7 +348,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Signs a given file
|
||||
*/
|
||||
public function signFile(string $filename) /*: string|false*/
|
||||
public function signFile(string $filename): string|false
|
||||
{
|
||||
return $this->GnuPG->sign(\file_get_contents($filename)) ?: $this->gnupgError();
|
||||
}
|
||||
|
|
@ -356,7 +356,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Signs a given file
|
||||
*/
|
||||
public function signStream($fp, /*string|resource*/ $output = null) /*: string|false*/
|
||||
public function signStream($fp, /*string|resource*/ $output = null): string|false
|
||||
{
|
||||
\rewind($fp);
|
||||
return $this->GnuPG->sign(\stream_get_contents($fp)) ?: $this->gnupgError();
|
||||
|
|
@ -365,7 +365,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Verifies a signed text
|
||||
*/
|
||||
public function verify(string $signed_text, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verify(string $signed_text, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
$result = $this->GnuPG->verify($signed_text, $signature ?: false, $plaintext) ?: $this->gnupgError();
|
||||
if (!$result) {
|
||||
|
|
@ -378,7 +378,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Verifies a signed file
|
||||
*/
|
||||
public function verifyFile(string $filename, string $signature, ?string &$plaintext = null) /*: array|false*/
|
||||
public function verifyFile(string $filename, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
return $this->GnuPG->verify(\file_get_contents($filename), $signature, $plaintext) ?: $this->gnupgError();
|
||||
}
|
||||
|
|
@ -386,7 +386,7 @@ class PECL implements \SnappyMail\PGP\PGPInterface
|
|||
/**
|
||||
* Verifies a given resource
|
||||
*/
|
||||
public function verifyStream(/*resource*/ $fp, string $signature, ?string &$plaintext = null) /*: array|false */
|
||||
public function verifyStream(/*resource*/ $fp, string $signature, ?string &$plaintext = null): array|false
|
||||
{
|
||||
if (!$fp || !\is_resource($fp)) {
|
||||
throw new \Exception('Invalid stream resource');
|
||||
|
|
|
|||
|
|
@ -6,40 +6,40 @@ use SnappyMail\SensitiveString;
|
|||
|
||||
interface PGPInterface
|
||||
{
|
||||
public static function isSupported() : bool;
|
||||
public static function isSupported(): bool;
|
||||
// public function addPinentry(string $keyId, SensitiveString $passphrase);
|
||||
// public function clearPinentries() : bool
|
||||
public function addDecryptKey(string $fingerprint, SensitiveString $passphrase) : bool;
|
||||
public function addEncryptKey(string $fingerprint) : bool;
|
||||
public function addSignKey(string $fingerprint, SensitiveString $passphrase) : bool;
|
||||
public function clearDecryptKeys() : bool;
|
||||
public function clearEncryptKeys() : bool;
|
||||
public function clearSignKeys() : bool;
|
||||
public function decrypt(string $text) /*: string|false */;
|
||||
public function decryptFile(string $filename) /*: string|false */;
|
||||
public function decryptStream(/*resource*/ $fp, /*string|resource*/ $output = null) /*: string|false */;
|
||||
public function decryptVerify(string $text, string &$plaintext) /*: array|false*/;
|
||||
public function decryptVerifyFile(string $filename, string &$plaintext) /*: array|false*/;
|
||||
public function deleteKey(string $keyId, bool $private) : bool;
|
||||
public function encrypt(string $plaintext) /*: string|false*/;
|
||||
public function encryptFile(string $filename) /*: string|false*/;
|
||||
public function encryptStream(/*resource*/ $fp, /*string|resource*/ $output = null) /*: string|false*/;
|
||||
public function export(string $fingerprint, ?SensitiveString $passphrase = null) /*: string|false*/;
|
||||
public function getEngineInfo() : array;
|
||||
public function getError() /*: string|false*/;
|
||||
public function getErrorInfo() : array;
|
||||
public function getProtocol() : int;
|
||||
public function generateKey(string $uid, SensitiveString $passphrase) /*: string|false*/;
|
||||
public function import(string $keydata) /*: array|false*/;
|
||||
public function importFile(string $filename) /*: array|false*/;
|
||||
public function allKeysInfo(string $pattern) : array;
|
||||
public function setArmor(bool $armor = true) : bool;
|
||||
public function setErrorMode(int $errormode) : void;
|
||||
public function setSignMode(int $signmode) : bool;
|
||||
public function sign(string $plaintext) /*: string|false*/;
|
||||
public function signFile(string $filename) /*: string|false*/;
|
||||
public function signStream($fp, /*string|resource*/ $output = null) /*: string|false*/;
|
||||
public function verify(string $signed_text, string $signature, ?string &$plaintext = null) /*: array|false*/;
|
||||
public function verifyFile(string $filename, string $signature, ?string &$plaintext = null) /*: array|false*/;
|
||||
public function verifyStream(/*resource*/ $fp, string $signature, ?string &$plaintext = null) /*: array|false */;
|
||||
// public function clearPinentries(): bool
|
||||
public function addDecryptKey(string $fingerprint, SensitiveString $passphrase): bool;
|
||||
public function addEncryptKey(string $fingerprint): bool;
|
||||
public function addSignKey(string $fingerprint, SensitiveString $passphrase): bool;
|
||||
public function clearDecryptKeys(): bool;
|
||||
public function clearEncryptKeys(): bool;
|
||||
public function clearSignKeys(): bool;
|
||||
public function decrypt(string $text): string|false;
|
||||
public function decryptFile(string $filename): string|false;
|
||||
public function decryptStream(/*resource*/ $fp, /*string|resource*/ $output = null): string|false;
|
||||
public function decryptVerify(string $text, string &$plaintext): array|false;
|
||||
public function decryptVerifyFile(string $filename, string &$plaintext): array|false;
|
||||
public function deleteKey(string $keyId, bool $private): bool;
|
||||
public function encrypt(string $plaintext): string|false;
|
||||
public function encryptFile(string $filename): string|false;
|
||||
public function encryptStream(/*resource*/ $fp, /*string|resource*/ $output = null): string|false;
|
||||
public function export(string $fingerprint, ?SensitiveString $passphrase = null): string|false;
|
||||
public function getEngineInfo(): array;
|
||||
public function getError(): string|false;
|
||||
public function getErrorInfo(): array;
|
||||
public function getProtocol(): int;
|
||||
public function generateKey(string $uid, SensitiveString $passphrase): string|false;
|
||||
public function import(string $keydata): array|false;
|
||||
public function importFile(string $filename): array|false;
|
||||
public function allKeysInfo(string $pattern): array;
|
||||
public function setArmor(bool $armor = true): bool;
|
||||
public function setErrorMode(int $errormode): void;
|
||||
public function setSignMode(int $signmode): bool;
|
||||
public function sign(string $plaintext): string|false;
|
||||
public function signFile(string $filename): string|false;
|
||||
public function signStream($fp, /*string|resource*/ $output = null): string|false;
|
||||
public function verify(string $signed_text, string $signature, ?string &$plaintext = null): array|false;
|
||||
public function verifyFile(string $filename, string $signature, ?string &$plaintext = null): array|false;
|
||||
public function verifyStream(/*resource*/ $fp, string $signature, ?string &$plaintext = null): array|false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ class SensitiveString /* extends SensitiveParameterValue | SensitiveParameter */
|
|||
return $this->getValue();
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
throw new \Exception("JSON serialization of 'SnappyMail\\SensitiveString' is not allowed");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Certificate
|
|||
/**
|
||||
* Verifies if a certificate can be used for a particular purpose
|
||||
*/
|
||||
public function checkPurpose(int $purpose, array $cainfo = array(), ?string $untrustedfile = null)/*: bool|int*/
|
||||
public function checkPurpose(int $purpose, array $cainfo = array(), ?string $untrustedfile = null): bool|int
|
||||
{
|
||||
if ($this->x509) {
|
||||
return \openssl_x509_checkpurpose($this->x509, $purpose, $cainfo, $untrustedfile);
|
||||
|
|
@ -65,14 +65,14 @@ class Certificate
|
|||
return false;
|
||||
}
|
||||
|
||||
public function canSign() : bool
|
||||
public function canSign(): bool
|
||||
{
|
||||
return $this->x509
|
||||
? true === \openssl_x509_checkpurpose($this->x509, \X509_PURPOSE_SMIME_SIGN)
|
||||
: false;
|
||||
}
|
||||
|
||||
public function canEncrypt() : bool
|
||||
public function canEncrypt(): bool
|
||||
{
|
||||
return $this->x509
|
||||
? true === \openssl_x509_checkpurpose($this->x509, \X509_PURPOSE_SMIME_ENCRYPT)
|
||||
|
|
@ -82,7 +82,7 @@ class Certificate
|
|||
/**
|
||||
* Returns the certificate in a PEM encoded format string
|
||||
*/
|
||||
public function export(bool $notext = true) : ?string
|
||||
public function export(bool $notext = true): ?string
|
||||
{
|
||||
if ($this->x509) {
|
||||
$output = '';
|
||||
|
|
@ -96,7 +96,7 @@ class Certificate
|
|||
/**
|
||||
* Returns the fingerprint or digest of the certificate
|
||||
*/
|
||||
public function fingerprint(string $hash_algorithm = 'sha1', bool $raw_output = false)/*: string|bool*/
|
||||
public function fingerprint(string $hash_algorithm = 'sha1', bool $raw_output = false): string|bool
|
||||
{
|
||||
return $this->x509 ? \openssl_x509_fingerprint($this->x509, $hash_algorithm, $raw_output) : false;
|
||||
}
|
||||
|
|
@ -104,17 +104,17 @@ class Certificate
|
|||
/**
|
||||
* Returns the certificate information as an array
|
||||
*/
|
||||
public function info(bool $shortnames = true) /*: array|bool*/
|
||||
public function info(bool $shortnames = true): array|bool
|
||||
{
|
||||
return $this->x509 ? \openssl_x509_parse($this->x509, $shortnames) : false;
|
||||
}
|
||||
|
||||
public static function getCipherMethods(bool $aliases = false) : array
|
||||
public static function getCipherMethods(bool $aliases = false): array
|
||||
{
|
||||
return \openssl_get_cipher_methods($aliases);
|
||||
}
|
||||
|
||||
public function createSelfSigned(\SnappyMail\SensitiveString $passphrase, ?string $privateKey = null) : array
|
||||
public function createSelfSigned(\SnappyMail\SensitiveString $passphrase, ?string $privateKey = null): array
|
||||
{
|
||||
$options = array(
|
||||
'config' => __DIR__ . '/openssl.cnf',
|
||||
|
|
@ -177,7 +177,7 @@ class Certificate
|
|||
#[\SensitiveParameter]
|
||||
string $pass = '',
|
||||
array $args = array()
|
||||
) : string
|
||||
): string
|
||||
{
|
||||
$out = '';
|
||||
\openssl_pkcs12_export($this->x509, $out, $this->pkey, $pass, $args);
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ class OpenSSL
|
|||
$this->homedir = $homedir;
|
||||
}
|
||||
|
||||
public function getCertificate(string $filename)/* : string*/
|
||||
public function getCertificate(string $filename): string|false
|
||||
{
|
||||
return \file_get_contents("{$this->homedir}/{$filename}");
|
||||
}
|
||||
|
||||
public function storeCertificate(string $certificate) : bool
|
||||
public function storeCertificate(string $certificate): bool
|
||||
{
|
||||
$data = \openssl_x509_parse(\openssl_x509_read($certificate));
|
||||
if (!$data) {
|
||||
|
|
@ -51,7 +51,7 @@ class OpenSSL
|
|||
return true;
|
||||
}
|
||||
|
||||
public function certificates(bool $force = false) : array
|
||||
public function certificates(bool $force = false): array
|
||||
{
|
||||
$cacheFile = "{$this->homedir}/certificates.json";
|
||||
$result = (!$force && \file_exists($cacheFile))
|
||||
|
|
@ -111,17 +111,17 @@ class OpenSSL
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function privateKeys() : array
|
||||
public function privateKeys(): array
|
||||
{
|
||||
// \glob("{$this->homedir}/*.key");
|
||||
}
|
||||
|
||||
public static function isSupported() : bool
|
||||
public static function isSupported(): bool
|
||||
{
|
||||
return \defined('PKCS7_DETACHED');
|
||||
}
|
||||
|
||||
public function setCertificate(/*OpenSSLCertificate|string*/$certificate)
|
||||
public function setCertificate(OpenSSLCertificate|string $certificate): void
|
||||
{
|
||||
$this->certificate = \openssl_x509_read($certificate);
|
||||
if (!$this->certificate) {
|
||||
|
|
@ -132,7 +132,7 @@ class OpenSSL
|
|||
}
|
||||
}
|
||||
|
||||
public function setCertificateChain(/*string*/$certificateChain)
|
||||
public function setCertificateChain(?string $certificateChain): void
|
||||
{
|
||||
if ($certificateChain === "") {
|
||||
$this->certificateChain = null;
|
||||
|
|
@ -141,9 +141,9 @@ class OpenSSL
|
|||
}
|
||||
}
|
||||
|
||||
public function setPrivateKey(/*OpenSSLAsymmetricKey|string*/$privateKey,
|
||||
public function setPrivateKey(OpenSSLAsymmetricKey|string $privateKey,
|
||||
?\SnappyMail\SensitiveString $passphrase = null
|
||||
) : void
|
||||
): void
|
||||
{
|
||||
$this->privateKey = \openssl_pkey_get_private($privateKey, $passphrase);
|
||||
if (!$this->privateKey) {
|
||||
|
|
@ -171,7 +171,7 @@ class OpenSSL
|
|||
}
|
||||
|
||||
/*
|
||||
public function asn1parse(/*string|Temporary* / $input) : ?string
|
||||
public function asn1parse(string|Temporary $input): ?string
|
||||
{
|
||||
if (\is_string($input)) {
|
||||
$tmp = new Temporary('smimein-');
|
||||
|
|
@ -183,7 +183,7 @@ class OpenSSL
|
|||
\shell_exec('openssl asn1parse -in $input->filename()');
|
||||
}
|
||||
*/
|
||||
public function decrypt(/*string|Temporary*/ $input) : ?string
|
||||
public function decrypt(string|Temporary $input): ?string
|
||||
{
|
||||
if (\is_string($input)) {
|
||||
$tmp = new Temporary('smimein-');
|
||||
|
|
@ -204,7 +204,7 @@ class OpenSSL
|
|||
return $output->getContents();
|
||||
}
|
||||
|
||||
public function encrypt(/*string|Temporary*/$input, array $certificates) : ?string
|
||||
public function encrypt(string|Temporary $input, array $certificates): ?string
|
||||
{
|
||||
if (\is_string($input)) {
|
||||
$tmp = new Temporary('smimein-');
|
||||
|
|
@ -245,7 +245,7 @@ class OpenSSL
|
|||
return $data;
|
||||
}
|
||||
|
||||
public function sign(/*string|Temporary*/$input, bool $detached = true)
|
||||
public function sign(string|Temporary $input, bool $detached = true): ?string
|
||||
{
|
||||
if (\is_string($input)) {
|
||||
$tmp = new Temporary('smimein-');
|
||||
|
|
@ -314,7 +314,7 @@ class OpenSSL
|
|||
/**
|
||||
* $opaque = true, when the message is not detached
|
||||
*/
|
||||
public function verify(/*string|Temporary*/$input, ?string $signers_certificates_filename = null, bool $opaque = false)
|
||||
public function verify(string|Temporary $input, ?string $signers_certificates_filename = null, bool $opaque = false): ?array
|
||||
{
|
||||
if (\is_string($input)) {
|
||||
$tmp = new Temporary('smimein-');
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class TAR
|
|||
$this->close();
|
||||
}
|
||||
|
||||
public function pushHttpHeaders(string $name) : void
|
||||
public function pushHttpHeaders(string $name): void
|
||||
{
|
||||
if ($i = \ob_get_level()) {
|
||||
# Clear buffers:
|
||||
|
|
@ -61,7 +61,7 @@ class TAR
|
|||
\MailSo\Base\Http::setContentDisposition('attachment', ['filename' => $name]);
|
||||
}
|
||||
|
||||
public function close() : void
|
||||
public function close(): void
|
||||
{
|
||||
if ($this->out) {
|
||||
if ($this->started) {
|
||||
|
|
@ -81,7 +81,7 @@ class TAR
|
|||
}
|
||||
}
|
||||
|
||||
public function addFile($fileinfo, ?string $name = null) : bool
|
||||
public function addFile($fileinfo, ?string $name = null): bool
|
||||
{
|
||||
if (!($fileinfo instanceof \SplFileInfo)) {
|
||||
$fileinfo = new \SplFileInfo($fileinfo);
|
||||
|
|
@ -113,7 +113,7 @@ class TAR
|
|||
return true;
|
||||
}
|
||||
|
||||
public function addFromStream($resource, string $name, int $time = 0) : bool
|
||||
public function addFromStream($resource, string $name, int $time = 0): bool
|
||||
{
|
||||
if (\is_resource($resource)) {
|
||||
$temp = new TarTempResource();
|
||||
|
|
@ -155,7 +155,7 @@ class TAR
|
|||
return true;
|
||||
}
|
||||
|
||||
public function addFromString(string $name, string $data, int $time = 0) : bool
|
||||
public function addFromString(string $name, string $data, int $time = 0): bool
|
||||
{
|
||||
$this->writeEntryHeader(
|
||||
\strtr($name, '\\', '/'),
|
||||
|
|
@ -174,7 +174,7 @@ class TAR
|
|||
return true;
|
||||
}
|
||||
|
||||
public function addDir(string $dirname, ?\SplFileInfo $fileinfo = null) : void
|
||||
public function addDir(string $dirname, ?\SplFileInfo $fileinfo = null): void
|
||||
{
|
||||
$this->writeEntryHeader(
|
||||
\rtrim(\strtr($dirname, '\\', '/'), '/') . '/',
|
||||
|
|
@ -187,7 +187,7 @@ class TAR
|
|||
);
|
||||
}
|
||||
|
||||
public function addRecursive(string $dir, string $target_dir = '', $ignore = '#/(\\.hg(/|$)|\\.hgignore)#') : void
|
||||
public function addRecursive(string $dir, string $target_dir = '', $ignore = '#/(\\.hg(/|$)|\\.hgignore)#'): void
|
||||
{
|
||||
if (!$this->out) {
|
||||
throw new \Exception('Stream closed');
|
||||
|
|
@ -217,7 +217,7 @@ class TAR
|
|||
}
|
||||
}
|
||||
|
||||
protected function start()
|
||||
protected function start(): void
|
||||
{
|
||||
if ($this->started) {
|
||||
return;
|
||||
|
|
@ -239,7 +239,7 @@ class TAR
|
|||
}
|
||||
}
|
||||
|
||||
protected function write($string)/* : int|bool*/
|
||||
protected function write(string $string): int|bool
|
||||
{
|
||||
if (!$this->out) {
|
||||
throw new \Exception('Stream closed');
|
||||
|
|
@ -265,7 +265,7 @@ class TAR
|
|||
return $written;
|
||||
}
|
||||
|
||||
protected function writeEntryHeader($name, $type, $size, $uid = 0, $gid = 0, $perm = 0, $mtime = 0, $link = '', $prefix = '')
|
||||
protected function writeEntryHeader($name, $type, $size, $uid = 0, $gid = 0, $perm = 0, $mtime = 0, $link = '', $prefix = ''): void
|
||||
{
|
||||
// handle long filename length
|
||||
$paxdata = $paxname = '';
|
||||
|
|
@ -331,7 +331,7 @@ class TAR
|
|||
}
|
||||
|
||||
// Writes Pre-POSIX.1-1988 (i.e. v7) and POSIX UStar headers
|
||||
protected function writeUStarEntryHeader($name, $type, $size, $uid = 0, $gid = 0, $perm = 0, $mtime = 0, $link = '', $prefix = '')
|
||||
protected function writeUStarEntryHeader($name, $type, $size, $uid = 0, $gid = 0, $perm = 0, $mtime = 0, $link = '', $prefix = ''): void
|
||||
{
|
||||
$data = \pack('a100a8a8a8a12A12',
|
||||
$name,
|
||||
|
|
@ -362,10 +362,7 @@ class TAR
|
|||
|
||||
class TarTempResource extends \SplTempFileObject
|
||||
{
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getOwner()/*: int|false*/ { return 0; }
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getGroup()/*: int|false*/ { return 0; }
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getPerms()/*: int|false*/ { return 420; }
|
||||
public function getOwner(): int|false { return 0; }
|
||||
public function getGroup(): int|false { return 0; }
|
||||
public function getPerms(): int|false { return 420; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue