More params and returns to PHP 7.3+

This commit is contained in:
djmaze 2020-03-16 13:08:53 +01:00
parent 3d246ae842
commit 26c38b3ec9
95 changed files with 1028 additions and 4865 deletions

View file

@ -204,10 +204,7 @@ class Actions
return '';
}
/**
* @return \RainLoop\Config\Application
*/
public function Config()
public function Config() : \RainLoop\Config\Application
{
if (null === $this->oConfig)
{
@ -532,37 +529,34 @@ class Actions
public function SetAuthLogoutToken() : void
{
@\header('X-RainLoop-Action: Logout');
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY, \md5(APP_START_TIME), 0);
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY, \md5($_SERVER['REQUEST_TIME_FLOAT']), 0);
}
public function SetAuthToken(?\RainLoop\Model\Account $oAccount) : void
public function SetAuthToken(\RainLoop\Model\Account $oAccount) : void
{
if ($oAccount)
$sSpecAuthToken = '_'.$oAccount->GetAuthTokenQ();
$this->SetSpecAuthToken($sSpecAuthToken);
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, $sSpecAuthToken, 0);
if ($oAccount->SignMe() && 0 < \strlen($oAccount->SignMeToken()))
{
$sSpecAuthToken = '_'.$oAccount->GetAuthTokenQ();
\RainLoop\Utils::SetCookie(self::AUTH_SIGN_ME_TOKEN_KEY,
\RainLoop\Utils::EncodeKeyValuesQ(array(
'e' => $oAccount->Email(),
't' => $oAccount->SignMeToken()
)),
\time() + 60 * 60 * 24 * 30);
$this->SetSpecAuthToken($sSpecAuthToken);
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, $sSpecAuthToken, 0);
if ($oAccount->SignMe() && 0 < \strlen($oAccount->SignMeToken()))
{
\RainLoop\Utils::SetCookie(self::AUTH_SIGN_ME_TOKEN_KEY,
\RainLoop\Utils::EncodeKeyValuesQ(array(
'e' => $oAccount->Email(),
't' => $oAccount->SignMeToken()
)),
\time() + 60 * 60 * 24 * 30);
$this->StorageProvider()->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'sign_me',
\RainLoop\Utils::EncodeKeyValuesQ(array(
'Time' => \time(),
'AuthToken' => $oAccount->GetAuthTokenQ(),
'SignMetToken' => $oAccount->SignMeToken()
))
);
}
$this->StorageProvider()->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'sign_me',
\RainLoop\Utils::EncodeKeyValuesQ(array(
'Time' => \time(),
'AuthToken' => $oAccount->GetAuthTokenQ(),
'SignMetToken' => $oAccount->SignMeToken()
))
);
}
}
@ -635,18 +629,14 @@ class Actions
}
/**
* @return \RainLoop\Model\Account|bool
* @throws \RainLoop\Exceptions\ClientException
*/
public function GetAccount(bool $bThrowExceptionOnFalse = false)
public function GetAccount(bool $bThrowExceptionOnFalse = false) : \RainLoop\Model\Account
{
return $this->getAccountFromToken($bThrowExceptionOnFalse);
}
/**
* @return \MailSo\Base\Http
*/
public function Http()
public function Http() : \MailSo\Base\Http
{
if (null === $this->oHttp)
{
@ -656,10 +646,7 @@ class Actions
return $this->oHttp;
}
/**
* @return \MailSo\Mail\MailClient
*/
public function MailClient()
public function MailClient() : \MailSo\Mail\MailClient
{
if (null === $this->oMailClient)
{
@ -670,10 +657,7 @@ class Actions
return $this->oMailClient;
}
/**
* @return \RainLoop\Providers\Filters
*/
public function FiltersProvider()
public function FiltersProvider() : \RainLoop\Providers\Filters
{
if (null === $this->oFiltersProvider)
{
@ -684,10 +668,7 @@ class Actions
return $this->oFiltersProvider;
}
/**
* @return \RainLoop\Providers\TwoFactorAuth
*/
public function TwoFactorAuthProvider()
public function TwoFactorAuthProvider() : \RainLoop\Providers\TwoFactorAuth
{
if (null === $this->oTwoFactorAuthProvider)
{
@ -699,10 +680,7 @@ class Actions
return $this->oTwoFactorAuthProvider;
}
/**
* @return \RainLoop\Providers\Storage
*/
public function StorageProvider(bool $bLocal = false)
public function StorageProvider(bool $bLocal = false) : \RainLoop\Providers\Storage
{
if ($bLocal)
{
@ -728,10 +706,7 @@ class Actions
return null;
}
/**
* @return \RainLoop\Providers\Settings
*/
public function SettingsProvider(bool $bLocal = false)
public function SettingsProvider(bool $bLocal = false) : \RainLoop\Providers\Settings
{
if ($bLocal)
{
@ -757,10 +732,7 @@ class Actions
return null;
}
/**
* @return \RainLoop\Providers\Files
*/
public function FilesProvider()
public function FilesProvider() : \RainLoop\Providers\Files
{
if (null === $this->oFilesProvider)
{
@ -771,10 +743,7 @@ class Actions
return $this->oFilesProvider;
}
/**
* @return \RainLoop\Providers\Domain
*/
public function DomainProvider()
public function DomainProvider() : \RainLoop\Providers\Domain
{
if (null === $this->oDomainProvider)
{
@ -785,10 +754,7 @@ class Actions
return $this->oDomainProvider;
}
/**
* @return \RainLoop\Providers\Suggestions
*/
public function SuggestionsProvider()
public function SuggestionsProvider() : \RainLoop\Providers\Suggestions
{
if (null === $this->oSuggestionsProvider)
{
@ -799,10 +765,7 @@ class Actions
return $this->oSuggestionsProvider;
}
/**
* @return \RainLoop\Providers\AddressBook
*/
public function AddressBookProvider(?\RainLoop\Model\Account $oAccount = null, bool $bForceEnable = false)
public function AddressBookProvider(?\RainLoop\Model\Account $oAccount = null, bool $bForceEnable = false) : \RainLoop\Providers\AddressBook
{
if (null === $this->oAddressBookProvider)
{
@ -822,10 +785,7 @@ class Actions
return $this->oAddressBookProvider;
}
/**
* @return \MailSo\Cache\CacheClient
*/
public function Cacher(?\RainLoop\Model\Account $oAccount = null, bool $bForceFile = false)
public function Cacher(?\RainLoop\Model\Account $oAccount = null, bool $bForceFile = false) : \MailSo\Cache\CacheClient
{
$sKey = '';
if ($oAccount)
@ -892,10 +852,7 @@ class Actions
return $this->aCachers[$sIndexKey];
}
/**
* @return \RainLoop\Plugins\Manager
*/
public function Plugins()
public function Plugins() : \RainLoop\Plugins\Manager
{
if (null === $this->oPlugins)
{
@ -906,10 +863,7 @@ class Actions
return $this->oPlugins;
}
/**
* @return \MailSo\Log\Logger
*/
public function Logger()
public function Logger() : \MailSo\Log\Logger
{
if (null === $this->oLogger)
{
@ -999,10 +953,7 @@ class Actions
return $this->oLogger;
}
/**
* @return \MailSo\Log\Logger
*/
public function LoggerAuth()
public function LoggerAuth() : \MailSo\Log\Logger
{
if (null === $this->oLoggerAuth)
{
@ -1096,10 +1047,7 @@ class Actions
}
}
/**
* @return \RainLoop\Model\Account|null
*/
public function LoginProvide(string $sEmail, string $sLogin, string $sPassword, string $sSignMeToken = '', string $sClientCert = '', bool $bThrowProvideException = false)
public function LoginProvide(string $sEmail, string $sLogin, string $sPassword, string $sSignMeToken = '', string $sClientCert = '', bool $bThrowProvideException = false) : ?\RainLoop\Model\Account
{
$oAccount = null;
if (0 < \strlen($sEmail) && 0 < \strlen($sLogin) && 0 < \strlen($sPassword))
@ -1132,10 +1080,9 @@ class Actions
}
/**
* @return \RainLoop\Model\Account|bool
* @throws \RainLoop\Exceptions\ClientException
*/
public function GetAccountFromCustomToken(string $sToken, bool $bThrowExceptionOnFalse = true, bool $bValidateShortToken = true, bool $bQ = false)
public function GetAccountFromCustomToken(string $sToken, bool $bThrowExceptionOnFalse = true, bool $bValidateShortToken = true, bool $bQ = false) : \RainLoop\Model\Account
{
$oResult = false;
if (!empty($sToken))
@ -1180,10 +1127,7 @@ class Actions
return $oResult;
}
/**
* @return \RainLoop\Model\Account|bool
*/
public function GetAccountFromSignMeToken()
public function GetAccountFromSignMeToken() : \RainLoop\Model\Account
{
$oAccount = false;
@ -1220,10 +1164,9 @@ class Actions
}
/**
* @return \RainLoop\Model\Account|bool
* @throws \RainLoop\Exceptions\ClientException
*/
public function getAccountFromToken(bool $bThrowExceptionOnFalse = true)
public function getAccountFromToken(bool $bThrowExceptionOnFalse = true) : \RainLoop\Model\Account
{
return $this->GetAccountFromCustomToken($this->getLocalAuthToken(), $bThrowExceptionOnFalse, true, true);
}
@ -1738,7 +1681,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
{
if (0 < $iDelay && 0 < $iWait)
{
if ($iWait > \time() - APP_START_TIME)
if ($iWait > \time() - $_SERVER['REQUEST_TIME_FLOAT'])
{
\sleep($iDelay);
}
@ -1754,18 +1697,15 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
}
public function AuthToken(?\RainLoop\Model\Account $oAccount) : void
public function AuthToken(\RainLoop\Model\Account $oAccount) : void
{
if ($oAccount)
{
$this->SetAuthToken($oAccount);
$this->SetAuthToken($oAccount);
$aAccounts = $this->GetAccounts($oAccount);
if (\is_array($aAccounts) && isset($aAccounts[$oAccount->Email()]))
{
$aAccounts[$oAccount->Email()] = $oAccount->GetAuthToken();
$this->SetAccounts($oAccount, $aAccounts);
}
$aAccounts = $this->GetAccounts($oAccount);
if (\is_array($aAccounts) && isset($aAccounts[$oAccount->Email()]))
{
$aAccounts[$oAccount->Email()] = $oAccount->GetAuthToken();
$this->SetAccounts($oAccount, $aAccounts);
}
}
@ -1824,11 +1764,10 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
/**
* @return \RainLoop\Model\Account
* @throws \RainLoop\Exceptions\ClientException
*/
public function LoginProcess(string &$sEmail, string &$sPassword, string $sSignMeToken = '',
string $sAdditionalCode = '', bool $bAdditionalCodeSignMe = false, bool $bSkipTwoFactorAuth = false)
string $sAdditionalCode = '', bool $bAdditionalCodeSignMe = false, bool $bSkipTwoFactorAuth = false) : \RainLoop\Model\Account
{
$sInputEmail = $sEmail;
@ -2205,10 +2144,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
return $aTemplates;
}
/**
* @return \RainLoop\Model\Identity
*/
public function GetTemplateByID(\RainLoop\Model\Account $oAccount, string $sID)
public function GetTemplateByID(\RainLoop\Model\Account $oAccount, string $sID) : ?\RainLoop\Model\Identity
{
$aTemplates = $this->GetTemplates($oAccount);
if (\is_array($aTemplates))
@ -2307,10 +2243,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
return $aIdentities;
}
/**
* @return \RainLoop\Model\Identity
*/
public function GetIdentityByID(\RainLoop\Model\Account $oAccount, string $sID, bool $bFirstOnEmpty = false)
public function GetIdentityByID(\RainLoop\Model\Account $oAccount, string $sID, bool $bFirstOnEmpty = false) : ?\RainLoop\Model\Identity
{
$aIdentities = $this->GetIdentities($oAccount);
@ -2327,10 +2260,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
return $bFirstOnEmpty && \is_array($aIdentities) && isset($aIdentities[0]) ? $aIdentities[0] : null;
}
/**
* @return \RainLoop\Model\Identity
*/
public function GetAccountIdentity(\RainLoop\Model\Account $oAccount)
public function GetAccountIdentity(\RainLoop\Model\Account $oAccount) : ?\RainLoop\Model\Identity
{
return $this->GetIdentityByID($oAccount, '', true);
}
@ -3102,7 +3033,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$this->SettingsProvider(true)->Save($oAccount, $oSettingsLocal));
}
public function setConfigFromParams(\RainLoop\Config\Application &$oConfig, string $sParamName, string $sConfigSector, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null) : void
public function setConfigFromParams(\RainLoop\Config\Application $oConfig, string $sParamName, string $sConfigSector, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null) : void
{
$sValue = $this->GetActionParam($sParamName, '');
if ($this->HasActionParam($sParamName))
@ -3140,7 +3071,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
}
private function setCapaFromParams(\RainLoop\Config\Application &$oConfig, string $sParamName, string $sCapa) : void
private function setCapaFromParams(\RainLoop\Config\Application $oConfig, string $sParamName, string $sCapa) : void
{
switch ($sCapa)
{
@ -3174,7 +3105,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
}
private function setSettingsFromParams(\RainLoop\Settings &$oSettings, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null) : void
private function setSettingsFromParams(\RainLoop\Settings $oSettings, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null) : void
{
if ($this->HasActionParam($sConfigName))
{
@ -3523,10 +3454,10 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$oSmtpClient->SetTimeOuts($iConnectionTimeout);
$iTime = \microtime(true);
$oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(),
\MailSo\Smtp\SmtpClient::EhloHelper(), $oDomain->OutSecure(),
$oSmtpClient->Connect($oDomain->OutHost(), $oDomain->OutPort(), $oDomain->OutSecure(),
!!$this->Config()->Get('ssl', 'verify_certificate', false),
!!$this->Config()->Get('ssl', 'allow_self_signed', true)
!!$this->Config()->Get('ssl', 'allow_self_signed', true),
'', \MailSo\Smtp\SmtpClient::EhloHelper()
);
$iSmtpTime = \microtime(true) - $iTime;
@ -4030,7 +3961,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$bResult = $oArchive->extractTo(APP_PLUGINS_PATH);
if (!$bResult)
{
$this->Logger()->Write('Cannot extract package files: '.$oArchive->errorInfo(), \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
$this->Logger()->Write('Cannot extract package files: '.$oArchive->getStatusString(), \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
}
}
}
@ -5004,10 +4935,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
return $this->DefaultResponse(__FUNCTION__, $oMessageList);
}
/**
* @return \MailSo\Mime\Message
*/
private function buildMessage(\RainLoop\Model\Account $oAccount, bool $bWithDraftInfo = true)
private function buildMessage(\RainLoop\Model\Account $oAccount, bool $bWithDraftInfo = true) : \MailSo\Mime\Message
{
$sIdentityID = $this->GetActionParam('IdentityID', '');
$sTo = $this->GetActionParam('To', '');
@ -5195,10 +5123,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
}
/**
* @return \MailSo\Mime\Message
*/
private function buildReadReceiptMessage(\RainLoop\Model\Account $oAccount)
private function buildReadReceiptMessage(\RainLoop\Model\Account $oAccount) : \MailSo\Mime\Message
{
$sReadReceipt = $this->GetActionParam('ReadReceipt', '');
$sSubject = $this->GetActionParam('Subject', '');
@ -7362,10 +7287,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
}
}
/**
* @return \Imagine\Image\AbstractImage
*/
public function correctImageOrientation(\Imagine\Image\AbstractImage $oImage, bool $bDetectImageOrientation = true, int $iThumbnailBoxSize = 0)
public function correctImageOrientation(\Imagine\Image\AbstractImage $oImage, bool $bDetectImageOrientation = true, int $iThumbnailBoxSize = 0) : \Imagine\Image\AbstractImage
{
$iOrientation = 1;
if ($bDetectImageOrientation && \MailSo\Base\Utils::FunctionExistsAndEnabled('exif_read_data') &&
@ -7770,10 +7692,7 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack
$this->AddressBookProvider($oAccount)->Export($oAccount->ParentEmailHelper(), 'csv') : false;
}
/**
* @return \RainLoop\Model\Account|bool
*/
private function initMailClientConnection()
private function initMailClientConnection() : ?\RainLoop\Model\Account
{
$oAccount = null;

View file

@ -4,6 +4,7 @@ namespace RainLoop;
class Api
{
private function __construct()
{
}
@ -38,18 +39,12 @@ class Api
return $oActions;
}
/**
* @return \RainLoop\Config\Application
*/
public static function Config()
public static function Config() : \RainLoop\Config\Application
{
return static::Actions()->Config();
}
/**
* @return \MailSo\Log\Logger
*/
public static function Logger()
public static function Logger() : \MailSo\Log\Logger
{
return static::Actions()->Logger();
}

View file

@ -51,11 +51,10 @@ abstract class PdoAbstract
}
/**
* @return \PDO
*
* @throws \Exception
*/
protected function getPDO()
protected function getPDO() : \PDO
{
if ($this->oPDO)
{
@ -153,10 +152,7 @@ abstract class PdoAbstract
return $this->getPDO()->rollBack();
}
/**
* @return \PDOStatement|null
*/
protected function prepareAndExecute(string $sSql, array $aParams = array(), bool $bMultiplyParams = false, bool $bLogParams = false)
protected function prepareAndExecute(string $sSql, array $aParams = array(), bool $bMultiplyParams = false, bool $bLogParams = false) : ?\PDOStatement
{
if ($this->bExplain && !$bMultiplyParams)
{
@ -292,10 +288,7 @@ abstract class PdoAbstract
return $oPdo ? $oPdo->quote((string) $sValue, \PDO::PARAM_STR) : '\'\'';
}
/**
* @return int|string|bool
*/
protected function getSystemValue(string $sName, bool $bReturnIntValue = true)
protected function getSystemValue(string $sName, bool $bReturnIntValue = true) : int
{
$oPdo = $this->getPDO();
if ($oPdo)
@ -328,10 +321,7 @@ abstract class PdoAbstract
return false;
}
/**
* @return int|string|bool
*/
protected function getVersion(string $sName)
protected function getVersion(string $sName) : int
{
return $this->getSystemValue($sName.'_version', true);
}

View file

@ -81,7 +81,7 @@ class Application extends \RainLoop\Config\AbstractConfig
return $mResult;
}
public function SetPassword(string $sPassword)
public function SetPassword(string $sPassword) : void
{
$this->Set('security', 'admin_password', \password_hash($sPassword, PASSWORD_DEFAULT));
}

View file

@ -4,6 +4,7 @@ namespace RainLoop;
class KeyPathHelper
{
static public function PublicFile(string $sHash) : string
{
return '/Public/Files/'.sha1($sHash).'/Data/';

View file

@ -153,10 +153,7 @@ class Account
return $this->sSignMeToken;
}
/**
* @return \RainLoop\Model\Domain
*/
public function Domain()
public function Domain() : \RainLoop\Model\Domain
{
return $this->oDomain;
}
@ -377,8 +374,9 @@ class Account
if ($aSmtpCredentials['UseConnect'] && !$aSmtpCredentials['UsePhpMail'] && $oSmtpClient)
{
$oSmtpClient->Connect($aSmtpCredentials['Host'], $aSmtpCredentials['Port'], $aSmtpCredentials['Ehlo'],
$aSmtpCredentials['Secure'], $aSmtpCredentials['VerifySsl'], $aSmtpCredentials['AllowSelfSigned']
$oSmtpClient->Connect($aSmtpCredentials['Host'], $aSmtpCredentials['Port'],
$aSmtpCredentials['Secure'], $aSmtpCredentials['VerifySsl'], $aSmtpCredentials['AllowSelfSigned'],
'', $aSmtpCredentials['Ehlo']
);
}

View file

@ -141,13 +141,7 @@ class Domain
$sWhiteList);
}
/**
* @param string $sName
* @param array $aDomain
*
* @return \RainLoop\Model\Domain|null
*/
public static function NewInstanceFromDomainConfigArray(string $sName, $aDomain)
public static function NewInstanceFromDomainConfigArray(string $sName, array $aDomain) : ?\RainLoop\Model\Domain
{
$oDomain = null;

View file

@ -138,7 +138,7 @@ class Notifications
self::UnknownError => 'UnknownError'
);
if (self::ClientViewError === $iCode && $oPrevious instanceof \Throwable)
if (self::ClientViewError === $iCode && $oPrevious)
{
return $oPrevious->getMessage();
}

View file

@ -57,10 +57,7 @@ abstract class AbstractPlugin
$this->bLangs = false;
}
/**
* @return \RainLoop\Config\Plugin
*/
public function Config()
public function Config() : \RainLoop\Config\Plugin
{
if (!$this->bPluginConfigLoaded && $this->oPluginConfig)
{
@ -77,10 +74,7 @@ abstract class AbstractPlugin
return $this->oPluginConfig;
}
/**
* @return \RainLoop\Plugins\Manager
*/
public function Manager()
public function Manager() : \RainLoop\Plugins\Manager
{
return $this->oPluginManager;
}
@ -125,9 +119,6 @@ abstract class AbstractPlugin
return '';
}
/**
* @final
*/
final public function ConfigMap() : array
{
if (null === $this->aConfigMap)

View file

@ -595,18 +595,8 @@ class Manager
return $this->bIsEnabled ? \count($this->aPlugins) : 0;
}
/**
* @param \MailSo\Log\Logger $oLogger
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function SetLogger($oLogger) : self
public function SetLogger(\MailSo\Log\Logger $oLogger) : self
{
if (!($oLogger instanceof \MailSo\Log\Logger))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
$this->oLogger = $oLogger;
return $this;

View file

@ -29,10 +29,7 @@ abstract class AbstractProvider
$this->oLogger = $oLogger;
}
/**
* @return \MailSo\Log\Logger|null
*/
public function Logger()
public function Logger() : ?\MailSo\Log\Logger
{
return $this->oLogger;
}

View file

@ -72,12 +72,7 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider
$iOffset, $iLimit, $sSearch, $iResultCount) : array();
}
/**
* @param string $mID
*
* @return \RainLoop\Providers\AddressBook\Classes\Contact|null
*/
public function GetContactByID(string $sEmail, $mID, bool $bIsStrID = false)
public function GetContactByID(string $sEmail, $mID, bool $bIsStrID = false) : ?\RainLoop\Providers\AddressBook\Classes\Contact
{
return $this->IsActive() ? $this->oDriver->GetContactByID($sEmail, $mID, $bIsStrID) : null;
}

View file

@ -56,12 +56,12 @@ class PdoAddressBook
));
}
private function updateContactEtagAndTime(int $iUserID, int $mID, string $sEtag, int $iChanged)
private function updateContactEtagAndTime(int $iUserID, int $iID, string $sEtag, int $iChanged)
{
return !!$this->prepareAndExecute('UPDATE rainloop_ab_contacts SET changed = :changed, etag = :etag '.
'WHERE id_user = :id_user AND id_contact = :id_contact', array(
':id_user' => array($iUserID, \PDO::PARAM_INT),
':id_contact' => array($mID, \PDO::PARAM_INT),
':id_contact' => array($iID, \PDO::PARAM_INT),
':changed' => array($iChanged, \PDO::PARAM_INT),
':etag' => array($sEtag, \PDO::PARAM_STR)
)
@ -239,7 +239,7 @@ class PdoAddressBook
return $aResponse;
}
private function getContactsPaths(\SabreForRainLoop\DAV\Client &$oClient, string $sUser, string $sPassword, string $sProxy = '') : array
private function getContactsPaths(\SabreForRainLoop\DAV\Client $oClient, string $sUser, string $sPassword, string $sProxy = '') : array
{
$aContactsPaths = array();
@ -425,7 +425,7 @@ class PdoAddressBook
return $aContactsPaths;
}
private function checkContactsPath(\SabreForRainLoop\DAV\Client &$oClient, string $sPath) : bool
private function checkContactsPath(\SabreForRainLoop\DAV\Client $oClient, string $sPath) : bool
{
if (!$oClient)
{
@ -475,7 +475,7 @@ class PdoAddressBook
return $bGood;
}
public function getDavClientFromUrl(string $sUrl, string $sUser, string $sPassword, string $sProxy = '')
public function getDavClientFromUrl(string $sUrl, string $sUser, string $sPassword, string $sProxy = '') : \SabreForRainLoop\DAV\Client
{
if (!\preg_match('/^http[s]?:\/\//i', $sUrl))
{
@ -527,11 +527,11 @@ class PdoAddressBook
return $oClient;
}
public function getDavClient(string $sUrl, string $sUser, string $sPassword, string $sProxy = '') : bool
public function getDavClient(string $sUrl, string $sUser, string $sPassword, string $sProxy = '') : ?\SabreForRainLoop\DAV\Client
{
if (!\class_exists('SabreForRainLoop\DAV\Client'))
{
return false;
return null;
}
$aMatch = array();
@ -548,7 +548,7 @@ class PdoAddressBook
$oClient = $this->getDavClientFromUrl($sUrl, $sUser, $sPassword, $sProxy);
if (!$oClient)
{
return false;
return null;
}
$bGood = false;
@ -1168,10 +1168,8 @@ class PdoAddressBook
/**
* @param mixed $mID
*
* @return \RainLoop\Providers\AddressBook\Classes\Contact|null
*/
public function GetContactByID(string $sEmail, $mID, bool $bIsStrID = false)
public function GetContactByID(string $sEmail, $mID, bool $bIsStrID = false) : ?\RainLoop\Providers\AddressBook\Classes\Contact
{
$mID = \trim($mID);

View file

@ -1,81 +0,0 @@
<?php
namespace RainLoop\Providers;
class ChangePassword extends \RainLoop\Providers\AbstractProvider
{
/**
* @var \RainLoop\Actions
*/
private $oActions;
/**
* @var \RainLoop\Providers\ChangePassword\ChangePasswordInterface
*/
private $oDriver;
/**
* @var bool
*/
private $bCheckWeak;
public function __construct(\RainLoop\Actions $oActions, ?\RainLoop\Providers\ChangePassword\ChangePasswordInterface $oDriver = null, bool $bCheckWeak = true)
{
$this->oActions = $oActions;
$this->oDriver = $oDriver;
$this->bCheckWeak = $bCheckWeak;
}
public function PasswordChangePossibility(\RainLoop\Model\Account $oAccount) : bool
{
return $this->IsActive() &&
$this->oDriver && $this->oDriver->PasswordChangePossibility($oAccount)
;
}
public function ChangePassword(\RainLoop\Model\Account $oAccount, string $sPrevPassword, string $sNewPassword)
{
$mResult = false;
if ($this->oDriver instanceof \RainLoop\Providers\ChangePassword\ChangePasswordInterface &&
$this->PasswordChangePossibility($oAccount))
{
if ($sPrevPassword !== $oAccount->Password())
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CurrentPasswordIncorrect);
}
$sPasswordForCheck = \trim($sNewPassword);
if (6 > \strlen($sPasswordForCheck))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::NewPasswordShort);
}
if (!\MailSo\Base\Utils::PasswordWeaknessCheck($sPasswordForCheck))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::NewPasswordWeak);
}
if (!$this->oDriver->ChangePassword($oAccount, $sPrevPassword, $sNewPassword))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CouldNotSaveNewPassword);
}
$oAccount->SetPassword($sNewPassword);
$this->oActions->SetAuthToken($oAccount);
$mResult = $this->oActions->GetSpecAuthToken();
}
else
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CouldNotSaveNewPassword);
}
return $mResult;
}
public function IsActive() : bool
{
return $this->oDriver instanceof \RainLoop\Providers\ChangePassword\ChangePasswordInterface;
}
}

View file

@ -32,10 +32,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
return $this->bAdmin;
}
/**
* @return \RainLoop\Model\Domain|null
*/
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true)
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true) : ?\RainLoop\Model\Domain
{
$oDomain = $this->oDriver->Load($sName, $bFindWithWildCard, $bCheckDisabled, $bCheckAliases);
if ($oDomain instanceof \RainLoop\Model\Domain)
@ -93,10 +90,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
return $this->oDriver->Count($sSearch);
}
/**
* @return \RainLoop\Model\Domain | null
*/
public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '')
public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '') : ?\RainLoop\Model\Domain
{
$oDomain = null;
@ -163,10 +157,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
return $oDomain;
}
/**
* @return \RainLoop\Model\Domain | null
*/
public function CreateNewAliasFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '')
public function CreateNewAliasFromAction(\RainLoop\Actions $oActions, string $sNameForTest = '') : ?\RainLoop\Model\Domain
{
$oDomain = null;

View file

@ -86,10 +86,7 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
return $sResult;
}
/**
* @return \RainLoop\Model\Domain|null
*/
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true)
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true, bool $bCheckAliases = true) : ?\RainLoop\Model\Domain
{
$mResult = null;

View file

@ -7,10 +7,7 @@ interface DomainAdminInterface extends DomainInterface
public function Disable(string $sName, bool $bDisable) : bool;
/**
* @return \RainLoop\Model\Domain|null
*/
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true);
public function Load(string $sName, bool $bFindWithWildCard = false, bool $bCheckDisabled = true) : ?\RainLoop\Model\Domain;
public function Save(\RainLoop\Model\Domain $oDomain) : bool;

