diff --git a/lib/Config.php b/lib/Config.php index 20e6ff6954..b5258674d3 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -295,19 +295,19 @@ class Config { protected function getWebSocketDomainForSignalingServer(string $url): string { $url .= '/'; - if (strpos($url, 'https://') === 0) { + if (str_starts_with($url, 'https://')) { return 'wss://' . substr($url, 8, strpos($url, '/', 9) - 8); } - if (strpos($url, 'http://') === 0) { + if (str_starts_with($url, 'http://')) { return 'ws://' . substr($url, 7, strpos($url, '/', 8) - 7); } - if (strpos($url, 'wss://') === 0) { + if (str_starts_with($url, 'wss://')) { return substr($url, 0, strpos($url, '/', 7)); } - if (strpos($url, 'ws://') === 0) { + if (str_starts_with($url, 'ws://')) { return substr($url, 0, strpos($url, '/', 6)); } @@ -509,7 +509,7 @@ class Config { return; } - if (substr($alg, 0, 2) === 'ES') { + if (str_starts_with($alg, 'ES')) { $privKey = openssl_pkey_new([ 'curve_name' => 'prime256v1', 'private_key_bits' => 2048, @@ -520,7 +520,7 @@ class Config { if (!openssl_pkey_export($privKey, $secret)) { throw new \Exception('Could not export private key'); } - } elseif (substr($alg, 0, 2) === 'RS') { + } elseif (str_starts_with($alg, 'RS')) { $privKey = openssl_pkey_new([ 'private_key_bits' => 2048, 'private_key_type' => OPENSSL_KEYTYPE_RSA, diff --git a/lib/Controller/SignalingController.php b/lib/Controller/SignalingController.php index 1da09a0b90..52850f71c1 100644 --- a/lib/Controller/SignalingController.php +++ b/lib/Controller/SignalingController.php @@ -235,11 +235,11 @@ class SignalingController extends OCSController { $url = rtrim($signalingServers[$serverId]['server'], '/'); $url = strtolower($url); - if (strpos($url, 'wss://') === 0) { + if (str_starts_with($url, 'wss://')) { $url = 'https://' . substr($url, 6); } - if (strpos($url, 'ws://') === 0) { + if (str_starts_with($url, 'ws://')) { $url = 'http://' . substr($url, 5); } diff --git a/lib/Deck/DeckPluginLoader.php b/lib/Deck/DeckPluginLoader.php index ac7db96ab5..88e880086a 100644 --- a/lib/Deck/DeckPluginLoader.php +++ b/lib/Deck/DeckPluginLoader.php @@ -48,7 +48,7 @@ class DeckPluginLoader implements IEventListener { return; } - if (strpos($this->request->getPathInfo(), '/apps/deck') === 0) { + if (str_starts_with($this->request->getPathInfo(), '/apps/deck')) { Util::addScript('spreed', 'talk-collections'); Util::addScript('spreed', 'talk-deck'); } diff --git a/lib/Flow/Operation.php b/lib/Flow/Operation.php index aa185d6fab..bcc165752b 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -159,7 +159,7 @@ class Operation implements IOperation { case self::MESSAGE_MODES['ROOM_MENTION']: return '@all '; case self::MESSAGE_MODES['SELF_MENTION']: - $hasWhitespace = strpos($participant->getAttendee()->getActorId(), ' ') !== false; + $hasWhitespace = str_contains($participant->getAttendee()->getActorId(), ' '); $enclosure = $hasWhitespace ? '"' : ''; return '@' . $enclosure . $participant->getAttendee()->getActorId() . $enclosure . ' '; case self::MESSAGE_MODES['NO_MENTION']: diff --git a/lib/Maps/MapsPluginLoader.php b/lib/Maps/MapsPluginLoader.php index 039b367599..7cd94a89ab 100644 --- a/lib/Maps/MapsPluginLoader.php +++ b/lib/Maps/MapsPluginLoader.php @@ -58,7 +58,7 @@ class MapsPluginLoader implements IEventListener { return; } - if (strpos($this->request->getPathInfo(), '/apps/maps') === 0) { + if (str_starts_with($this->request->getPathInfo(), '/apps/maps')) { Util::addScript('spreed', 'talk-collections'); Util::addScript('spreed', 'talk-maps'); } diff --git a/lib/Migration/FixNamespaceInDatabaseTables.php b/lib/Migration/FixNamespaceInDatabaseTables.php index 5e8f98b2f7..d62803968f 100644 --- a/lib/Migration/FixNamespaceInDatabaseTables.php +++ b/lib/Migration/FixNamespaceInDatabaseTables.php @@ -54,7 +54,7 @@ class FixNamespaceInDatabaseTables implements IRepairStep { $result = $query->executeQuery(); while ($row = $result->fetch()) { $oldClass = $row['class']; - if (strpos($oldClass, 'OCA\\Spreed\\') !== 0) { + if (!str_starts_with($oldClass, 'OCA\\Spreed\\')) { continue; } diff --git a/lib/Recording/BackendNotifier.php b/lib/Recording/BackendNotifier.php index e8d746dded..ee67b3a9c5 100644 --- a/lib/Recording/BackendNotifier.php +++ b/lib/Recording/BackendNotifier.php @@ -103,9 +103,9 @@ class BackendNotifier { $url = '/api/v1/room/' . $room->getToken(); $url = $recording['server'] . $url; - if (strpos($url, 'wss://') === 0) { + if (str_starts_with($url, 'wss://')) { $url = 'https://' . substr($url, 6); - } elseif (strpos($url, 'ws://') === 0) { + } elseif (str_starts_with($url, 'ws://')) { $url = 'http://' . substr($url, 5); } $body = json_encode($data); diff --git a/lib/Room.php b/lib/Room.php index c16a98680b..381d0ff547 100644 --- a/lib/Room.php +++ b/lib/Room.php @@ -257,7 +257,7 @@ class Room { /** @var RoomService $roomService */ $roomService = Server::get(RoomService::class); $roomService->setName($this, json_encode($users), ''); - } elseif (strpos($this->name, '["') !== 0) { + } elseif (!str_starts_with($this->name, '["')) { // TODO use DI $participantService = Server::get(ParticipantService::class); // Not the json array, but the old fallback when someone left diff --git a/lib/Search/ConversationSearch.php b/lib/Search/ConversationSearch.php index 0e3dbc688a..775c5861e0 100644 --- a/lib/Search/ConversationSearch.php +++ b/lib/Search/ConversationSearch.php @@ -65,7 +65,7 @@ class ConversationSearch implements IProvider { * @inheritDoc */ public function getOrder(string $route, array $routeParameters): int { - if (strpos($route, Application::APP_ID . '.') === 0) { + if (str_starts_with($route, Application::APP_ID . '.')) { // Active app, prefer Talk results return -1; } @@ -88,7 +88,7 @@ class ConversationSearch implements IProvider { $parameters = $query->getRouteParameters(); if (isset($parameters['token']) && $parameters['token'] === $room->getToken() && - strpos($query->getRoute(), Application::APP_ID . '.') === 0) { + str_starts_with($query->getRoute(), Application::APP_ID . '.')) { // Don't search the current conversation. //User most likely looks for other things with the same name continue; diff --git a/lib/Search/MessageSearch.php b/lib/Search/MessageSearch.php index abfdcddada..c7af503343 100644 --- a/lib/Search/MessageSearch.php +++ b/lib/Search/MessageSearch.php @@ -76,7 +76,7 @@ class MessageSearch implements IProvider, IFilteringProvider { * @inheritDoc */ public function getOrder(string $route, array $routeParameters): ?int { - if (strpos($route, Application::APP_ID . '.') === 0) { + if (str_starts_with($route, Application::APP_ID . '.')) { // Active app, prefer Talk results return -2; } diff --git a/lib/Service/CommandService.php b/lib/Service/CommandService.php index 86014c59ed..a01b04d44e 100644 --- a/lib/Service/CommandService.php +++ b/lib/Service/CommandService.php @@ -127,7 +127,7 @@ class CommandService { if ($command->getApp() === '' || $command->getApp() === null) { $script = $command->getScript(); - if (strpos($script, 'alias:') === 0) { + if (str_starts_with($script, 'alias:')) { try { $this->resolveAlias($command); } catch (DoesNotExistException $e) { @@ -137,7 +137,7 @@ class CommandService { if (preg_match('/[`\'"]{(?:ARGUMENTS|ROOM|USER)}[`\'"]/i', $script)) { throw new \InvalidArgumentException('script-parameters', 6); } - if (strpos($script, '{ARGUMENTS_DOUBLEQUOTE_ESCAPED}') !== false) { + if (str_contains($script, '{ARGUMENTS_DOUBLEQUOTE_ESCAPED}')) { throw new \InvalidArgumentException('script-parameters', 6); } @@ -165,7 +165,7 @@ class CommandService { */ public function resolveAlias(Command $command): Command { $script = $command->getScript(); - if (strpos($script, 'alias:') === 0) { + if (str_starts_with($script, 'alias:')) { $alias = explode(':', $script, 3); if (isset($alias[2])) { [, $app, $cmd] = $alias; diff --git a/lib/Settings/Admin/AdminSettings.php b/lib/Settings/Admin/AdminSettings.php index fe98011e0d..8aef0a6d39 100644 --- a/lib/Settings/Admin/AdminSettings.php +++ b/lib/Settings/Admin/AdminSettings.php @@ -411,7 +411,7 @@ class AdminSettings implements ISettings { } $userLocale = $this->serverConfig->getUserValue($this->currentUser->getUID(), 'core', 'locale', 'en_US'); $guessCountry = 'US'; - if (strpos($userLocale, '_') !== false) { + if (str_contains($userLocale, '_')) { $guessCountry = substr($userLocale, strrpos($userLocale, '_') + 1); $correctGuess = false; foreach ($countries as $country) { @@ -519,11 +519,11 @@ class AdminSettings implements ISettings { if ($usingFPM) { // Needs to use mpm_event - return strpos($apacheModule, 'event') !== false ? '' : 'invalid'; + return str_contains($apacheModule, 'event') ? '' : 'invalid'; } // Needs to use mpm_prefork - return strpos($apacheModule, 'prefork') !== false ? '' : 'invalid'; + return str_contains($apacheModule, 'prefork') ? '' : 'invalid'; } /** diff --git a/lib/Signaling/BackendNotifier.php b/lib/Signaling/BackendNotifier.php index fc19ecc177..61d6d8dff2 100644 --- a/lib/Signaling/BackendNotifier.php +++ b/lib/Signaling/BackendNotifier.php @@ -122,9 +122,9 @@ class BackendNotifier { $url = '/api/v1/room/' . $room->getToken(); $url = $signaling['server'] . $url; - if (strpos($url, 'wss://') === 0) { + if (str_starts_with($url, 'wss://')) { $url = 'https://' . substr($url, 6); - } elseif (strpos($url, 'ws://') === 0) { + } elseif (str_starts_with($url, 'ws://')) { $url = 'http://' . substr($url, 5); } $body = json_encode($data);