diff options
author | F. E Noel Nfebe <fenn25.fn@gmail.com> | 2023-06-04 17:11:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-04 17:11:51 +0100 |
commit | cf75c2eaae82b58f5d1bd2cc765b31d5106eeafb (patch) | |
tree | 27770fb65b17fcac11ceab3930f28efd894bfa7e /core | |
parent | 0357e58e3e18aff02611952d23cbb3f7c7aac9b5 (diff) | |
parent | a1ef0285f89112b8777eb47f3c34d07f111660b4 (diff) | |
download | nextcloud-server-cf75c2eaae82b58f5d1bd2cc765b31d5106eeafb.tar.gz nextcloud-server-cf75c2eaae82b58f5d1bd2cc765b31d5106eeafb.zip |
Merge pull request #38602 from fsamapoor/replace_strpos_calls_in_core
Refactors "strpos" calls in /core to improve code readability.
Diffstat (limited to 'core')
-rw-r--r-- | core/Controller/ClientFlowLoginController.php | 4 | ||||
-rw-r--r-- | core/Controller/ClientFlowLoginV2Controller.php | 4 | ||||
-rw-r--r-- | core/Controller/CssController.php | 2 | ||||
-rw-r--r-- | core/Controller/JsController.php | 2 | ||||
-rw-r--r-- | core/Controller/LoginController.php | 2 | ||||
-rw-r--r-- | core/Controller/NavigationController.php | 4 | ||||
-rw-r--r-- | core/ajax/update.php | 2 |
7 files changed, 10 insertions, 10 deletions
diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php index 85a793bd92b..2876621c97b 100644 --- a/core/Controller/ClientFlowLoginController.php +++ b/core/Controller/ClientFlowLoginController.php @@ -368,9 +368,9 @@ class ClientFlowLoginController extends Controller { private function getServerPath(): string { $serverPostfix = ''; - if (strpos($this->request->getRequestUri(), '/index.php') !== false) { + if (str_contains($this->request->getRequestUri(), '/index.php')) { $serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/index.php')); - } elseif (strpos($this->request->getRequestUri(), '/login/flow') !== false) { + } elseif (str_contains($this->request->getRequestUri(), '/login/flow')) { $serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/login/flow')); } diff --git a/core/Controller/ClientFlowLoginV2Controller.php b/core/Controller/ClientFlowLoginV2Controller.php index ef16cfbd04b..0c12f1a612f 100644 --- a/core/Controller/ClientFlowLoginV2Controller.php +++ b/core/Controller/ClientFlowLoginV2Controller.php @@ -363,9 +363,9 @@ class ClientFlowLoginV2Controller extends Controller { private function getServerPath(): string { $serverPostfix = ''; - if (strpos($this->request->getRequestUri(), '/index.php') !== false) { + if (str_contains($this->request->getRequestUri(), '/index.php')) { $serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/index.php')); - } elseif (strpos($this->request->getRequestUri(), '/login/v2') !== false) { + } elseif (str_contains($this->request->getRequestUri(), '/login/v2')) { $serverPostfix = substr($this->request->getRequestUri(), 0, strpos($this->request->getRequestUri(), '/login/v2')); } diff --git a/core/Controller/CssController.php b/core/Controller/CssController.php index 4cd2996835e..792be71f9e1 100644 --- a/core/Controller/CssController.php +++ b/core/Controller/CssController.php @@ -101,7 +101,7 @@ class CssController extends Controller { private function getFile(ISimpleFolder $folder, string $fileName, bool &$gzip): ISimpleFile { $encoding = $this->request->getHeader('Accept-Encoding'); - if (strpos($encoding, 'gzip') !== false) { + if (str_contains($encoding, 'gzip')) { try { $gzip = true; return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz diff --git a/core/Controller/JsController.php b/core/Controller/JsController.php index 885de5491e7..6b3e7ff2ed2 100644 --- a/core/Controller/JsController.php +++ b/core/Controller/JsController.php @@ -99,7 +99,7 @@ class JsController extends Controller { private function getFile(ISimpleFolder $folder, string $fileName, bool &$gzip): ISimpleFile { $encoding = $this->request->getHeader('Accept-Encoding'); - if (strpos($encoding, 'gzip') !== false) { + if (str_contains($encoding, 'gzip')) { try { $gzip = true; return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php index aa6617c4b6d..9c64204b898 100644 --- a/core/Controller/LoginController.php +++ b/core/Controller/LoginController.php @@ -275,7 +275,7 @@ class LoginController extends Controller { $location = $this->urlGenerator->getAbsoluteURL($redirectUrl); // Deny the redirect if the URL contains a @ // This prevents unvalidated redirects like ?redirect_url=:user@domain.com - if (strpos($location, '@') === false) { + if (!str_contains($location, '@')) { return new RedirectResponse($location); } } diff --git a/core/Controller/NavigationController.php b/core/Controller/NavigationController.php index 6b994ca33f1..a1c3f917fe3 100644 --- a/core/Controller/NavigationController.php +++ b/core/Controller/NavigationController.php @@ -94,10 +94,10 @@ class NavigationController extends OCSController { */ private function rewriteToAbsoluteUrls(array $navigation): array { foreach ($navigation as &$entry) { - if (0 !== strpos($entry['href'], $this->urlGenerator->getBaseUrl())) { + if (!str_starts_with($entry['href'], $this->urlGenerator->getBaseUrl())) { $entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']); } - if (0 !== strpos($entry['icon'], $this->urlGenerator->getBaseUrl())) { + if (!str_starts_with($entry['icon'], $this->urlGenerator->getBaseUrl())) { $entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']); } } diff --git a/core/ajax/update.php b/core/ajax/update.php index 1678e30c02e..c28f2cdcd7c 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -46,7 +46,7 @@ use OC\Repair\Events\RepairStepEvent; use OC\Repair\Events\RepairWarningEvent; use OCP\L10N\IFactory; -if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { +if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) { @set_time_limit(0); } |