Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typings to config #35581

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/encryption/lib/Recovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function isRecoveryEnabledForUser($user = '') {
* @return bool
*/
public function isRecoveryKeyEnabled() {
$enabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled', 0);
$enabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled', '0');

return ($enabled === '1');
}
Expand Down
6 changes: 3 additions & 3 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
$params['allowShareWithLink'] = $this->shareManager->shareApiAllowLinks() ? 'yes' : 'no';
$params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
$params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc');
$params['showgridview'] = $this->config->getUserValue($user, 'files', 'show_grid', false);
$showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
$params['showgridview'] = $this->config->getUserValue($user, 'files', 'show_grid', 'false');
$showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', 'false');
$params['showHiddenFiles'] = $showHidden ? 1 : 0;
$cropImagePreviews = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'crop_image_previews', true);
$cropImagePreviews = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'crop_image_previews', 'true');
$params['cropImagePreviews'] = $cropImagePreviews ? 1 : 0;
$params['fileNotFound'] = $fileNotFound ? 1 : 0;
$params['appNavigation'] = $nav;
Expand Down
2 changes: 1 addition & 1 deletion apps/files/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$shareManager = Server::get(IManager::class);
$publicUploadEnabled = $shareManager->shareApiLinkAllowPublicUpload() ? 'yes' : 'no';

$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', false);
$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', 'false');

Check notice

Code scanning / Psalm

PossiblyNullReference

Cannot call method getUID on possibly null value

// renders the controls and table headers template
$tmpl = new OCP\Template('files', 'list', '');
Expand Down
2 changes: 1 addition & 1 deletion apps/files/recentlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
$config = \OC::$server->getConfig();
$userSession = \OC::$server->getUserSession();

$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', false);
$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', 'false');

Check notice

Code scanning / Psalm

PossiblyNullReference

Cannot call method getUID on possibly null value

$tmpl = new OCP\Template('files', 'recentlist', '');

Expand Down
2 changes: 1 addition & 1 deletion apps/files/simplelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$config = \OC::$server->getConfig();
$userSession = \OC::$server->getUserSession();

$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', false);
$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', 'false');

Check notice

Code scanning / Psalm

PossiblyNullReference

Cannot call method getUID on possibly null value

// renders the controls and table headers template
$tmpl = new OCP\Template('files', 'simplelist', '');
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$config = Server::get(IConfig::class);
$userSession = Server::get(IUserSession::class);

$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', false);
$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', 'false');

Check notice

Code scanning / Psalm

PossiblyNullReference

Cannot call method getUID on possibly null value

$tmpl = new OCP\Template('files_sharing', 'list', '');

Expand Down
2 changes: 1 addition & 1 deletion apps/files_trashbin/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
$config = \OC::$server->getConfig();
$userSession = \OC::$server->getUserSession();

$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', false);
$showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', 'false');

Check notice

Code scanning / Psalm

PossiblyNullReference

Cannot call method getUID on possibly null value

