Skip to content

Commit 8cd35f2

Browse files
Use str_contains function for modules and plugins (joomla#44938)
Co-authored-by: Harald Leithner <[email protected]>
1 parent 6c51496 commit 8cd35f2

File tree

14 files changed

+29
-29
lines changed

14 files changed

+29
-29
lines changed

modules/mod_menu/src/Helper/MenuHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static function getList(&$params)
125125
break;
126126

127127
case 'url':
128-
if ((str_starts_with($item->link, 'index.php?')) && (strpos($item->link, 'Itemid=') === false)) {
128+
if ((str_starts_with($item->link, 'index.php?')) && (!str_contains($item->link, 'Itemid='))) {
129129
// If this is an internal Joomla link, ensure the Itemid is set.
130130
$item->flink = $item->link . '&Itemid=' . $item->id;
131131
}
@@ -150,7 +150,7 @@ public static function getList(&$params)
150150
break;
151151
}
152152

153-
if ((strpos($item->flink, 'index.php?') !== false) && strcasecmp(substr($item->flink, 0, 4), 'http')) {
153+
if ((str_contains($item->flink, 'index.php?')) && strcasecmp(substr($item->flink, 0, 4), 'http')) {
154154
$item->flink = Route::_($item->flink, true, $itemParams->get('secure'));
155155
} else {
156156
$item->flink = Route::_($item->flink);

modules/mod_wrapper/src/Helper/WrapperHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getParamsWrapper(Registry $params, SiteApplication $app)
5252
if (str_starts_with($url, '/')) {
5353
// Relative URL in component. use server http_host.
5454
$url = 'http://' . $app->getInput()->server->get('HTTP_HOST') . $url;
55-
} elseif (strpos($url, 'http') === false && strpos($url, 'https') === false) {
55+
} elseif (!str_contains($url, 'http') && !str_contains($url, 'https')) {
5656
$url = 'http://' . $url;
5757
}
5858
}

plugins/api-authentication/token/src/Extension/Token.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function onUserAuthenticate(AuthenticationEvent $event): void
149149
// The token is a base64 encoded string. Make sure we can decode it.
150150
$authString = @base64_decode($tokenString);
151151

152-
if (empty($authString) || (strpos($authString, ':') === false)) {
152+
if (empty($authString) || (!str_contains($authString, ':'))) {
153153
return;
154154
}
155155

plugins/behaviour/taggable/src/Extension/Taggable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function onTableAfterStore(AfterStoreEvent $event)
173173
if (empty($newTags)) {
174174
$result = $tagsHelper->postStoreProcess($table);
175175
} else {
176-
if (\is_string($newTags) && (strpos($newTags, ',') !== false)) {
176+
if (\is_string($newTags) && (str_contains($newTags, ','))) {
177177
$newTags = explode(',', $newTags);
178178
} elseif (!\is_array($newTags)) {
179179
$newTags = (array) $newTags;

plugins/content/fields/src/Extension/Fields.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ public function onContentPrepare(ContentPrepareEvent $event)
7474
}
7575

7676
// Prepare the text
77-
if (property_exists($item, 'text') && strpos($item->text, 'field') !== false) {
77+
if (property_exists($item, 'text') && str_contains($item->text, 'field')) {
7878
$item->text = $this->prepare($item->text, $context, $item);
7979
}
8080

8181
// Prepare the intro text
82-
if (property_exists($item, 'introtext') && \is_string($item->introtext) && strpos($item->introtext, 'field') !== false) {
82+
if (property_exists($item, 'introtext') && \is_string($item->introtext) && str_contains($item->introtext, 'field')) {
8383
$item->introtext = $this->prepare($item->introtext, $context, $item);
8484
}
8585

8686
// Prepare the full text
87-
if (!empty($item->fulltext) && strpos($item->fulltext, 'field') !== false) {
87+
if (!empty($item->fulltext) && str_contains($item->fulltext, 'field')) {
8888
$item->fulltext = $this->prepare($item->fulltext, $context, $item);
8989
}
9090
}

plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function display(string $name, string $content = '', array $attributes =
205205
* If URL, just pass it to $content_css
206206
* else, assume it is a file name in the current template folder
207207
*/
208-
$content_css = strpos($content_css_custom, 'http') !== false
208+
$content_css = str_contains($content_css_custom, 'http')
209209
? $content_css_custom
210210
: $this->includeRelativeFiles('css', $content_css_custom);
211211
} else {
@@ -383,11 +383,11 @@ public function prepareTinyMCEUploadPath(string $path): string
383383
$custom_button = trim($levelParams->get('custom_button', ''));
384384

385385
if ($custom_plugin) {
386-
$plugins = array_merge($plugins, explode(strpos($custom_plugin, ',') !== false ? ',' : ' ', $custom_plugin));
386+
$plugins = array_merge($plugins, explode(str_contains($custom_plugin, ',') ? ',' : ' ', $custom_plugin));
387387
}
388388

389389
if ($custom_button) {
390-
$toolbar1 = array_merge($toolbar1, explode(strpos($custom_button, ',') !== false ? ',' : ' ', $custom_button));
390+
$toolbar1 = array_merge($toolbar1, explode(str_contains($custom_button, ',') ? ',' : ' ', $custom_button));
391391
}
392392

393393
// Merge the two toolbars for backwards compatibility

plugins/system/debug/src/DataCollector/QueryCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private function getStatements(): array
219219

220220
$isCaller = 0;
221221

222-
if (\Joomla\Database\DatabaseDriver::class === $class && false === strpos($file, 'DatabaseDriver.php')) {
222+
if (\Joomla\Database\DatabaseDriver::class === $class && !str_contains($file, 'DatabaseDriver.php')) {
223223
$callerLocation = $location;
224224
$isCaller = 1;
225225
}

plugins/system/debug/src/Extension/Debug.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function onAfterRespond(AfterRespondEvent|ApplicationEvent $event): void
366366
// No debug for Safari and Chrome redirection.
367367
if (
368368
str_starts_with($contents, '<html><head><meta http-equiv="refresh" content="0;')
369-
&& strpos(strtolower($_SERVER['HTTP_USER_AGENT'] ?? ''), 'webkit') !== false
369+
&& str_contains(strtolower($_SERVER['HTTP_USER_AGENT'] ?? ''), 'webkit')
370370
) {
371371
$this->debugBar->stackData();
372372

@@ -688,13 +688,13 @@ public function onBeforeRespond(BeforeRespondEvent $event): void
688688
}
689689

690690
// Collect the module render time
691-
if (strpos($mark->label, 'mod_') !== false) {
691+
if (str_contains($mark->label, 'mod_')) {
692692
$moduleTime += $mark->time;
693693
continue;
694694
}
695695

696696
// Collect the access render time
697-
if (strpos($mark->label, 'Access:') !== false) {
697+
if (str_contains($mark->label, 'Access:')) {
698698
$accessTime += $mark->time;
699699
continue;
700700
}

plugins/system/httpheaders/src/Extension/Httpheaders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private function setCspHeader(): void
327327
if (
328328
$strictDynamicEnabled
329329
&& $cspValue->directive === 'script-src'
330-
&& strpos($cspValue->value, 'strict-dynamic') === false
330+
&& !str_contains($cspValue->value, 'strict-dynamic')
331331
) {
332332
$cspValue->value = "'strict-dynamic' " . $cspValue->value;
333333
}

plugins/system/languagefilter/src/Extension/LanguageFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ public function parseRule(&$router, &$uri)
514514
$language_new = $this->languageFactory->createLanguage($lang_code, (bool) $app->get('debug_lang'));
515515

516516
foreach ($language->getPaths() as $extension => $files) {
517-
if (strpos($extension, 'plg_system') !== false) {
517+
if (str_contains($extension, 'plg_system')) {
518518
$extension_name = substr($extension, 11);
519519

520520
$language_new->load($extension, JPATH_ADMINISTRATOR)

0 commit comments

Comments
 (0)