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

@ -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;
}