From 9e052883bf0ecc64cafd54270aea121d1a8da7c3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 18 Sep 2026 12:04:37 +0930 Subject: [PATCH] StrContains --- app/Http/Controllers/Admin/AdminSettingsController.php | 4 ++-- app/Http/Controllers/Api/ApiV1Controller.php | 2 +- app/Http/Controllers/FederationController.php | 2 +- app/Http/Controllers/InstallController.php | 2 +- app/Services/ImportService.php | 4 ++-- app/Services/SearchApiV2Service.php | 4 ++-- app/Util/Lexer/Extractor.php | 2 +- app/Util/Lexer/HitHighlighter.php | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Admin/AdminSettingsController.php b/app/Http/Controllers/Admin/AdminSettingsController.php index e59b4ee72..0b4cd706e 100644 --- a/app/Http/Controllers/Admin/AdminSettingsController.php +++ b/app/Http/Controllers/Admin/AdminSettingsController.php @@ -882,12 +882,12 @@ trait AdminSettingsController $visibility = $request->input('disk_config.visibility'); $url = $request->input('disk_config.url'); $endpoint = $request->input('disk_config.endpoint'); - if (strpos($key, '*') === false && $key != config_cache($dkey.'key')) { + if (!str_contains($key, '*') && $key != config_cache($dkey.'key')) { array_push($changes, 'key'); } else { $ckey = config_cache($dkey.'key'); } - if (strpos($secret, '*') === false && $secret != config_cache($dkey.'secret')) { + if (!str_contains($secret, '*') && $secret != config_cache($dkey.'secret')) { array_push($changes, 'secret'); } else { $csecret = config_cache($dkey.'secret'); diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index a6223c128..2473c03a0 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -3518,7 +3518,7 @@ class ApiV1Controller extends Controller if ( isset($status['account']['acct']) && - strpos($status['account']['acct'], '@') !== false + str_contains($status['account']['acct'], '@') ) { $domain = parse_url( $status['account']['url'], diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php index 58a3ad854..3e9d11619 100644 --- a/app/Http/Controllers/FederationController.php +++ b/app/Http/Controllers/FederationController.php @@ -113,7 +113,7 @@ class FederationController extends Controller if ($cached = Cache::get($key)) { return response()->json($cached, 200, [], JSON_UNESCAPED_SLASHES); } - if (strpos($resource, $domain) == false) { + if (!str_contains($resource, $domain)) { return response('', 400); } $parsed = Nickname::normalizeProfileUrl($resource); diff --git a/app/Http/Controllers/InstallController.php b/app/Http/Controllers/InstallController.php index 9e82a0dec..10153fd00 100644 --- a/app/Http/Controllers/InstallController.php +++ b/app/Http/Controllers/InstallController.php @@ -192,7 +192,7 @@ class InstallController extends Controller protected function updateConfig($key, $value): void { $f = file_get_contents(base_path('.env')); - if (strpos($f, $key) !== false) { + if (str_contains($f, $key)) { $u = str_replace($key, $value, $f); } else { $u = $f; diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index c5f3ec141..5b6328ba2 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -74,7 +74,7 @@ class ImportService } throw $e; } catch (\Exception $e) { - if (strpos($e->getMessage(), 'Could not find valid next date') !== false) { + if (str_contains($e->getMessage(), 'Could not find valid next date')) { return null; } throw $e; @@ -169,7 +169,7 @@ class ImportService throw $e; } catch (\Exception $e) { - if (strpos($e->getMessage(), 'Could not find valid next date') !== false) { + if (str_contains($e->getMessage(), 'Could not find valid next date')) { return null; } throw $e; diff --git a/app/Services/SearchApiV2Service.php b/app/Services/SearchApiV2Service.php index 5f5ca0083..46234492a 100644 --- a/app/Services/SearchApiV2Service.php +++ b/app/Services/SearchApiV2Service.php @@ -236,14 +236,14 @@ class SearchApiV2Service return $this->resolveLocalProfile(); } } else { - if (! Helpers::validateUrl($query) && strpos($query, '@') === false) { + if (! Helpers::validateUrl($query) && !str_contains($query, '@')) { return $default; } if ( ! Str::startsWith($query, 'http') && Str::substrCount($query, '@') == 1 && - strpos($query, '@') !== false && + str_contains($query, '@') && strpos($query, '@') !== 0 ) { try { diff --git a/app/Util/Lexer/Extractor.php b/app/Util/Lexer/Extractor.php index 5e8fc4ade..0539593c2 100755 --- a/app/Util/Lexer/Extractor.php +++ b/app/Util/Lexer/Extractor.php @@ -332,7 +332,7 @@ class Extractor extends Regex } $needle = $this->extractURLWithoutProtocol() ? '.' : ':'; - if (strpos($tweet, $needle) === false) { + if (!str_contains($tweet, $needle)) { return []; } diff --git a/app/Util/Lexer/HitHighlighter.php b/app/Util/Lexer/HitHighlighter.php index 5922875e0..27d748904 100755 --- a/app/Util/Lexer/HitHighlighter.php +++ b/app/Util/Lexer/HitHighlighter.php @@ -114,7 +114,7 @@ class HitHighlighter extends Regex $highlightTweet = ''; $tags = ['<'.$this->tag.'>', 'tag.'>']; // Check whether we can simply replace or whether we need to chunk... - if (strpos($tweet, '<') === false) { + if (!str_contains($tweet, '<')) { $ti = 0; // tag increment (for added tags) $highlightTweet = $tweet; foreach ($hits as $hit) {