mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
refactor: Repalce array_search with in_array in lib/
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
ba1af2b22e
commit
ea8f9a7e84
8 changed files with 10 additions and 10 deletions
|
|
@ -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, '/') . '/';
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue