Skip to content

Commit 4fd113a

Browse files
refactor: Repalce array_search with in_array in lib/
Signed-off-by: Christoph Wurst <[email protected]>
1 parent 039ac09 commit 4fd113a

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

lib/private/Archive/TAR.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function getFolder(string $path): array {
197197
if ($pos = strpos($result, '/')) {
198198
$result = substr($result, 0, $pos + 1);
199199
}
200-
if (array_search($result, $folderContent) === false) {
200+
if (!in_array($result, $folderContent)) {
201201
$folderContent[] = $result;
202202
}
203203
}
@@ -269,7 +269,7 @@ public function extract(string $dest): bool {
269269
*/
270270
public function fileExists(string $path): bool {
271271
$files = $this->getFiles();
272-
if ((array_search($path, $files) !== false) or (array_search($path . '/', $files) !== false)) {
272+
if ((in_array($path, $files)) or (in_array($path . '/', $files))) {
273273
return true;
274274
} else {
275275
$folderPath = rtrim($path, '/') . '/';

lib/private/Command/AsyncBus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function runCommand($command) {
8282
private function canRunAsync($command) {
8383
$traits = $this->getTraits($command);
8484
foreach ($traits as $trait) {
85-
if (array_search($trait, $this->syncTraits) !== false) {
85+
if (in_array($trait, $this->syncTraits)) {
8686
return false;
8787
}
8888
}

lib/private/Files/Cache/Cache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ protected function normalizeData(array $data): array {
447447
$params = [];
448448
$extensionParams = [];
449449
foreach ($data as $name => $value) {
450-
if (array_search($name, $fields) !== false) {
450+
if (in_array($name, $fields)) {
451451
if ($name === 'path') {
452452
$params['path_hash'] = md5($value);
453453
} elseif ($name === 'mimetype') {
@@ -467,7 +467,7 @@ protected function normalizeData(array $data): array {
467467
}
468468
$params[$name] = $value;
469469
}
470-
if (array_search($name, $extensionFields) !== false) {
470+
if (in_array($name, $extensionFields)) {
471471
$extensionParams[$name] = $value;
472472
}
473473
}

lib/private/Files/Cache/Watcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function update($path, $cachedData) {
129129
* @return bool
130130
*/
131131
public function needsUpdate($path, $cachedData) {
132-
if ($this->watchPolicy === self::CHECK_ALWAYS or ($this->watchPolicy === self::CHECK_ONCE and array_search($path, $this->checkedPaths) === false)) {
132+
if ($this->watchPolicy === self::CHECK_ALWAYS or ($this->watchPolicy === self::CHECK_ONCE and !in_array($path, $this->checkedPaths))) {
133133
$this->checkedPaths[] = $path;
134134
return $this->storage->hasUpdated($path, $cachedData['storage_mtime']);
135135
}

lib/private/Group/Manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public function isAdmin($userId) {
371371
* @return bool if in group
372372
*/
373373
public function isInGroup($userId, $group) {
374-
return array_search($group, $this->getUserIdGroupIds($userId)) !== false;
374+
return in_array($group, $this->getUserIdGroupIds($userId));
375375
}
376376

377377
/**

lib/private/Hooks/EmitterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function listen($scope, $method, callable $callback) {
4343
if (!isset($this->listeners[$eventName])) {
4444
$this->listeners[$eventName] = [];
4545
}
46-
if (array_search($callback, $this->listeners[$eventName], true) === false) {
46+
if (!in_array($callback, $this->listeners[$eventName], true)) {
4747
$this->listeners[$eventName][] = $callback;
4848
}
4949
}

lib/private/legacy/OC_App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ public function listAllApps(): array {
565565
$supportedApps = $this->getSupportedApps();
566566

567567
foreach ($installedApps as $app) {
568-
if (array_search($app, $blacklist) === false) {
568+
if (!in_array($app, $blacklist)) {
569569
$info = $appManager->getAppInfo($app, false, $langCode);
570570
if (!is_array($info)) {
571571
\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', ILogger::ERROR);

lib/private/legacy/OC_User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public static function setupBackends() {
138138
$class = $config['class'];
139139
$arguments = $config['arguments'];
140140
if (class_exists($class)) {
141-
if (array_search($i, self::$_setupedBackends) === false) {
141+
if (!in_array($i, self::$_setupedBackends)) {
142142
// make a reflection object
143143
$reflectionObj = new ReflectionClass($class);
144144

0 commit comments

Comments
 (0)