Skip to content

Commit

Permalink
Merge branch 'phpstan' into 'master'
Browse files Browse the repository at this point in the history
Fixed phpstan issues

See merge request grommunio/grommunio-sync!51
  • Loading branch information
gromandreas committed Nov 6, 2023
2 parents 11d8060 + d2dcb16 commit 2a5f779
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ settings.json
vendor/phpstan*
vendor/bin/phpstan*
mapi
phpstan.neon.dist
2 changes: 2 additions & 0 deletions lib/core/changesmemorywrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ public function ImportFolderDeletion($folder) {

return true;
}

return false;
}

/*----------------------------------------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions lib/core/interprocessdata.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ protected function setData($data, $id = 2, $ttl = -1) {

protected function setDeviceUserData($key, $data, $devid, $user, $subkey = -1, $doCas = false, $rawdata = false) {
$compKey = $this->getComposedKey($devid, $user, $subkey);
$ok = false;

// overwrite
if (!$doCas) {
$ok = ($this->ipcProvider->get()->hset($key, $compKey, json_encode($data)) !== false);
}
// merge data and do CAS on the $compKey
elseif ($doCas == "merge") {
$ok = false;
$okCount = 0;
// TODO: make this configurable (retrycount)?
while (!$ok && $okCount < 5) {
Expand Down Expand Up @@ -204,7 +204,6 @@ protected function setDeviceUserData($key, $data, $devid, $user, $subkey = -1, $
}
// delete keys of data and do CAS on the $compKey
elseif ($doCas == "deletekeys") {
$ok = false;
$okCount = 0;
// TODO: make this configurable (retrycount)?
while (!$ok && $okCount < 5) {
Expand Down
2 changes: 2 additions & 0 deletions lib/core/sharedfolders.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class SharedFolders extends InterProcessData {
private static $instance = false;
private $shared;
private $updateTime;
private $localpart;
private $mainDomain;

public static function GetSharedFolders() {
if (!self::$instance) {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/stateobject.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public static function ThrowStateInvalidException() {
*
* Serializes the object to a value that can be serialized natively by json_encode()
*
* @return array
* @return mixed
*/
public function jsonSerialize() {
return [
Expand Down
2 changes: 1 addition & 1 deletion lib/core/streamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public function GetStreamerVars() {
*
* Serializes the object to a value that can be serialized natively by json_encode()
*
* @return array
* @return mixed
*/
public function jsonSerialize() {
$data = [];
Expand Down
10 changes: 7 additions & 3 deletions lib/grommunio/exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ class ExportChangesICS implements IExportChanges {
private $store;
private $session;
private $restriction;
private $contentparameters;
private $contentParameters;
private $flags;
private $exporterflags;
private $exporter;
private $moveSrcState;
private $moveDstState;
private $statestream;

/**
* Constructor.
Expand Down Expand Up @@ -79,6 +78,7 @@ public function __construct($session, $store, $folderid = false) {
}
catch (MAPIException $me) {
$this->exporter = false;

// We return the general error SYNC_FSSTATUS_CODEUNKNOWN (12) which is also SYNC_STATUS_FOLDERHIERARCHYCHANGED (12)
// if this happened while doing content sync, the mobile will try to resync the folderhierarchy
throw new StatusException(sprintf("ExportChangesICS('%s','%s','%s'): Error, unable to open folder: 0x%X", $session, $store, Utils::PrintAsString($folderid), mapi_last_hresult()), SYNC_FSSTATUS_CODEUNKNOWN);
Expand Down Expand Up @@ -136,6 +136,8 @@ public function Config($state, $flags = 0) {

mapi_stream_write($stream, $state);
$this->statestream = $stream;

return true;
}

/**
Expand Down Expand Up @@ -171,6 +173,8 @@ public function ConfigContentParameters($contentparameters) {
}

$this->contentParameters = $contentparameters;

return true;
}

/**
Expand Down
11 changes: 6 additions & 5 deletions lib/request/find.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,18 @@ public function Handle($commandCode) {

try {
if ($searchname == ISearchProvider::SEARCH_GAL) {
// get search results from the searchprovider
$rows = $searchprovider->GetGALSearchResults($searchquery, $searchrange, $searchpicture);
// TODO: Fix GAL search in Find command
// $rows = $searchprovider->GetGALSearchResults($cpo->GetFindFreeText(), "0-100", null);
throw new StatusException("GAL search in FIND command is not implemented. Please report this including the 'WBXML debug data' logged. Be aware that the debug data could contain confidential information.", SYNC_FINDSTATUS_INVALIDREQUEST, null, LOGLEVEL_FATAL);
}
elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) {
if ($searchname == ISearchProvider::SEARCH_MAILBOX) {
$backendFolderId = self::$deviceManager->GetBackendIdForFolderId($cpo->GetFindFolderid());
$cpo->SetFindFolderid($backendFolderId);
$rows = $searchprovider->GetMailboxSearchResults($cpo);
}
}
catch (StatusException $stex) {
$storestatus = $stex->getCode();
$status = $stex->getCode();
}

self::$encoder->startTag(SYNC_FIND_RESPONSE);
Expand All @@ -160,7 +161,7 @@ public function Handle($commandCode) {
self::$encoder->endTag();

self::$encoder->startTag(SYNC_FIND_STATUS);
self::$encoder->content(SYNC_FINDSTATUS_SUCCESS);
self::$encoder->content($status);
self::$encoder->endTag();

if (isset($rows['range'])) {
Expand Down
2 changes: 1 addition & 1 deletion lib/wbxml/wbxmldecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ private function getOpaque($len) {
/**
* Reads one byte from the input stream.
*
* @return int
* @return int|void
*/
private function getByte() {
$ch = fread($this->in, 1);
Expand Down

0 comments on commit 2a5f779

Please sign in to comment.