Solved more problems of issues #4

This commit is contained in:
djmaze 2020-09-24 10:22:23 +02:00
parent 578131e22a
commit f70d2c6884
4 changed files with 20 additions and 30 deletions

View file

@ -479,7 +479,7 @@ class Contact
/**
* @param mixed $oProp
*/
private function addArrayPropertyHelper(array &$aProperties, $oArrayProp, int $iType) : string
private function addArrayPropertyHelper(array &$aProperties, $oArrayProp, int $iType) : void
{
foreach ($oArrayProp as $oProp)
{
@ -501,7 +501,7 @@ class Contact
}
}
public function PopulateByVCard(string $sUid, string $sVCard, string $sEtag = '', $oLogger = null)
public function PopulateByVCard(string $sUid, string $sVCard, string $sEtag = '', $oLogger = null) : bool
{
if ("\xef\xbb\xbf" === \substr($sVCard, 0, 3))
{

View file

@ -24,7 +24,7 @@ class Tag
$this->Clear();
}
public function Clear()
public function Clear() : void
{
$this->IdContactTag = '';
$this->Name = '';

View file

@ -41,7 +41,7 @@ class PdoAddressBook
public function IsSupported() : bool
{
$aDrivers = \class_exists('PDO') ? \PDO::getAvailableDrivers() : array();
return \is_array($aDrivers) ? \in_array($this->sDsnType, $aDrivers) : false;
return \is_array($aDrivers) && \in_array($this->sDsnType, $aDrivers);
}
public function IsSharingAllowed() : bool
@ -49,14 +49,14 @@ class PdoAddressBook
return $this->IsSupported() && false; // TODO
}
private function flushDeletedContacts(int $iUserID)
private function flushDeletedContacts(int $iUserID) : bool
{
return !!$this->prepareAndExecute('DELETE FROM rainloop_ab_contacts WHERE id_user = :id_user AND deleted = 1', array(
':id_user' => array($iUserID, \PDO::PARAM_INT)
));
}
private function updateContactEtagAndTime(int $iUserID, int $iID, string $sEtag, int $iChanged)
private function updateContactEtagAndTime(int $iUserID, int $iID, string $sEtag, int $iChanged) : bool
{
return !!$this->prepareAndExecute('UPDATE rainloop_ab_contacts SET changed = :changed, etag = :etag '.
'WHERE id_user = :id_user AND id_contact = :id_contact', array(
@ -68,7 +68,7 @@ class PdoAddressBook
);
}
private function prepearDatabaseSyncData(int $iUserID)
private function prepearDatabaseSyncData(int $iUserID) : array
{
$aResult = array();
$oStmt = $this->prepareAndExecute('SELECT id_contact, id_contact_str, changed, deleted, etag FROM rainloop_ab_contacts WHERE id_user = :id_user', array(
@ -175,7 +175,7 @@ class PdoAddressBook
return $mResult;
}
private function davClientRequest($oClient, string $sCmd, string $sUrl, $mData = null)
private function davClientRequest($oClient, string $sCmd, string $sUrl, $mData = null) : ?array
{
\MailSo\Base\Utils::ResetTimeLimit();
@ -187,23 +187,23 @@ class PdoAddressBook
// $this->oLogger->Write($mData, \MailSo\Log\Enumerations\Type::INFO, 'DAV');
// }
$oResponse = false;
$aResponse = null;
try
{
if (('PUT' === $sCmd || 'POST' === $sCmd) && null !== $mData)
{
$oResponse = $oClient->request($sCmd, $sUrl, $mData, array(
$aResponse = $oClient->request($sCmd, $sUrl, $mData, array(
'Content-Type' => 'text/vcard; charset=utf-8'
));
}
else
{
$oResponse = $oClient->request($sCmd, $sUrl);
$aResponse = $oClient->request($sCmd, $sUrl);
}
// if ('GET' === $sCmd)
// {
// $this->oLogger->WriteDump($oResponse, \MailSo\Log\Enumerations\Type::INFO, 'DAV');
// $this->oLogger->WriteDump($aResponse, \MailSo\Log\Enumerations\Type::INFO, 'DAV');
// }
}
catch (\Throwable $oException)
@ -211,10 +211,10 @@ class PdoAddressBook
$this->oLogger->WriteException($oException);
}
return $oResponse;
return $aResponse;
}
private function detectionPropFind(\SabreForRainLoop\DAV\Client $oClient, string $sPath) : bool
private function detectionPropFind(\SabreForRainLoop\DAV\Client $oClient, string $sPath) : ?array
{
$aResponse = null;
@ -543,10 +543,9 @@ class PdoAddressBook
return null;
}
$bGood = false;
$sPath = $oClient->__UrlPath__;
$bGood = false;
$bGood = true;
if ('' === $sPath || '/' === $sPath || !$this->checkContactsPath($oClient, $sPath))
{
$sNewPath = '';
@ -599,17 +598,8 @@ class PdoAddressBook
$bGood = $this->checkContactsPath($oClient, $sPath);
}
else
{
$bGood = true;
}
if (!$bGood)
{
$oClient = false;
}
return $oClient;
return $bGood ? $oClient : null;
}
public function Sync(string $sEmail, string $sUrl, string $sUser, string $sPassword, string $sProxy = '') : bool
@ -1645,7 +1635,7 @@ class PdoAddressBook
return $sResult;
}
private function getInitialTablesArray(string $sDbType)
private function getInitialTablesArray(string $sDbType) : array
{
switch ($sDbType)
{
@ -1753,6 +1743,7 @@ SQLITEINITIAL;
break;
}
$aResult = array();
if (0 < \strlen($sInitial))
{
$aList = \explode(';', \trim($sInitial));

View file

@ -149,7 +149,7 @@ class Client {
* @param int $depth
* @return array
*/
public function propFind($url, array $properties, $depth = 0) {
public function propFind($url, array $properties, $depth = 0) : array {
$body = '<?xml version="1.0"?>' . "\n";
$body.= '<d:propfind xmlns:d="DAV:">' . "\n";
@ -304,9 +304,8 @@ class Client {
* @param string $url
* @param string $body
* @param array $headers
* @return array
*/
public function request($method, $url = '', $body = null, $headers = array()) {
public function request($method, $url = '', $body = null, $headers = array()) : array {
$url = $this->getAbsoluteUrl($url);