Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-02-07 17:00:01 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2022-02-15 15:23:25 +0300
commit3188f5dc76055170e3d504a5cf5f5d1a6e4e7c2c (patch)
tree9092e4f658dac9ec06973fc6f023ddab54d5dcbc /apps
parent9c7b769cb2a068a0baed34558d0554db4f13f192 (diff)
Fix psalm errors in apps/user_ldap/lib/Jobs/CleanUp.php
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/Jobs/CleanUp.php40
1 files changed, 14 insertions, 26 deletions
diff --git a/apps/user_ldap/lib/Jobs/CleanUp.php b/apps/user_ldap/lib/Jobs/CleanUp.php
index b516e08b9e1..a47968962f3 100644
--- a/apps/user_ldap/lib/Jobs/CleanUp.php
+++ b/apps/user_ldap/lib/Jobs/CleanUp.php
@@ -45,7 +45,7 @@ use OCA\User_LDAP\UserPluginManager;
* @package OCA\User_LDAP\Jobs;
*/
class CleanUp extends TimedJob {
- /** @var int $limit amount of users that should be checked per run */
+ /** @var ?int $limit amount of users that should be checked per run */
protected $limit;
/** @var int $defaultIntervalMin default interval in minutes */
@@ -79,7 +79,7 @@ class CleanUp extends TimedJob {
* assigns the instances passed to run() to the class properties
* @param array $arguments
*/
- public function setArguments($arguments) {
+ public function setArguments($arguments): void {
//Dependency Injection is not possible, because the constructor will
//only get values that are serialized to JSON. I.e. whatever we would
//pass in app.php we do add here, except something else is passed e.g.
@@ -134,19 +134,13 @@ class CleanUp extends TimedJob {
* makes the background job do its work
* @param array $argument
*/
- public function run($argument) {
+ public function run($argument): void {
$this->setArguments($argument);
if (!$this->isCleanUpAllowed()) {
return;
}
$users = $this->mapping->getList($this->getOffset(), $this->getChunkSize());
- if (!is_array($users)) {
- //something wrong? Let's start from the beginning next time and
- //abort
- $this->setOffset(true);
- return;
- }
$resetOffset = $this->isOffsetResetNecessary(count($users));
$this->checkUsers($users);
$this->setOffset($resetOffset);
@@ -154,18 +148,15 @@ class CleanUp extends TimedJob {
/**
* checks whether next run should start at 0 again
- * @param int $resultCount
- * @return bool
*/
- public function isOffsetResetNecessary($resultCount) {
+ public function isOffsetResetNecessary(int $resultCount): bool {
return $resultCount < $this->getChunkSize();
}
/**
* checks whether cleaning up LDAP users is allowed
- * @return bool
*/
- public function isCleanUpAllowed() {
+ public function isCleanUpAllowed(): bool {
try {
if ($this->ldapHelper->haveDisabledConfigurations()) {
return false;
@@ -179,9 +170,8 @@ class CleanUp extends TimedJob {
/**
* checks whether clean up is enabled by configuration
- * @return bool
*/
- private function isCleanUpEnabled() {
+ private function isCleanUpEnabled(): bool {
return (bool)$this->ocConfig->getSystemValue(
'ldapUserCleanupInterval', (string)$this->defaultIntervalMin);
}
@@ -190,7 +180,7 @@ class CleanUp extends TimedJob {
* checks users whether they are still existing
* @param array $users result from getMappedUsers()
*/
- private function checkUsers(array $users) {
+ private function checkUsers(array $users): void {
foreach ($users as $user) {
$this->checkUser($user);
}
@@ -200,7 +190,7 @@ class CleanUp extends TimedJob {
* checks whether a user is still existing in LDAP
* @param string[] $user
*/
- private function checkUser(array $user) {
+ private function checkUser(array $user): void {
if ($this->userBackend->userExistsOnLDAP($user['name'])) {
//still available, all good
@@ -212,29 +202,27 @@ class CleanUp extends TimedJob {
/**
* gets the offset to fetch users from the mappings table
- * @return int
*/
- private function getOffset() {
- return (int)$this->ocConfig->getAppValue('user_ldap', 'cleanUpJobOffset', 0);
+ private function getOffset(): int {
+ return (int)$this->ocConfig->getAppValue('user_ldap', 'cleanUpJobOffset', '0');
}
/**
* sets the new offset for the next run
* @param bool $reset whether the offset should be set to 0
*/
- public function setOffset($reset = false) {
+ public function setOffset(bool $reset = false): void {
$newOffset = $reset ? 0 :
$this->getOffset() + $this->getChunkSize();
- $this->ocConfig->setAppValue('user_ldap', 'cleanUpJobOffset', $newOffset);
+ $this->ocConfig->setAppValue('user_ldap', 'cleanUpJobOffset', (string)$newOffset);
}
/**
* returns the chunk size (limit in DB speak)
- * @return int
*/
- public function getChunkSize() {
+ public function getChunkSize(): int {
if ($this->limit === null) {
- $this->limit = (int)$this->ocConfig->getAppValue('user_ldap', 'cleanUpJobChunkSize', 50);
+ $this->limit = (int)$this->ocConfig->getAppValue('user_ldap', 'cleanUpJobChunkSize', '50');
}
return $this->limit;
}