Remove unneeded usage of `mb_strpos`
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 12 May 2022 12:39:24 +0000 (14:39 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 12 May 2022 13:17:46 +0000 (15:17 +0200)
If the return value of `mb_strpos` is only compared to `false` then there is no
need to use the multibyte engine, instead `str_contains()` does example the
same and is clearer.

The same applies if the return value is compared to `0`, in this case the size
of multibyte characters cannot have affected the offset. `str_starts_with()`
can be used instead.

31 files changed:
wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php
wcfsetup/install/files/lib/acp/page/ExceptionLogViewPage.class.php
wcfsetup/install/files/lib/data/option/Option.class.php
wcfsetup/install/files/lib/data/package/Package.class.php
wcfsetup/install/files/lib/page/AbstractPage.class.php
wcfsetup/install/files/lib/page/MembersListPage.class.php
wcfsetup/install/files/lib/system/WCFSetup.class.php
wcfsetup/install/files/lib/system/bbcode/SimpleMessageParser.class.php
wcfsetup/install/files/lib/system/bbcode/highlighter/PhpHighlighter.class.php
wcfsetup/install/files/lib/system/condition/UserEmailCondition.class.php
wcfsetup/install/files/lib/system/condition/UserUsernameCondition.class.php
wcfsetup/install/files/lib/system/exception/ValidateActionException.class.php
wcfsetup/install/files/lib/system/form/FormDocument.class.php
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php
wcfsetup/install/files/lib/system/html/metacode/converter/CodeMetacodeConverter.class.php
wcfsetup/install/files/lib/system/html/metacode/converter/ListMetacodeConverter.class.php
wcfsetup/install/files/lib/system/html/metacode/converter/UrlMetacodeConverter.class.php
wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodePre.class.php
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabQuote.class.php
wcfsetup/install/files/lib/system/message/censorship/Censorship.class.php
wcfsetup/install/files/lib/system/option/RadioButtonOptionType.class.php
wcfsetup/install/files/lib/system/option/user/SelectOptionsUserOptionOutput.class.php
wcfsetup/install/files/lib/system/setup/Installer.class.php
wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php
wcfsetup/install/files/lib/util/CronjobUtil.class.php
wcfsetup/install/files/lib/util/HeaderUtil.class.php
wcfsetup/install/files/lib/util/OptionUtil.class.php
wcfsetup/install/files/lib/util/StringStack.class.php
wcfsetup/install/files/lib/util/StringUtil.class.php
wcfsetup/install/files/lib/util/Url.class.php

index a8504c2749477e23e1ff846b5f6c840a6dcbce83..bad0f90a4451e97e6877299901521f12611d5d2d 100755 (executable)
@@ -154,7 +154,7 @@ class UserGroupAddForm extends AbstractOptionListForm
                     throw new UserInputException('groupName', 'multilingual');
                 }
             }
-            if (\mb_strpos($this->userOnlineMarking, '%s') === false) {
+            if (!\str_contains($this->userOnlineMarking, '%s')) {
                 throw new UserInputException('userOnlineMarking', 'invalid');
             }
         } catch (UserInputException $e) {
index 5cf1bec9e9dd29c3320537b33fb986f3f0171824..23f731cb47b1e040b3144640f76c092ae5c6870f 100644 (file)
@@ -110,7 +110,7 @@ class ExceptionLogViewPage extends MultipleLinkPage
             foreach ($this->logFiles as $logFile) {
                 $contents = \file_get_contents($logFile);
 
-                if (\mb_strpos($contents, '<<<<<<<<' . $this->exceptionID . '<<<<') !== false) {
+                if (\str_contains($contents, '<<<<<<<<' . $this->exceptionID . '<<<<')) {
                     $fileNameRegex->match($logFile);
                     $matches = $fileNameRegex->getMatches();
                     $this->logFile = $matches[0];
index fb1a2b1c0ddb3b4f49e755538974642c0865e2ef..f69c6901a480d376b124a434742cfd8273750b13 100644 (file)
@@ -150,7 +150,7 @@ class Option extends DatabaseObject
         $options = \explode("\n", StringUtil::trim(StringUtil::unifyNewlines($this->selectOptions)));
         foreach ($options as $option) {
             $key = $value = $option;
-            if (\mb_strpos($option, ':') !== false) {
+            if (\str_contains($option, ':')) {
                 $optionData = \explode(':', $option);
                 $key = \array_shift($optionData);
                 $value = \implode(':', $optionData);
@@ -174,7 +174,7 @@ class Option extends DatabaseObject
             $options = \explode("\n", StringUtil::trim(StringUtil::unifyNewlines($this->enableOptions)));
             $key = -1;
             foreach ($options as $option) {
-                if (\mb_strpos($option, ':') !== false) {
+                if (\str_contains($option, ':')) {
                     $optionData = \explode(':', $option);
                     $key = \array_shift($optionData);
                     $value = \implode(':', $optionData);
index 0404eec5f5251d5ace46ecc3a15dc4c6a7f444d2..4d07311c3c80586bff506a70adaeb3a5771b8be5 100644 (file)
@@ -386,7 +386,7 @@ class Package extends DatabaseObject implements ILinkableObject, IRouteControlle
      */
     public static function checkFromversion($currentVersion, $fromVersion)
     {
-        if (\mb_strpos($fromVersion, '*') !== false) {
+        if (\str_contains($fromVersion, '*')) {
             // from version with wildcard
             // use regular expression
             $fromVersion = \str_replace('\*', '.*', \preg_quote($fromVersion, '!'));
index a54f8724eac37fecc235c8cba9516bd12e773bf0..c9d7fdb2ab485b21f353838c50e8582f58805db7 100644 (file)
@@ -332,10 +332,8 @@ abstract class AbstractPage implements IPage
                     }
 
                     if (!empty($rQueryString)) {
-                        $redirectURL .= (\mb_strpos(
-                            $redirectURL,
-                            '?'
-                        ) === false ? '?' : '&') . \http_build_query($rQueryString, '', '&');
+                        $redirectURL .= !\str_contains($redirectURL, '?') ? '?' : '&';
+                        $redirectURL .= \http_build_query($rQueryString, '', '&');
                     }
                 }
 
index 973d4e3bf3885d111d87b250343bd63dc945c371..ee6fda934998ff5416032519bb298393f1b09e84 100644 (file)
@@ -91,10 +91,9 @@ class MembersListPage extends SortablePage
 
         // letter
         if (
-            isset($_REQUEST['letter']) && \mb_strlen($_REQUEST['letter']) == 1 && \mb_strpos(
-                self::$availableLetters,
-                $_REQUEST['letter']
-            ) !== false
+            isset($_REQUEST['letter'])
+            && \mb_strlen($_REQUEST['letter']) == 1
+            && \str_contains(self::$availableLetters, $_REQUEST['letter'])
         ) {
             $this->letter = $_REQUEST['letter'];
         }
index f34ba175d5dabd207b1509362dbb3bd259f53971..261341cd378f426243182b74179cd8eeae30813a 100644 (file)
@@ -600,7 +600,7 @@ class WCFSetup extends WCF
             $relativePath = FileUtil::getRelativePath($documentRoot, INSTALL_SCRIPT_DIR);
             foreach ($packages as $application => $packageData) {
                 $dir = $relativePath . ($application === 'wcf' ? '' : $packageData['directory'] . '/');
-                if (\mb_strpos($dir, './') === 0) {
+                if (\str_starts_with($dir, './')) {
                     $dir = \mb_substr($dir, 1);
                 }
 
@@ -1174,7 +1174,7 @@ class WCFSetup extends WCF
         $otherPackages = [];
         $tar = new Tar(SETUP_FILE);
         foreach ($tar->getContentList() as $file) {
-            if ($file['type'] != 'folder' && \mb_strpos($file['filename'], 'install/packages/') === 0) {
+            if ($file['type'] != 'folder' && \str_starts_with($file['filename'], 'install/packages/')) {
                 $packageFile = \basename($file['filename']);
 
                 // ignore any files which aren't an archive
@@ -1393,7 +1393,7 @@ class WCFSetup extends WCF
         $packageNames = [];
         $tar = new Tar(SETUP_FILE);
         foreach ($tar->getContentList() as $file) {
-            if ($file['type'] != 'folder' && \mb_strpos($file['filename'], 'install/packages/') === 0) {
+            if ($file['type'] != 'folder' && \str_starts_with($file['filename'], 'install/packages/')) {
                 $packageFile = \basename($file['filename']);
 
                 try {
index 27e4c46af5901c9eb32e29c07b4534978e9661fa..0e9d7348e933f4f6fc85cfd149d5828e2ef8fa58 100644 (file)
@@ -163,7 +163,7 @@ class SimpleMessageParser extends SingletonFactory
         $text = \preg_replace_callback($urlPattern, [$this, 'cacheURLsCallback'], $text);
 
         // parse emails
-        if (\mb_strpos($text, '@') !== false) {
+        if (\str_contains($text, '@')) {
             $text = \preg_replace_callback($emailPattern, [$this, 'cacheEmailsCallback'], $text);
         }
 
index 825507b554ef1275411c28abaff92d5e436a11b1..2b23f16764e829caaa541d06c5d6c71d00a6bfb7 100644 (file)
@@ -44,7 +44,7 @@ class PhpHighlighter extends Highlighter
     {
         // add starting php tag
         $phpTagsAdded = false;
-        if (\mb_strpos($string, '<?') === false) {
+        if (!\str_contains($string, '<?')) {
             $phpTagsAdded = true;
             $string = '<?php ' . $string . ' ?>';
         }
index b8d81fdb800ee46806e6e50e36c8cadc02682309..c8e301cb6cc6803ff354c888af8424f16dce6aa8 100644 (file)
@@ -54,7 +54,7 @@ class UserEmailCondition extends AbstractTextCondition implements
      */
     public function checkUser(Condition $condition, User $user)
     {
-        return \mb_strpos($user->email, $condition->email) !== false;
+        return \str_contains($user->email, $condition->email);
     }
 
     /**
index 7322eec9265a52e60f322b72029f3d4442523cd5..6af30006b37ed05723ef4ef72af5b3445e4f3344 100644 (file)
@@ -54,7 +54,7 @@ class UserUsernameCondition extends AbstractTextCondition implements
      */
     public function checkUser(Condition $condition, User $user)
     {
-        return \mb_strpos($user->username, $condition->username) !== false;
+        return \str_contains($user->username, $condition->username);
     }
 
     /**
index 343a3be64b3e2de82fe1e830113879d719201965..1564cf33617bfa225eaad6da0940b81d6b3ae529 100644 (file)
@@ -32,7 +32,7 @@ class ValidateActionException extends \Exception
     public function __construct($fieldName, $errorMessage = 'empty', array $variables = [])
     {
         $this->errorMessage = $errorMessage;
-        if (\mb_strpos($this->errorMessage, '.') === false) {
+        if (!\str_contains($this->errorMessage, '.')) {
             if (\preg_match('~^[a-zA-Z0-9-_]+$~', $this->errorMessage)) {
                 $this->errorMessage = WCF::getLanguage()
                     ->getDynamicVariable('wcf.global.form.error.' . $this->errorMessage);
index d5a72b399d02ddf35f5b839613e47861c151451f..53bebf52acd5c4a04841afac61f49366119ce521 100644 (file)
@@ -116,7 +116,7 @@ class FormDocument
         $variables = [];
 
         foreach ($_REQUEST as $key => $value) {
-            if (\mb_strpos($key, $this->getName() . '_') !== false) {
+            if (\str_contains($key, $this->getName() . '_')) {
                 $key = \str_replace($this->getName() . '_', '', $key);
                 $variables[$key] = $value;
             }
index c9569094be7ecbe6b582a73a5e295a5046e020db..4858c6eaa834facbd7b94d122c38118a8e4c3bb1 100644 (file)
@@ -235,7 +235,7 @@ class HtmlInputNodeTextParser
      */
     protected function detectMention(\DOMText $text, $value, array &$usernames)
     {
-        if (\mb_strpos($value, '@') === false) {
+        if (!\str_contains($value, '@')) {
             return;
         }
 
@@ -271,7 +271,7 @@ class HtmlInputNodeTextParser
         $exactValues = [];
         $likeValues = [];
         foreach ($usernames as $username) {
-            if (\mb_strpos($username, ' ') !== false) {
+            if (\str_contains($username, ' ')) {
                 // string contains a whitespace, account for names that
                 // are built up with more than two words
                 $likeValues[] = $username;
@@ -365,7 +365,7 @@ class HtmlInputNodeTextParser
      */
     protected function parseMention(\DOMText $text, $value, array $users, array $groups)
     {
-        if (\mb_strpos($value, '@') === false) {
+        if (!\str_contains($value, '@')) {
             return $value;
         }
 
@@ -475,7 +475,7 @@ class HtmlInputNodeTextParser
      */
     protected function parseEmail(\DOMText $text, $value)
     {
-        if (\mb_strpos($value, '@') === false) {
+        if (!\str_contains($value, '@')) {
             return $value;
         }
 
index a2fd53dab283e72a43b7eacea2ce70543ec9df70..faa22b6013b7ad5291a627e09a1f25b6b127a3c6 100644 (file)
@@ -33,7 +33,7 @@ class CodeMetacodeConverter extends AbstractMetacodeConverter
             case 1:
                 if (\is_numeric($attributes[0])) {
                     $line = \intval($attributes[0]);
-                } elseif (\mb_strpos($attributes[0], '.') === false) {
+                } elseif (!\str_contains($attributes[0], '.')) {
                     $highlighter = $attributes[0];
                 } else {
                     $file = $attributes[0];
@@ -43,7 +43,7 @@ class CodeMetacodeConverter extends AbstractMetacodeConverter
             case 2:
                 if (\is_numeric($attributes[0])) {
                     $line = \intval($attributes[0]);
-                    if (\mb_strpos($attributes[1], '.') === false) {
+                    if (!\str_contains($attributes[1], '.')) {
                         $highlighter = $attributes[1];
                     } else {
                         $file = $attributes[1];
@@ -76,7 +76,7 @@ class CodeMetacodeConverter extends AbstractMetacodeConverter
         $replaceNodes = [];
         /** @var \DOMText $textNode */
         foreach ($xpath->query('.//text()', $element) as $textNode) {
-            if (\mb_strpos($textNode->textContent, "\n") !== false) {
+            if (\str_contains($textNode->textContent, "\n")) {
                 $replaceNodes[] = $textNode;
             }
         }
index 9b3a590dbc431a6c4c653270f087a676285ab9aa..a2b1794a4362c8d7ca881258cc07c22e726a3c3f 100644 (file)
@@ -35,7 +35,7 @@ class ListMetacodeConverter extends AbstractMetacodeConverter
         $xpath = new \DOMXPath($element->ownerDocument);
         /** @var \DOMText $node */
         foreach ($xpath->query('.//text()', $element) as $node) {
-            if (\mb_strpos($node->textContent, '[*]') !== false && !$this->isInsideList($node)) {
+            if (\str_contains($node->textContent, '[*]') && !$this->isInsideList($node)) {
                 $nodes[] = $node;
             }
         }
index 399dc358df27cc4ec66765df5c59f0e4d805275c..bb2da55cf500a6681a30ab02b8cc58a7f9425e62 100644 (file)
@@ -34,7 +34,7 @@ class UrlMetacodeConverter extends AbstractMetacodeConverter
         }
 
         $href = StringUtil::decodeHTML($href);
-        if (\mb_strpos($href, '//') === 0) {
+        if (\str_starts_with($href, '//')) {
             // dynamic protocol, treat as https
             $href = "https:{$href}";
         } elseif (\preg_match('~^(?P<schema>[a-z0-9]+)://~', $href, $match)) {
@@ -42,7 +42,7 @@ class UrlMetacodeConverter extends AbstractMetacodeConverter
                 // invalid schema, replace it with `http`
                 $href = 'http' . \mb_substr($href, \strlen($match['schema']));
             }
-        } elseif (\mb_strpos($href, 'index.php') === false) {
+        } elseif (!\str_contains($href, 'index.php')) {
             // unless it's a relative `index.php` link, assume it is missing the protocol
             $href = "http://{$href}";
         }
index 93d263ab4c95418f786a89da50d7ea1f48df4148..3e6de9d8f237fd4005f521950436b2acbf3f77cc 100644 (file)
@@ -95,7 +95,7 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor
             foreach ($pre->childNodes as $node) {
                 if (
                     $node->nodeType === \XML_TEXT_NODE
-                    && \mb_strpos($node->textContent, '@@@WCF_PRE_LINEBREAK@@@') !== false
+                    && \str_contains($node->textContent, '@@@WCF_PRE_LINEBREAK@@@')
                 ) {
                     $node->nodeValue = \str_replace('@@@WCF_PRE_LINEBREAK@@@', "\n", $node->textContent);
                 }
@@ -126,16 +126,14 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor
                     $string = $obj->replaceTag($data['data']);
 
                     if (!isset($data['data']['skipInnerContent']) || $data['data']['skipInnerContent'] !== true) {
-                        if (\mb_strpos($string, '<!-- META_CODE_INNER_CONTENT -->') !== false) {
+                        if (\str_contains($string, '<!-- META_CODE_INNER_CONTENT -->')) {
                             return \str_replace('<!-- META_CODE_INNER_CONTENT -->', $matches['content'], $string);
-                        } else {
-                            if (\mb_strpos($string, '&lt;!-- META_CODE_INNER_CONTENT --&gt;') !== false) {
-                                return \str_replace(
-                                    '&lt;!-- META_CODE_INNER_CONTENT --&gt;',
-                                    $matches['content'],
-                                    $string
-                                );
-                            }
+                        } elseif (\str_contains($string, '&lt;!-- META_CODE_INNER_CONTENT --&gt;')) {
+                            return \str_replace(
+                                '&lt;!-- META_CODE_INNER_CONTENT --&gt;',
+                                $matches['content'],
+                                $string
+                            );
                         }
                     }
 
index b2018b9a016a0622a1a9080637d529279958cf94..59739455f4a10ae868e72c00a7ad0e3744866463 100644 (file)
@@ -166,45 +166,45 @@ class HtmlOutputNodePre extends AbstractHtmlOutputNode
     public function guessHighlighter($content)
     {
         // PHP at the beginning is almost surely PHP.
-        if (\mb_strpos($content, '<?php') === 0) {
+        if (\str_starts_with($content, '<?php')) {
             return 'php';
         }
 
         if (
-            \mb_strpos($content, 'SELECT') === 0
-            || \mb_strpos($content, 'UPDATE') === 0
-            || \mb_strpos($content, 'INSERT') === 0
-            || \mb_strpos($content, 'DELETE') === 0
+            \str_starts_with($content, 'SELECT')
+            || \str_starts_with($content, 'UPDATE')
+            || \str_starts_with($content, 'INSERT')
+            || \str_starts_with($content, 'DELETE')
         ) {
             return 'sql';
         }
 
-        if (\mb_strpos($content, 'import java.') !== false) {
+        if (\str_contains($content, 'import java.')) {
             return 'java';
         }
 
-        if (\mb_strpos($content, 'using System;') !== false) {
+        if (\str_contains($content, 'using System;')) {
             return 'csharp';
         }
 
         if (
-            \mb_strpos($content, "---") !== false
-            && \mb_strpos($content, "\n+++") !== false
+            \str_contains($content, "---")
+            && \str_contains($content, "\n+++")
         ) {
             return 'diff';
         }
 
-        if (\mb_strpos($content, "\n#include ") !== false) {
+        if (\str_contains($content, "\n#include ")) {
             return 'c';
         }
 
-        if (\mb_strpos($content, '#!/usr/bin/perl') === 0) {
+        if (\str_starts_with($content, '#!/usr/bin/perl')) {
             return 'perl';
         }
 
         if (
-            \mb_strpos($content, '#!/usr/bin/python') === 0
-            || \mb_strpos($content, 'def __init__(self') !== false
+            \str_starts_with($content, '#!/usr/bin/python')
+            || \str_contains($content, 'def __init__(self')
             || Regex::compile("from (\\S+) import (\\S+)")->match($content)
         ) {
             return 'python';
@@ -215,51 +215,53 @@ class HtmlOutputNodePre extends AbstractHtmlOutputNode
         }
 
         if (
-            \mb_strpos($content, 'FROM') === 0
-            && \mb_strpos($content, "RUN") !== false
+            \str_starts_with($content, 'FROM')
+            && \str_contains($content, "RUN")
         ) {
             return 'docker';
         }
 
         if (
-            \mb_stripos($content, "RewriteRule") !== false
-            || \mb_stripos($content, "RewriteEngine On") !== false
-            || \mb_stripos($content, "AuthUserFile") !== false
+            \stripos($content, "RewriteRule") !== false
+            || \stripos($content, "RewriteEngine On") !== false
+            || \stripos($content, "AuthUserFile") !== false
         ) {
             return 'apacheconf';
         }
 
-        if (\mb_strpos($content, '\\documentclass') !== false) {
+        if (\str_contains($content, '\\documentclass')) {
             return 'latex';
         }
 
         // PHP somewhere later might not necessarily be PHP, it could also be
         // a .patch or a Dockerfile.
-        if (\mb_strpos($content, '<?php') !== false) {
+        if (\str_contains($content, '<?php')) {
             return 'php';
         }
 
         if (
-            \mb_strpos($content, '{/if}') !== false
-            && (\mb_strpos($content, '<div') !== false
-                || \mb_strpos($content, '<span') !== false)
+            \str_contains($content, '{/if}')
+            && (
+                \str_contains($content, '<div')
+                || \str_contains($content, '<span')
+            )
         ) {
             return 'smarty';
         }
 
-        if (\mb_strpos($content, '<html') !== false) {
+        if (\str_contains($content, '<html')) {
             return 'html';
         }
 
-        if (\mb_strpos($content, '<?xml') === 0) {
+        if (\str_starts_with($content, '<?xml')) {
             return 'xml';
         }
 
-        if (\mb_strpos($content, '@mixin') !== false) {
+        if (\str_contains($content, '@mixin')) {
             return 'scss';
         }
 
-        if (\mb_strpos($content, '!important;') !== false) {
+        if (\str_contains($content, '!important;')) {
             return 'css';
         }
 
index ba1d7d2f819980b6089f769ae6e90c40ac437391..f2ab97addb9285fc448a2f84407e0e82978ebd09 100644 (file)
@@ -46,7 +46,7 @@ class HtmlOutputNodeWoltlabQuote extends AbstractHtmlOutputNode
                     }
 
                     $link = $element->getAttribute('data-link');
-                    if (\mb_strpos($link, 'index.php') === 0) {
+                    if (\str_starts_with($link, 'index.php')) {
                         $link = WCF::getPath() . $link;
                     }
 
index 0a7db54ee184dd97a7c1c7e42ac08624a263d0c9..8d7ae7769e075acb6236ba47a1d884765d6737da 100644 (file)
@@ -101,7 +101,7 @@ class Censorship extends SingletonFactory
 
                     continue 2;
                 } // check for asterisk matches ("*badword*" == "FooBadwordBar")
-                elseif (\mb_strpos($censoredWord, '*') !== false) {
+                elseif (\str_contains($censoredWord, '*')) {
                     $censoredWord = \str_replace('\*', '.*', \preg_quote($censoredWord, '!'));
                     if (\preg_match('!^' . $censoredWord . '$!', $word)) {
                         // store censored word
@@ -114,7 +114,7 @@ class Censorship extends SingletonFactory
                         continue 2;
                     }
                 } // check for partial matches ("~badword~" == "bad-word")
-                elseif (\mb_strpos($censoredWord, '~') !== false) {
+                elseif (\str_contains($censoredWord, '~')) {
                     $censoredWord = \str_replace('~', '', $censoredWord);
                     if (($position = \mb_strpos($censoredWord, $word)) !== false) {
                         if ($position > 0) {
@@ -203,9 +203,9 @@ class Censorship extends SingletonFactory
     protected function lookAhead($index, $search)
     {
         if (isset($this->words[$index])) {
-            if (\mb_strpos($this->words[$index], $search) === 0) {
+            if (\str_starts_with($this->words[$index], $search)) {
                 return $index;
-            } elseif (\mb_strpos($search, $this->words[$index]) === 0) {
+            } elseif (\str_starts_with($search, $this->words[$index])) {
                 return $this->lookAhead($index + 1, \mb_substr($search, \mb_strlen($this->words[$index])));
             }
         }
index ad3ca48c38dc9b0d137d61a7ebb945504f3e67c1..2413c7c04e165ad6935cef1c5256e6928bcc9e73 100644 (file)
@@ -166,7 +166,7 @@ class RadioButtonOptionType extends AbstractOptionType implements
 
         $i = 0;
         foreach ($valueToOptions as $valueToOption) {
-            if (\mb_strpos($valueToOption, ':') !== false) {
+            if (\str_contains($valueToOption, ':')) {
                 $optionData = \explode(':', $valueToOption);
                 $key = \array_shift($optionData);
                 $enableOptionValues = \implode(':', $optionData);
index 3fa9c72474f99693fa4f66dfee584b2502c977f0..28ab623935e6b51114f53c4d4efeea4bd6b6ef3e 100644 (file)
@@ -52,7 +52,7 @@ class SelectOptionsUserOptionOutput implements IUserOptionOutput
         $options = OptionUtil::parseSelectOptions($option->selectOptions);
 
         // multiselect
-        if (\mb_strpos($value, "\n") !== false) {
+        if (\str_contains($value, "\n")) {
             $values = \explode("\n", $value);
             $result = [];
             foreach ($values as $value) {
index 8ea3ced329cad4a9855e087e901f79c80328e05f..55c585b509a711d29dfc7bca392520d88e156749 100644 (file)
@@ -133,7 +133,7 @@ class Installer
         $directories = [];
         $files = [];
         foreach ($tar->getContentList() as $index => $file) {
-            if (empty($this->folder) || \mb_strpos($file['filename'], $this->folder) === 0) {
+            if (empty($this->folder) || \str_starts_with($file['filename'], $this->folder)) {
                 if (!empty($this->folder)) {
                     $file['filename'] = \str_replace($this->folder, '', $file['filename']);
                 }
index 42f0fb5b53d12b54544cf1a4deea8f209331d210..19820f4e0153cc564aa325271fbcf6646242e0cb 100644 (file)
@@ -1190,12 +1190,12 @@ class TemplateScriptingCompiler
 
             // reinserts strings
             foreach (StringStack::getStack('singleQuote') as $hash => $value) {
-                if (\mb_strpos($string, $hash) !== false) {
+                if (\str_contains($string, $hash)) {
                     $string = \str_replace($hash, $value, $string);
                 }
             }
             foreach (StringStack::getStack('doubleQuote') as $hash => $value) {
-                if (\mb_strpos($string, $hash) !== false) {
+                if (\str_contains($string, $hash)) {
                     $string = \str_replace($hash, $value, $string);
                 }
             }
@@ -2194,7 +2194,7 @@ class TemplateScriptingCompiler
      */
     public function replacePHPTags($string)
     {
-        if (\mb_strpos($string, '<?') !== false) {
+        if (\str_contains($string, '<?')) {
             $string = \str_replace('<?php', '@@PHP_START_TAG@@', $string);
             $string = \str_replace('<?', '@@PHP_SHORT_START_TAG@@', $string);
             $string = \str_replace('?>', '@@PHP_END_TAG@@', $string);
index a76875f67b132c4284ee6c570d8fcdb6efcafe9e..986d5994c42d3a77b0f03a498d5b2e1e54cbabc2 100644 (file)
@@ -460,7 +460,7 @@ final class CronjobUtil
         elseif ($char == '*') {
             $step = 1;
 
-            if (\mb_strpos($fieldValue, '/') !== false) {
+            if (\str_contains($fieldValue, '/')) {
                 $rangeData = \explode('/', $fieldValue);
                 $step = $rangeData[1];
             }
@@ -481,7 +481,7 @@ final class CronjobUtil
      */
     protected static function getListItems($fieldValue)
     {
-        if (\mb_strpos($fieldValue, ',') !== false) {
+        if (\str_contains($fieldValue, ',')) {
             return \explode(',', $fieldValue);
         }
 
@@ -497,12 +497,12 @@ final class CronjobUtil
     protected static function getRanges($value)
     {
         // this is a single value
-        if (\mb_strpos($value, '-') === false) {
+        if (!\str_contains($value, '-')) {
             return [$value];
         }
 
         $step = 1;
-        if (\mb_strpos($value, '/') !== false) {
+        if (\str_contains($value, '/')) {
             $data = \explode('/', $value);
             $step = $data[1];
             $value = $data[0];
index 2197eedc5c0a52cec9f6decef2521ce236071fef..8f4c34d4209d89e722325f389d1930c7db4b0326 100644 (file)
@@ -62,10 +62,10 @@ final class HeaderUtil
     public static function getCookieDomain(): ?string
     {
         $application = ApplicationHandler::getInstance()->getActiveApplication();
-        $addDomain = (\mb_strpos(
+        $addDomain = (!\str_contains(
             $application->cookieDomain,
             '.'
-        ) === false || \str_ends_with(
+        ) || \str_ends_with(
             $application->cookieDomain,
             '.lan'
         ) || \str_ends_with($application->cookieDomain, '.local')) ? false : true;
index 7d30e22b2b6959feb9cd891249a6b12b33d5fb91..fc30adcedfb716f6c024b54e18dd66405ecb4d2f 100644 (file)
@@ -24,7 +24,7 @@ final class OptionUtil
         $options = \explode("\n", StringUtil::trim(StringUtil::unifyNewlines($selectOptions)));
         foreach ($options as $option) {
             $key = $value = $option;
-            if (\mb_strpos($option, ':') !== false) {
+            if (\str_contains($option, ':')) {
                 $optionData = \explode(':', $option);
                 $key = \array_shift($optionData);
                 $value = \implode(':', $optionData);
@@ -49,7 +49,7 @@ final class OptionUtil
             $options = \explode("\n", StringUtil::trim(StringUtil::unifyNewlines($enableOptions)));
             $key = -1;
             foreach ($options as $option) {
-                if (\mb_strpos($option, ':') !== false) {
+                if (\str_contains($option, ':')) {
                     $optionData = \explode(':', $option);
                     $key = \array_shift($optionData);
                     $value = \implode(':', $optionData);
index 0df71cdb92de22210227f91f4e50606b6d9e521c..1c725d7463b4a0fa652d234bcb5bc6a943d6b758 100644 (file)
@@ -57,7 +57,7 @@ final class StringStack
     {
         if (isset(self::$stringStack[$type])) {
             foreach (self::$stringStack[$type] as $hash => $value) {
-                if (\mb_strpos($string, $hash) !== false) {
+                if (\str_contains($string, $hash)) {
                     $string = \str_replace($hash, $value, $string);
                     unset(self::$stringStack[$type][$hash]);
                 }
index d7636bd2b9ffaa939513c33f513378d069912303..dc981c3dff4f4ec3f9aeb42a23821c6333eab6e6 100644 (file)
@@ -577,7 +577,7 @@ final class StringUtil
                     continue;
                 }
 
-                if (\mb_strpos($forbiddenName, '*') !== false) {
+                if (\str_contains($forbiddenName, '*')) {
                     $forbiddenName = \str_replace('\*', '.*', \preg_quote($forbiddenName, '/'));
                     if (\preg_match('/^' . $forbiddenName . '$/s', $word)) {
                         return false;
index e24ed95fba21de08bc1320d05d3c87c9aa15be6f..a1bb0d241991ee2b20a93267952d7f2ac97cc57d 100644 (file)
@@ -180,9 +180,9 @@ final class Url implements \ArrayAccess
         $hosts = [];
         foreach ($hostnames as $host) {
             $isWildcard = false;
-            if (\mb_strpos($host, '*') !== false) {
+            if (\str_contains($host, '*')) {
                 $host = \preg_replace('~^(\*\.)+~', '', $host);
-                if (\mb_strpos($host, '*') !== false || $host === '') {
+                if (\str_contains($host, '*') || $host === '') {
                     // bad host
                     continue;
                 }
@@ -205,7 +205,7 @@ final class Url implements \ArrayAccess
             } else {
                 // check wildcard hosts
                 foreach ($hosts as $host => $isWildcard) {
-                    if ($isWildcard && \mb_strpos($hostname, $host) !== false) {
+                    if ($isWildcard && \str_contains($hostname, $host)) {
                         // the prepended dot will ensure that `example.com` matches only
                         // on domains like `foo.example.com` but not on `bar-example.com`
                         if (\str_ends_with($hostname, '.' . $host)) {