From a1654ae27458de2dc2ef428f75671094a48ff4b8 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Thu, 29 Jan 2026 11:32:56 +0100 Subject: [PATCH] refactor: use strict operator --- lib/base.php | 8 ++++---- lib/private/App/AppManager.php | 6 +++--- lib/private/Contacts/ContactsMenu/ContactsStore.php | 2 +- lib/private/Files/Cache/Cache.php | 2 +- lib/private/Files/Cache/Updater.php | 2 +- lib/private/Files/Mount/MountPoint.php | 2 +- lib/private/Files/ObjectStore/S3ObjectTrait.php | 2 +- lib/private/Installer.php | 2 +- lib/private/Log/File.php | 4 ++-- lib/private/Security/CertificateManager.php | 2 +- lib/private/Share20/Manager.php | 8 ++++---- lib/private/TemplateLayout.php | 2 +- lib/private/legacy/OC_Helper.php | 4 ++-- lib/public/Util.php | 6 +++--- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/base.php b/lib/base.php index 8676b17e19b48..6399a82be6637 100644 --- a/lib/base.php +++ b/lib/base.php @@ -117,8 +117,8 @@ public static function initPaths(): void { if (substr($scriptName, -1) == '/') { $scriptName .= 'index.php'; //make sure suburi follows the same rules as scriptName - if (substr(OC::$SUBURI, -9) != 'index.php') { - if (substr(OC::$SUBURI, -1) != '/') { + if (substr(OC::$SUBURI, -9) !== 'index.php') { + if (substr(OC::$SUBURI, -1) !== '/') { OC::$SUBURI = OC::$SUBURI . '/'; } OC::$SUBURI = OC::$SUBURI . 'index.php'; @@ -131,7 +131,7 @@ public static function initPaths(): void { if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) { OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); - if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { + if (OC::$WEBROOT !== '' && OC::$WEBROOT[0] !== '/') { OC::$WEBROOT = '/' . OC::$WEBROOT; } } else { @@ -236,7 +236,7 @@ public static function checkInstalled(\OC\SystemConfig $systemConfig): void { public static function checkMaintenanceMode(\OC\SystemConfig $systemConfig): void { // Allow ajax update script to execute without being stopped - if (((bool)$systemConfig->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') { + if (((bool)$systemConfig->getValue('maintenance', false)) && OC::$SUBURI !== '/core/ajax/update.php') { // send http status 503 http_response_code(503); header('X-Nextcloud-Maintenance-Mode: 1'); diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 655d80e9b6c91..2e4709dd0a3e0 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -195,7 +195,7 @@ public function getAllAppsInAppsFolders(): array { if (is_resource($dh)) { while (($file = readdir($dh)) !== false) { if ( - $file[0] != '.' + $file[0] !== '.' && is_dir($apps_dir['path'] . '/' . $file) && is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml') ) { @@ -711,7 +711,7 @@ public function getAppPath(string $appId, bool $ignoreCache = false): string { return __DIR__ . '/../../../core'; } - if (($dir = $this->findAppInDirectories($appId, $ignoreCache)) != false) { + if (($dir = $this->findAppInDirectories($appId, $ignoreCache)) !== false) { return $dir['path'] . '/' . $appId; } throw new AppPathNotFoundException('Could not find path for ' . $appId); @@ -723,7 +723,7 @@ public function getAppPath(string $appId, bool $ignoreCache = false): string { * @throws AppPathNotFoundException if app path can't be found */ public function getAppWebPath(string $appId): string { - if (($dir = $this->findAppInDirectories($appId)) != false) { + if (($dir = $this->findAppInDirectories($appId)) !== false) { return \OC::$WEBROOT . $dir['url'] . '/' . $appId; } throw new AppPathNotFoundException('Could not find web path for ' . $appId); diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index deb03ce37f31f..c0549924b8c0c 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -183,7 +183,7 @@ private function filterContacts( $decodedExcludeGroups = json_decode($excludedGroups, true); $excludeGroupsList = $decodedExcludeGroups ?? []; - if ($excludeGroups != 'allow') { + if ($excludeGroups !== 'allow') { if (count($selfGroups) > 0 && count(array_diff($selfGroups, $excludeGroupsList)) === 0) { // all the groups of the current user are excluded -> filter all local users $skipLocal = true; diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 6213b88fc17df..7493d5822afdc 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -533,7 +533,7 @@ private function getParentPath($path) { * @return bool */ public function inCache($file) { - return $this->getId($file) != -1; + return $this->getId($file) !== -1; } /** diff --git a/lib/private/Files/Cache/Updater.php b/lib/private/Files/Cache/Updater.php index cdbff8b6c9ac0..bcdc3318a9ec6 100644 --- a/lib/private/Files/Cache/Updater.php +++ b/lib/private/Files/Cache/Updater.php @@ -275,7 +275,7 @@ private function updateStorageMTimeOnly($internalPath) { private function correctParentStorageMtime($internalPath) { $parentId = $this->cache->getParentId($internalPath); $parent = dirname($internalPath); - if ($parentId != -1) { + if ($parentId !== -1) { $mtime = $this->storage->filemtime($parent); if ($mtime !== false) { try { diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index a50a762c6b9fb..93db221b306ae 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -236,7 +236,7 @@ private function formatPath($path) { public function wrapStorage($wrapper) { $storage = $this->getStorage(); // storage can be null if it couldn't be initialized - if ($storage != null) { + if ($storage !== null) { $this->storage = $wrapper($this->mountPoint, $storage, $this); } } diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php index b6b55c746b2c9..662e611402f42 100644 --- a/lib/private/Files/ObjectStore/S3ObjectTrait.php +++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php @@ -161,7 +161,7 @@ protected function writeMultiPart(string $urn, StreamInterface $stream, array $m $totalWritten += $command['ContentLength']; }, 'before_complete' => function ($_command) use (&$totalWritten, $size, &$uploader, &$attempts) { - if ($size !== null && $totalWritten != $size) { + if ($size !== null && $totalWritten !== $size) { $e = new \Exception('Incomplete multi part upload, expected ' . $size . ' bytes, wrote ' . $totalWritten); throw new MultipartUploadException($uploader->getState(), $e); } diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 40a91287e3ae8..ff4c5f2f80571 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -631,7 +631,7 @@ private function copyRecursive(string $src, string $dest): void { } $files = scandir($src); foreach ($files as $file) { - if ($file != '.' && $file != '..') { + if ($file !== '.' && $file !== '..') { $this->copyRecursive("$src/$file", "$dest/$file"); } } diff --git a/lib/private/Log/File.php b/lib/private/Log/File.php index ba428ba185b39..47b885b1ce415 100644 --- a/lib/private/Log/File.php +++ b/lib/private/Log/File.php @@ -51,7 +51,7 @@ public function __construct( public function write(string $app, $message, int $level): void { $entry = $this->logDetailsAsJSON($app, $message, $level); $handle = @fopen($this->logFile, 'a'); - if ($this->logFileMode > 0 && is_file($this->logFile) && (fileperms($this->logFile) & 0777) != $this->logFileMode) { + if ($this->logFileMode > 0 && is_file($this->logFile) && (fileperms($this->logFile) & 0777) !== $this->logFileMode) { @chmod($this->logFile, $this->logFileMode); } if ($handle) { @@ -87,7 +87,7 @@ public function getEntries(int $limit = 50, int $offset = 0): array { fseek($handle, $pos); $ch = fgetc($handle); if ($ch == "\n" || $pos == 0) { - if ($line != '') { + if ($line !== '') { // Add the first character if at the start of the file, // because it doesn't hit the else in the loop if ($pos == 0) { diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php index d8a988261db6c..77b36997273d7 100644 --- a/lib/private/Security/CertificateManager.php +++ b/lib/private/Security/CertificateManager.php @@ -49,7 +49,7 @@ public function listCertificates(): array { return []; } while (false !== ($file = readdir($handle))) { - if ($file != '.' && $file != '..') { + if ($file !== '.' && $file !== '..') { try { $content = $this->view->file_get_contents($path . $file); if ($content !== false) { diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 7a1b7045b3643..cbf0e3246c05d 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -780,7 +780,7 @@ public function updateShare(IShare $share, bool $onlyValid = true): IShare { if ($share->getShareType() === IShare::TYPE_USER) { $this->userCreateChecks($share); - if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { + if ($share->getExpirationDate() !== $originalShare->getExpirationDate()) { // Verify the expiration date $this->validateExpirationDateInternal($share); $expirationDateUpdated = true; @@ -788,7 +788,7 @@ public function updateShare(IShare $share, bool $onlyValid = true): IShare { } elseif ($share->getShareType() === IShare::TYPE_GROUP) { $this->groupCreateChecks($share); - if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { + if ($share->getExpirationDate() !== $originalShare->getExpirationDate()) { // Verify the expiration date $this->validateExpirationDateInternal($share); $expirationDateUpdated = true; @@ -824,13 +824,13 @@ public function updateShare(IShare $share, bool $onlyValid = true): IShare { } } - if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { + if ($share->getExpirationDate() !== $originalShare->getExpirationDate()) { // Verify the expiration date $this->validateExpirationDateLink($share); $expirationDateUpdated = true; } } elseif ($share->getShareType() === IShare::TYPE_REMOTE || $share->getShareType() === IShare::TYPE_REMOTE_GROUP) { - if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { + if ($share->getExpirationDate() !== $originalShare->getExpirationDate()) { // Verify the expiration date $this->validateExpirationDateInternal($share); $expirationDateUpdated = true; diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 6c1fe71e4e9c5..fe9928b2852bf 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -217,7 +217,7 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate { // Add the js files $jsFiles = $this->findJavascriptFiles(Util::getScripts()); $page->assign('jsfiles', []); - if ($this->config->getSystemValueBool('installed', false) && $renderAs != TemplateResponse::RENDER_AS_ERROR) { + if ($this->config->getSystemValueBool('installed', false) && $renderAs !== TemplateResponse::RENDER_AS_ERROR) { // this is on purpose outside of the if statement below so that the initial state is prefilled (done in the getConfig() call) // see https://github.com/nextcloud/server/pull/22636 for details $jsConfigHelper = new JSConfigHelper( diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index 65f4300f850ec..6d94f3dab7709 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -53,7 +53,7 @@ public static function copyr($src, $dest) { } $files = scandir($src); foreach ($files as $file) { - if ($file != '.' && $file != '..') { + if ($file !== '.' && $file !== '..') { self::copyr("$src/$file", "$dest/$file"); } } @@ -87,7 +87,7 @@ public static function canExecute($name, $path = false) { $dirs = explode(PATH_SEPARATOR, (string)$path); // WARNING : We have to check if open_basedir is enabled : $obd = OC::$server->get(IniGetWrapper::class)->getString('open_basedir'); - if ($obd != 'none') { + if ($obd !== 'none') { $obd_values = explode(PATH_SEPARATOR, $obd); if (count($obd_values) > 0 && $obd_values[0]) { // open_basedir is in effect ! diff --git a/lib/public/Util.php b/lib/public/Util.php index 70a862880f19d..058e60c795aed 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -263,7 +263,7 @@ public static function linkToRemote($service) { $urlGenerator = \OCP\Server::get(IURLGenerator::class); $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; return $urlGenerator->getAbsoluteURL( - $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') + $remoteBase . (($service[strlen($service) - 1] !== '/') ? '/' : '') ); } @@ -276,7 +276,7 @@ public static function getServerHostName() { $host_name = \OCP\Server::get(IRequest::class)->getServerHost(); // strip away port number (if existing) $colon_pos = strpos($host_name, ':'); - if ($colon_pos != false) { + if ($colon_pos !== false) { $host_name = substr($host_name, 0, $colon_pos); } return $host_name; @@ -491,7 +491,7 @@ public static function encodePath($component) { * @since 4.5.0 */ public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { - $case = ($case != MB_CASE_UPPER) ? MB_CASE_LOWER : MB_CASE_UPPER; + $case = ($case !== MB_CASE_UPPER) ? MB_CASE_LOWER : MB_CASE_UPPER; $ret = []; foreach ($input as $k => $v) { $ret[mb_convert_case($k, $case, $encoding)] = $v;