View file

@ -32,10 +32,7 @@ class Files extends \RainLoop\Providers\AbstractProvider
return $this->oDriver->GetFile($oAccount, $sKey, $sOpenMode);
}
/**
* @return string | bool
*/
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey)
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey) : string
{
return $this->oDriver->GetFileName($oAccount, $sKey);
}
@ -45,10 +42,7 @@ class Files extends \RainLoop\Providers\AbstractProvider
return $this->oDriver->Clear($oAccount, $sKey);
}
/**
* @return int|bool
*/
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey)
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey) : int
{
return $this->oDriver->FileSize($oAccount, $sKey);
}

View file

@ -68,10 +68,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
return $mResult;
}
/**
* @return string|bool
*/
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey)
public function GetFileName(\RainLoop\Model\Account $oAccount, string $sKey) : string
{
$mResult = false;
$sFileName = $this->generateFullFileName($oAccount, $sKey);
@ -100,10 +97,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
return $mResult;
}
/**
* @return int|bool
*/
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey)
public function FileSize(\RainLoop\Model\Account $oAccount, string $sKey) : int
{
$mResult = false;
$sFileName = $this->generateFullFileName($oAccount, $sKey);

View file

@ -86,7 +86,7 @@ class FilterCondition
);
}
public static function CollectionFromJSON($aCollection) : array
public static function CollectionFromJSON(array $aCollection) : array
{
$aResult = array();
if (\is_array($aCollection) && 0 < \count($aCollection))

View file

@ -9,30 +9,18 @@ class Settings extends \RainLoop\Providers\AbstractProvider
*/
private $oDriver;
/**
* @param \RainLoop\Providers\Settings\ISettings $oDriver
*/
public function __construct(\RainLoop\Providers\Settings\ISettings $oDriver)
{
$this->oDriver = $oDriver;
}
/**
* @param \RainLoop\Model\Account $oAccount
*
* @return \RainLoop\Settings
*/
public function Load(\RainLoop\Model\Account $oAccount)
public function Load(\RainLoop\Model\Account $oAccount) : \RainLoop\Settings
{
$oSettings = new \RainLoop\Settings();
$oSettings->InitData($this->oDriver->Load($oAccount));
return $oSettings;
}
/**
* @param \RainLoop\Model\Account $oAccount
* @param \RainLoop\Settings $oSettings
*/
public function Save(\RainLoop\Model\Account $oAccount, \RainLoop\Settings $oSettings) : bool
{
return $this->oDriver->Save($oAccount, $oSettings->DataAsArray());

View file

@ -32,7 +32,7 @@ class Storage extends \RainLoop\Providers\AbstractProvider
* @param \RainLoop\Model\Account|string|null $oAccount
* @param mixed $sValue
*/
public function Put($oAccount, int $iStorageType, string $sKey, $sValue) : bool
public function Put($oAccount, int $iStorageType, string $sKey, string $sValue) : bool
{
if (!$this->verifyAccount($oAccount, $iStorageType))
{

View file

@ -28,9 +28,8 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
/**
* @param \RainLoop\Model\Account|string|null $oAccount
* @param mixed $sValue
*/
public function Put($oAccount, int $iStorageType, string $sKey, $sValue) : bool
public function Put($oAccount, int $iStorageType, string $sKey, string $sValue) : bool
{
return false !== @\file_put_contents(
$this->generateFileName($oAccount, $iStorageType, $sKey, true), $sValue);
@ -166,9 +165,6 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
return $sFilePath;
}
/**
* @param \MailSo\Log\Logger $oLogger
*/
public function SetLogger(?\MailSo\Log\Logger $oLogger)
{
$this->oLogger = $oLogger;

View file

@ -6,9 +6,8 @@ interface IStorage
{
/**
* @param \RainLoop\Model\Account|null $oAccount
* @param mixed $sValue
*/
public function Put($oAccount, int $iStorageType, string $sKey, $sValue) : bool;
public function Put($oAccount, int $iStorageType, string $sKey, string $sValue) : bool;
/**
* @param \RainLoop\Model\Account|null $oAccount

View file

@ -6,9 +6,8 @@ class TemproryApcStorage extends \RainLoop\Providers\Storage\FileStorage
{
/**
* @param \RainLoop\Model\Account|string|null $oAccount
* @param mixed $sValue
*/
public function Put($oAccount, int $iStorageType, string $sKey, $sValue) : bool
public function Put($oAccount, int $iStorageType, string $sKey, string $sValue) : bool
{
return !!@\apc_store($this->generateFileName($oAccount, $iStorageType, $sKey, true), $sValue);
}

View file

@ -4,8 +4,5 @@ namespace RainLoop\Providers\Suggestions;
interface ISuggestions
{
/**
* @return array [['email@1', 'name_1'], ['email@2', 'name_2']]
*/
public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20);
public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20) : array;
}

View file

@ -4,11 +4,6 @@ namespace RainLoop\Providers\Suggestions;
class TestSuggestions implements \RainLoop\Providers\Suggestions\ISuggestions
{
/**
* @param \RainLoop\Model\Account $oAccount
* @param string $sQuery
* @param int $iLimit = 20
*/
public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20) : array
{
return array(

View file

@ -4,6 +4,7 @@ namespace RainLoop\Providers\TwoFactorAuth;
abstract class AbstractTwoFactorAuth
{
public function Label() : string
{
return 'Two Factor Authenticator Code';

View file

@ -4,5 +4,6 @@ namespace RainLoop\Providers\TwoFactorAuth;
interface TwoFactorAuthInterface
{
public function VerifyCode(string $sSecret, string $sCode) : bool;
}

View file

@ -32,50 +32,32 @@ class ServiceActions
$this->sQuery = '';
}
/**
* @return \MailSo\Log\Logger
*/
public function Logger()
public function Logger() : \MailSo\Log\Logger
{
return $this->oActions->Logger();
}
/**
* @return \RainLoop\Plugins\Manager
*/
public function Plugins()
public function Plugins() : \RainLoop\Plugins\Manager
{
return $this->oActions->Plugins();
}
/**
* @return \RainLoop\Config\Application
*/
public function Config()
public function Config() : \RainLoop\Config\Application
{
return $this->oActions->Config();
}
/**
* @return \MailSo\Cache\CacheClient
*/
public function Cacher()
public function Cacher() : \MailSo\Cache\CacheClient
{
return $this->oActions->Cacher();
}
/**
* @return \RainLoop\Providers\Storage
*/
public function StorageProvider()
public function StorageProvider() : \RainLoop\Providers\Storage
{
return $this->oActions->StorageProvider();
}
/**
* @return \RainLoop\Providers\Settings
*/
public function SettingsProvider()
public function SettingsProvider() : \RainLoop\Providers\Settings
{
return $this->oActions->SettingsProvider();
}