refactor: Repalce array_search with in_array in lib/

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
pull/40462/head
Christoph Wurst 1 year ago committed by Arthur Schiwon
parent ba1af2b22e
commit ea8f9a7e84
  1. 4
      lib/private/Archive/TAR.php
  2. 2
      lib/private/Command/AsyncBus.php
  3. 4
      lib/private/Files/Cache/Cache.php
  4. 2
      lib/private/Files/Cache/Watcher.php
  5. 2
      lib/private/Group/Manager.php
  6. 2
      lib/private/Hooks/EmitterTrait.php
  7. 2
      lib/private/legacy/OC_App.php
  8. 2
      lib/private/legacy/OC_User.php

@ -197,7 +197,7 @@ class TAR extends Archive {
if ($pos = strpos($result, '/')) { if ($pos = strpos($result, '/')) {
$result = substr($result, 0, $pos + 1); $result = substr($result, 0, $pos + 1);
} }
if (array_search($result, $folderContent) === false) { if (!in_array($result, $folderContent)) {
$folderContent[] = $result; $folderContent[] = $result;
} }
} }
@ -269,7 +269,7 @@ class TAR extends Archive {
*/ */
public function fileExists(string $path): bool { public function fileExists(string $path): bool {
$files = $this->getFiles(); $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; return true;
} else { } else {
$folderPath = rtrim($path, '/') . '/'; $folderPath = rtrim($path, '/') . '/';

@ -82,7 +82,7 @@ abstract class AsyncBus implements IBus {
private function canRunAsync($command) { private function canRunAsync($command) {
$traits = $this->getTraits($command); $traits = $this->getTraits($command);
foreach ($traits as $trait) { foreach ($traits as $trait) {
if (array_search($trait, $this->syncTraits) !== false) { if (in_array($trait, $this->syncTraits)) {
return false; return false;
} }
} }

@ -454,7 +454,7 @@ class Cache implements ICache {
$params = []; $params = [];
$extensionParams = []; $extensionParams = [];
foreach ($data as $name => $value) { foreach ($data as $name => $value) {
if (array_search($name, $fields) !== false) { if (in_array($name, $fields)) {
if ($name === 'path') { if ($name === 'path') {
$params['path_hash'] = md5($value); $params['path_hash'] = md5($value);
} elseif ($name === 'mimetype') { } elseif ($name === 'mimetype') {
@ -474,7 +474,7 @@ class Cache implements ICache {
} }
$params[$name] = $value; $params[$name] = $value;
} }
if (array_search($name, $extensionFields) !== false) { if (in_array($name, $extensionFields)) {
$extensionParams[$name] = $value; $extensionParams[$name] = $value;
} }
} }

@ -129,7 +129,7 @@ class Watcher implements IWatcher {
* @return bool * @return bool
*/ */
public function needsUpdate($path, $cachedData) { 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; $this->checkedPaths[] = $path;
return $this->storage->hasUpdated($path, $cachedData['storage_mtime']); return $this->storage->hasUpdated($path, $cachedData['storage_mtime']);
} }

@ -371,7 +371,7 @@ class Manager extends PublicEmitter implements IGroupManager {
* @return bool if in group * @return bool if in group
*/ */
public function isInGroup($userId, $group) { public function isInGroup($userId, $group) {
return array_search($group, $this->getUserIdGroupIds($userId)) !== false; return in_array($group, $this->getUserIdGroupIds($userId));
} }
/** /**

@ -43,7 +43,7 @@ trait EmitterTrait {
if (!isset($this->listeners[$eventName])) { if (!isset($this->listeners[$eventName])) {
$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; $this->listeners[$eventName][] = $callback;
} }
} }

@ -564,7 +564,7 @@ class OC_App {
$supportedApps = $this->getSupportedApps(); $supportedApps = $this->getSupportedApps();
foreach ($installedApps as $app) { foreach ($installedApps as $app) {
if (array_search($app, $blacklist) === false) { if (!in_array($app, $blacklist)) {
$info = $appManager->getAppInfo($app, false, $langCode); $info = $appManager->getAppInfo($app, false, $langCode);
if (!is_array($info)) { if (!is_array($info)) {
\OCP\Server::get(LoggerInterface::class)->error('Could not read app info file for app "' . $app . '"', ['app' => 'core']); \OCP\Server::get(LoggerInterface::class)->error('Could not read app info file for app "' . $app . '"', ['app' => 'core']);

@ -138,7 +138,7 @@ class OC_User {
$class = $config['class']; $class = $config['class'];
$arguments = $config['arguments']; $arguments = $config['arguments'];
if (class_exists($class)) { if (class_exists($class)) {
if (array_search($i, self::$_setupedBackends) === false) { if (!in_array($i, self::$_setupedBackends)) {
// make a reflection object // make a reflection object
$reflectionObj = new ReflectionClass($class); $reflectionObj = new ReflectionClass($class);

Loading…
Cancel
Save