fix: Use strict array comparisons in lib/

To avoid surprises with corner cases.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2026-01-13 11:48:04 +01:00
parent c1dd559965
commit 3c80b7f2b3
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A
5 changed files with 6 additions and 5 deletions

View file

@ -970,7 +970,7 @@ class OC {
if (empty($restrictions)) {
continue;
}
$key = array_search($group->getGID(), $restrictions);
$key = array_search($group->getGID(), $restrictions, true);
unset($restrictions[$key]);
$restrictions = array_values($restrictions);
if (empty($restrictions)) {

View file

@ -354,7 +354,7 @@ class AccountManager implements IAccountManager {
protected function addMissingDefaultValues(array $userData, array $defaultUserData): array {
foreach ($defaultUserData as $defaultDataItem) {
// If property does not exist, initialize it
$userDataIndex = array_search($defaultDataItem['name'], array_column($userData, 'name'));
$userDataIndex = array_search($defaultDataItem['name'], array_column($userData, 'name'), true);
if ($userDataIndex === false) {
$userData[] = $defaultDataItem;
continue;

View file

@ -250,7 +250,7 @@ class Local extends \OC\Files\Storage\Common {
return false;
}
$content = scandir($parentPath, SCANDIR_SORT_NONE);
return is_array($content) && array_search(basename($fullPath), $content) !== false;
return is_array($content) && array_search(basename($fullPath), $content, true) !== false;
} else {
return file_exists($this->getSourcePath($path));
}

View file

@ -654,7 +654,7 @@ class Factory implements IFactory {
// put appropriate languages into appropriate arrays, to print them sorted
// common languages -> divider -> other languages
if (in_array($lang, self::COMMON_LANGUAGE_CODES)) {
$commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)] = $ln;
$commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES, true)] = $ln;
} else {
$otherLanguages[] = $ln;
}

View file

@ -645,7 +645,8 @@ class Tags implements ITags {
return array_search(strtolower($needle), array_map(
function ($tag) use ($mem) {
return strtolower(call_user_func([$tag, $mem]));
}, $haystack)
}, $haystack),
true
);
}