$tmpl = new OCP\Template('files_trashbin', 'index', '');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected function run($argument): void {
$user->getUID(),
'lookup_server_connector',
'update_retries',
$this->retries + 1
(string)($this->retries + 1)
);
}
}
Expand Down
24 changes: 11 additions & 13 deletions apps/theming/lib/Migration/MigrateUserConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,18 @@ public function run(IOutput $output) {
$this->userManager->callForSeenUsers(function (IUser $user) use ($output) {
$config = [];

$font = $this->config->getUserValue($user->getUID(), 'accessibility', 'font', false);
$highcontrast = $this->config->getUserValue($user->getUID(), 'accessibility', 'highcontrast', false);
$theme = $this->config->getUserValue($user->getUID(), 'accessibility', 'theme', false);

if ($highcontrast || $theme) {
if ($theme === 'dark' && $highcontrast === 'highcontrast') {
$config[] = $this->darkHighContrastTheme->getId();
} else if ($theme === 'dark') {
$config[] = $this->darkTheme->getId();
} else if ($highcontrast === 'highcontrast') {
$config[] = $this->highContrastTheme->getId();
}
$font = $this->config->getUserValue($user->getUID(), 'accessibility', 'font', '');
$highcontrast = $this->config->getUserValue($user->getUID(), 'accessibility', 'highcontrast', '');
$theme = $this->config->getUserValue($user->getUID(), 'accessibility', 'theme', '');

if ($theme === 'dark' && $highcontrast === 'highcontrast') {
$config[] = $this->darkHighContrastTheme->getId();
} else if ($theme === 'dark') {
$config[] = $this->darkTheme->getId();
} else if ($highcontrast === 'highcontrast') {
$config[] = $this->highContrastTheme->getId();
}

if ($font === 'fontdyslexic') {
$config[] = $this->dyslexiaFont->getId();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/theming/lib/ThemingDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function getLogo($useSvg = true): string {
// explanation: if an SVG is requested and the app config value for logoMime is set then the logo is there.
// otherwise we need to check it and maybe also generate a PNG from the SVG (that's done in getImage() which
// needs to be called then)
if ($useSvg === true && $logo !== false) {
if ($useSvg === true && $logo !== null) {
$logoExists = true;
} else {
try {
Expand Down
4 changes: 2 additions & 2 deletions apps/updatenotification/lib/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private function isUpdaterEnabled() {
*/
public function setChannel(string $channel): DataResponse {
Util::setChannel($channel);
$this->config->setAppValue('core', 'lastupdatedat', 0);
$this->config->setAppValue('core', 'lastupdatedat', '0');
return new DataResponse(['status' => 'success', 'data' => ['message' => $this->l10n->t('Channel updated')]]);
}

Expand All @@ -99,7 +99,7 @@ public function createCredentials(): DataResponse {

// Create a new job and store the creation date
$this->jobList->add(ResetTokenBackgroundJob::class);
$this->config->setAppValue('core', 'updater.secret.created', $this->timeFactory->getTime());
$this->config->setAppValue('core', 'updater.secret.created', (string) $this->timeFactory->getTime());

// Create a new token
$newToken = $this->secureRandom->generate(64);
Expand Down
8 changes: 4 additions & 4 deletions apps/updatenotification/lib/Notification/BackgroundJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ protected function checkCoreUpdate() {

$status = $updater->check();
if ($status === false) {
$errors = 1 + (int) $this->config->getAppValue('updatenotification', 'update_check_errors', 0);
$this->config->setAppValue('updatenotification', 'update_check_errors', $errors);
$errors = 1 + (int) $this->config->getAppValue('updatenotification', 'update_check_errors', '0');
$this->config->setAppValue('updatenotification', 'update_check_errors', (string) $errors);

if (\in_array($errors, $this->connectionNotifications, true)) {
$this->sendErrorNotifications($errors);
}
} elseif (\is_array($status)) {
$this->config->setAppValue('updatenotification', 'update_check_errors', 0);
$this->config->setAppValue('updatenotification', 'update_check_errors', '0');
$this->clearErrorNotifications();

if (isset($status['version'])) {
Expand Down Expand Up @@ -186,7 +186,7 @@ protected function createNotifications($app, $version, $visibleVersion = '') {
return;
}

if ($lastNotification !== false) {
if ($lastNotification !== null) {
// Delete old updates
$this->deleteOutdatedNotifications($app, $lastNotification);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/updatenotification/lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function prepare(INotification $notification, string $languageCode): INot

$l = $this->l10NFactory->get('updatenotification', $languageCode);
if ($notification->getSubject() === 'connection_error') {
$errors = (int) $this->config->getAppValue('updatenotification', 'update_check_errors', 0);
$errors = (int) $this->config->getAppValue('updatenotification', 'update_check_errors', '0');
if ($errors === 0) {
$this->notificationManager->markProcessed($notification);
throw new \InvalidArgumentException('Update checked worked again');
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function ($list, $attribute) {
*/
public function isDeletedUser($id) {
$isDeleted = $this->ocConfig->getUserValue(
$id, 'user_ldap', 'isDeleted', 0);
$id, 'user_ldap', 'isDeleted', '0');
return (int)$isDeleted === 1;
}

Expand Down
6 changes: 3 additions & 3 deletions apps/user_ldap/lib/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,9 @@ private function setOwnCloudAvatar() {
* @throws \OC\ServerNotAvailableException
* @throws \OCP\PreConditionNotMetException
*/
public function getExtStorageHome():string {
public function getExtStorageHome(): string {
Fixed Show fixed Hide fixed
$value = $this->config->getUserValue($this->getUsername(), 'user_ldap', 'extStorageHome', '');
if ($value !== '') {
if ($value !== '' && $value !== null) {
return $value;
}

Expand All @@ -619,7 +619,7 @@ public function getExtStorageHome():string {
* @throws \OCP\PreConditionNotMetException
* @throws \OC\ServerNotAvailableException
*/
public function updateExtStorageHome(string $valueFromLDAP = null):string {
public function updateExtStorageHome(?string $valueFromLDAP = null): string {
if ($valueFromLDAP === null) {
$extHomeValues = $this->access->readAttribute($this->getDN(), $this->connection->ldapExtStorageHomeAttribute);
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/User_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public function deleteUser($uid) {
}
}

$marked = (int)$this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0);
$marked = (int)$this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', '0');
if ($marked === 0) {
try {
$user = $this->access->userManager->get($uid);
Expand Down
2 changes: 1 addition & 1 deletion apps/weather_status/lib/Service/WeatherStatusService.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public function getLocation(): array {
$lat = $this->config->getUserValue($this->userId, Application::APP_ID, 'lat', '');
$lon = $this->config->getUserValue($this->userId, Application::APP_ID, 'lon', '');
$address = $this->config->getUserValue($this->userId, Application::APP_ID, 'address', '');
$mode = $this->config->getUserValue($this->userId, Application::APP_ID, 'mode', self::MODE_MANUAL_LOCATION);
$mode = $this->config->getUserValue($this->userId, Application::APP_ID, 'mode', (string) self::MODE_MANUAL_LOCATION);
return [
'lat' => $lat,
'lon' => $lon,
Expand Down
2 changes: 1 addition & 1 deletion core/Controller/WhatsNewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function get():DataResponse {
if ($user === null) {
throw new \RuntimeException("Acting user cannot be resolved");
}
$lastRead = $this->config->getUserValue($user->getUID(), 'core', 'whatsNewLastRead', 0);
$lastRead = $this->config->getUserValue($user->getUID(), 'core', 'whatsNewLastRead', '0');
$currentVersion = $this->whatsNewService->normalizeVersion($this->config->getSystemValue('version'));

if (version_compare($lastRead, $currentVersion, '>=')) {
Expand Down
Loading