aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndy Scherzinger <info@andy-scherzinger.de>2023-11-22 20:42:52 +0100
committerGitHub <noreply@github.com>2023-11-22 20:42:52 +0100
commit42724c15c5fb02e34150904d3ad8d1447cf9e30e (patch)
tree8409ebd9889bd484cf223ca0ff63b625d96caca6 /lib
parente490ac6e8b6cdb06141f6bdb3357387033813b70 (diff)
parentea8f9a7e841061ed96f291aa3c9a413fe2402b5c (diff)
downloadnextcloud-server-42724c15c5fb02e34150904d3ad8d1447cf9e30e.tar.gz
nextcloud-server-42724c15c5fb02e34150904d3ad8d1447cf9e30e.zip
Merge pull request #40462 from nextcloud/refactor/lib-array_search-to-in_array
refactor: Replace array_search with in_array in lib/
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Archive/TAR.php4
-rw-r--r--lib/private/Command/AsyncBus.php2
-rw-r--r--lib/private/Files/Cache/Cache.php4
-rw-r--r--lib/private/Files/Cache/Watcher.php2
-rw-r--r--lib/private/Group/Manager.php2
-rw-r--r--lib/private/Hooks/EmitterTrait.php2
-rw-r--r--lib/private/legacy/OC_App.php2
-rw-r--r--lib/private/legacy/OC_User.php2
8 files changed, 10 insertions, 10 deletions
diff --git a/lib/private/Archive/TAR.php b/lib/private/Archive/TAR.php
index 9dc906384e0..a6140e44eb6 100644
--- a/lib/private/Archive/TAR.php
+++ b/lib/private/Archive/TAR.php
@@ -197,7 +197,7 @@ class TAR extends Archive {
if ($pos = strpos($result, '/')) {
$result = substr($result, 0, $pos + 1);
}
- if (array_search($result, $folderContent) === false) {
+ if (!in_array($result, $folderContent)) {
$folderContent[] = $result;
}
}
@@ -269,7 +269,7 @@ class TAR extends Archive {
*/
public function fileExists(string $path): bool {
$files = $this->getFiles();
- if ((array_search($path, $files) !== false) or (array_search($path . '/', $files) !== false)) {
+ if ((in_array($path, $files)) or (in_array($path . '/', $files))) {
return true;
} else {
$folderPath = rtrim($path, '/') . '/';
diff --git a/lib/private/Command/AsyncBus.php b/lib/private/Command/AsyncBus.php
index ec6fbc91f68..c65e6cad78e 100644
--- a/lib/private/Command/AsyncBus.php
+++ b/lib/private/Command/AsyncBus.php
@@ -82,7 +82,7 @@ abstract class AsyncBus implements IBus {
private function canRunAsync($command) {
$traits = $this->getTraits($command);
foreach ($traits as $trait) {
- if (array_search($trait, $this->syncTraits) !== false) {
+ if (in_array($trait, $this->syncTraits)) {
return false;
}
}
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index 27db4dfe809..46228af565b 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -454,7 +454,7 @@ class Cache implements ICache {
$params = [];
$extensionParams = [];
foreach ($data as $name => $value) {
- if (array_search($name, $fields) !== false) {
+ if (in_array($name, $fields)) {
if ($name === 'path') {
$params['path_hash'] = md5($value);
} elseif ($name === 'mimetype') {
@@ -474,7 +474,7 @@ class Cache implements ICache {
}
$params[$name] = $value;
}
- if (array_search($name, $extensionFields) !== false) {
+ if (in_array($name, $extensionFields)) {
$extensionParams[$name] = $value;
}
}
diff --git a/lib/private/Files/Cache/Watcher.php b/lib/private/Files/Cache/Watcher.php
index acc76f263dc..61ea5b2f848 100644
--- a/lib/private/Files/Cache/Watcher.php
+++ b/lib/private/Files/Cache/Watcher.php
@@ -129,7 +129,7 @@ class Watcher implements IWatcher {
* @return bool
*/
public function needsUpdate($path, $cachedData) {
- if ($this->watchPolicy === self::CHECK_ALWAYS or ($this->watchPolicy === self::CHECK_ONCE and array_search($path, $this->checkedPaths) === false)) {
+ if ($this->watchPolicy === self::CHECK_ALWAYS or ($this->watchPolicy === self::CHECK_ONCE and !in_array($path, $this->checkedPaths))) {
$this->checkedPaths[] = $path;
return $this->storage->hasUpdated($path, $cachedData['storage_mtime']);
}
diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php
index 47475121ea0..da99187f130 100644
--- a/lib/private/Group/Manager.php
+++ b/lib/private/Group/Manager.php
@@ -371,7 +371,7 @@ class Manager extends PublicEmitter implements IGroupManager {
* @return bool if in group
*/
public function isInGroup($userId, $group) {
- return array_search($group, $this->getUserIdGroupIds($userId)) !== false;
+ return in_array($group, $this->getUserIdGroupIds($userId));
}
/**
diff --git a/lib/private/Hooks/EmitterTrait.php b/lib/private/Hooks/EmitterTrait.php
index da4e3da2bd6..fe9cba893de 100644
--- a/lib/private/Hooks/EmitterTrait.php
+++ b/lib/private/Hooks/EmitterTrait.php
@@ -43,7 +43,7 @@ trait EmitterTrait {
if (!isset($this->listeners[$eventName])) {
$this->listeners[$eventName] = [];
}
- if (array_search($callback, $this->listeners[$eventName], true) === false) {
+ if (!in_array($callback, $this->listeners[$eventName], true)) {
$this->listeners[$eventName][] = $callback;
}
}
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php
index 23e0b099e91..579c38b2d7c 100644
--- a/lib/private/legacy/OC_App.php
+++ b/lib/private/legacy/OC_App.php
@@ -564,7 +564,7 @@ class OC_App {
$supportedApps = $this->getSupportedApps();
foreach ($installedApps as $app) {
- if (array_search($app, $blacklist) === false) {
+ if (!in_array($app, $blacklist)) {
$info = $appManager->getAppInfo($app, false, $langCode);
if (!is_array($info)) {
\OCP\Server::get(LoggerInterface::class)->error('Could not read app info file for app "' . $app . '"', ['app' => 'core']);
diff --git a/lib/private/legacy/OC_User.php b/lib/private/legacy/OC_User.php
index 5751b813f2c..d2dc2a2389f 100644
--- a/lib/private/legacy/OC_User.php
+++ b/lib/private/legacy/OC_User.php
@@ -138,7 +138,7 @@ class OC_User {
$class = $config['class'];
$arguments = $config['arguments'];
if (class_exists($class)) {
- if (array_search($i, self::$_setupedBackends) === false) {
+ if (!in_array($i, self::$_setupedBackends)) {
// make a reflection object
$reflectionObj = new ReflectionClass($class);