diff --git a/libraries/src/Application/WebApplication.php b/libraries/src/Application/WebApplication.php index c1099afc01d09..bbe24c82d2d5e 100644 --- a/libraries/src/Application/WebApplication.php +++ b/libraries/src/Application/WebApplication.php @@ -408,7 +408,7 @@ protected function loadSystemUris($requestUri = null) $uri = Uri::getInstance($this->get('uri.request')); // If we are working from a CGI SAPI with the 'cgi.fix_pathinfo' directive disabled we use PHP_SELF. - if (strpos(PHP_SAPI, 'cgi') !== false && !\ini_get('cgi.fix_pathinfo') && !empty($_SERVER['REQUEST_URI'])) { + if (str_contains(PHP_SAPI, 'cgi') && !\ini_get('cgi.fix_pathinfo') && !empty($_SERVER['REQUEST_URI'])) { // We aren't expecting PATH_INFO within PHP_SELF so this should work. $path = \dirname($_SERVER['PHP_SELF']); } else { @@ -420,7 +420,7 @@ protected function loadSystemUris($requestUri = null) $host = $uri->toString(['scheme', 'user', 'pass', 'host', 'port']); // Check if the path includes "index.php". - if (strpos($path, 'index.php') !== false) { + if (str_contains($path, 'index.php')) { // Remove the index.php portion of the path. $path = substr_replace($path, '', strpos($path, 'index.php'), 9); } @@ -441,7 +441,7 @@ protected function loadSystemUris($requestUri = null) $mediaURI = trim($this->get('media_uri', '')); if ($mediaURI) { - if (strpos($mediaURI, '://') !== false) { + if (str_contains($mediaURI, '://')) { $this->set('uri.media.full', $mediaURI); $this->set('uri.media.path', $mediaURI); } else { diff --git a/libraries/src/Authentication/Password/MD5Handler.php b/libraries/src/Authentication/Password/MD5Handler.php index ff600cd0cc6b0..8719b5a719675 100644 --- a/libraries/src/Authentication/Password/MD5Handler.php +++ b/libraries/src/Authentication/Password/MD5Handler.php @@ -89,7 +89,7 @@ public function validatePassword($plaintext, $hashed) // Compile the hash to compare // If the salt is empty AND there is a ':' in the original hash, we must append ':' at the end - $testcrypt = md5($plaintext . $salt) . ($salt ? ':' . $salt : (strpos($hashed, ':') !== false ? ':' : '')); + $testcrypt = md5($plaintext . $salt) . ($salt ? ':' . $salt : (str_contains($hashed, ':') ? ':' : '')); return Crypt::timingSafeCompare($hashed, $testcrypt); } diff --git a/libraries/src/Client/FtpClient.php b/libraries/src/Client/FtpClient.php index 5adb2992b7906..fb94d9b95f269 100644 --- a/libraries/src/Client/FtpClient.php +++ b/libraries/src/Client/FtpClient.php @@ -479,9 +479,9 @@ public function syst() } // Match the system string to an OS - if (strpos(strtoupper($ret), 'MAC') !== false) { + if (str_contains(strtoupper($ret), 'MAC')) { $ret = 'MAC'; - } elseif (strpos(strtoupper($ret), 'WIN') !== false) { + } elseif (str_contains(strtoupper($ret), 'WIN')) { $ret = 'WIN'; } else { $ret = 'UNIX'; diff --git a/libraries/src/Console/SetConfigurationCommand.php b/libraries/src/Console/SetConfigurationCommand.php index 8692a185f8ec2..b0651581f24f9 100644 --- a/libraries/src/Console/SetConfigurationCommand.php +++ b/libraries/src/Console/SetConfigurationCommand.php @@ -127,7 +127,7 @@ private function retrieveOptionsFromInput(array $options): bool $collected = []; foreach ($options as $option) { - if (strpos($option, '=') === false) { + if (!str_contains($option, '=')) { $this->ioStyle->error('Options and values should be separated by "="'); return false; diff --git a/libraries/src/Date/Date.php b/libraries/src/Date/Date.php index 599439e584a91..ac1321467eeae 100644 --- a/libraries/src/Date/Date.php +++ b/libraries/src/Date/Date.php @@ -312,19 +312,19 @@ public function format($format, $local = false, $translate = true): string if ($translate) { // Manually modify the month and day strings in the formatted time. - if (strpos($return, self::DAY_ABBR) !== false) { + if (str_contains($return, self::DAY_ABBR)) { $return = str_replace(self::DAY_ABBR, $this->dayToString(parent::format('w'), true), $return); } - if (strpos($return, self::DAY_NAME) !== false) { + if (str_contains($return, self::DAY_NAME)) { $return = str_replace(self::DAY_NAME, $this->dayToString(parent::format('w')), $return); } - if (strpos($return, self::MONTH_ABBR) !== false) { + if (str_contains($return, self::MONTH_ABBR)) { $return = str_replace(self::MONTH_ABBR, $this->monthToString(parent::format('n'), true), $return); } - if (strpos($return, self::MONTH_NAME) !== false) { + if (str_contains($return, self::MONTH_NAME)) { $return = str_replace(self::MONTH_NAME, $this->monthToString(parent::format('n')), $return); } } diff --git a/libraries/src/Dispatcher/ComponentDispatcher.php b/libraries/src/Dispatcher/ComponentDispatcher.php index 6e61347d931a4..d36849d7a6f87 100644 --- a/libraries/src/Dispatcher/ComponentDispatcher.php +++ b/libraries/src/Dispatcher/ComponentDispatcher.php @@ -118,7 +118,7 @@ public function dispatch() $command = $this->input->getCmd('task', 'display'); // Check for a controller.task command. - if (strpos($command, '.') !== false) { + if (str_contains($command, '.')) { // Explode the controller.task command. list($controller, $task) = explode('.', $command); diff --git a/libraries/src/Document/Renderer/Feed/RssRenderer.php b/libraries/src/Document/Renderer/Feed/RssRenderer.php index 5522faec5b00a..7b112772794e5 100644 --- a/libraries/src/Document/Renderer/Feed/RssRenderer.php +++ b/libraries/src/Document/Renderer/Feed/RssRenderer.php @@ -173,7 +173,7 @@ public function render($name = '', $params = null, $content = null) $itemlink = implode('/', array_map('rawurlencode', explode('/', $itemlink))); } - if ((strpos($itemlink, 'http://') === false) && (strpos($itemlink, 'https://') === false)) { + if ((!str_contains($itemlink, 'http://')) && (!str_contains($itemlink, 'https://'))) { $itemlink = str_replace(' ', '%20', $url . $itemlink); } diff --git a/libraries/src/Document/Renderer/Html/ScriptsRenderer.php b/libraries/src/Document/Renderer/Html/ScriptsRenderer.php index e329fcf62c3e4..b1819c578dec8 100644 --- a/libraries/src/Document/Renderer/Html/ScriptsRenderer.php +++ b/libraries/src/Document/Renderer/Html/ScriptsRenderer.php @@ -185,7 +185,7 @@ private function renderElement($item): string $this->renderedSrc[$src] = true; // Check if script uses media version. - if ($version && strpos($src, '?') === false && ($mediaVersion || $version !== 'auto')) { + if ($version && !str_contains($src, '?') && ($mediaVersion || $version !== 'auto')) { $src .= '?' . ($version === 'auto' ? $mediaVersion : $version); } diff --git a/libraries/src/Document/Renderer/Html/StylesRenderer.php b/libraries/src/Document/Renderer/Html/StylesRenderer.php index ccf55920e2a1e..45a6aa39a7a4d 100644 --- a/libraries/src/Document/Renderer/Html/StylesRenderer.php +++ b/libraries/src/Document/Renderer/Html/StylesRenderer.php @@ -174,7 +174,7 @@ private function renderElement($item): string $this->renderedSrc[$src] = true; // Check if script uses media version. - if ($version && strpos($src, '?') === false && ($mediaVersion || $version !== 'auto')) { + if ($version && !str_contains($src, '?') && ($mediaVersion || $version !== 'auto')) { $src .= '?' . ($version === 'auto' ? $mediaVersion : $version); } diff --git a/libraries/src/Environment/Browser.php b/libraries/src/Environment/Browser.php index 782dad6af8a60..29133799bbf84 100644 --- a/libraries/src/Environment/Browser.php +++ b/libraries/src/Environment/Browser.php @@ -543,8 +543,8 @@ public function match($userAgent = null, $accept = null) * user agent string, which we can use to look for mobile agents. */ if ( - strpos($this->agent, 'MOT-') !== false - || strpos($this->lowerAgent, 'j-') !== false + str_contains($this->agent, 'MOT-') + || str_contains($this->lowerAgent, 'j-') || preg_match('/(mobileexplorer|openwave|opera mini|opera mobi|operamini|avantgo|wap|elaine)/i', $this->agent) || preg_match('/(iPhone|iPod|iPad|Android|Mobile|Phone|BlackBerry|Xiino|Palmscape|palmsource)/i', $this->agent) || preg_match('/(Nokia|Ericsson|docomo|digital paths|portalmmm|CriOS[\/ ]([0-9.]+))/i', $this->agent) @@ -561,7 +561,7 @@ public function match($userAgent = null, $accept = null) if (preg_match('|Edge\/([0-9.]+)|', $this->agent, $version)) { $this->setBrowser('edge'); - if (strpos($version[1], '.') !== false) { + if (str_contains($version[1], '.')) { list($this->majorVersion, $this->minorVersion) = explode('.', $version[1]); } else { $this->majorVersion = $version[1]; @@ -601,9 +601,9 @@ public function match($userAgent = null, $accept = null) list($this->majorVersion, $this->minorVersion) = explode('.', $version[1]); } elseif ( - strpos($this->lowerAgent, 'elaine/') !== false - || strpos($this->lowerAgent, 'palmsource') !== false - || strpos($this->lowerAgent, 'digital paths') !== false + str_contains($this->lowerAgent, 'elaine/') + || str_contains($this->lowerAgent, 'palmsource') + || str_contains($this->lowerAgent, 'digital paths') ) { $this->setBrowser('palm'); } elseif ( @@ -615,11 +615,11 @@ public function match($userAgent = null, $accept = null) $this->setBrowser('msie'); // Special case for IE 11+ - if (strpos($version[0], 'Trident') !== false && strpos($version[0], 'rv:') !== false) { + if (str_contains($version[0], 'Trident') && str_contains($version[0], 'rv:')) { preg_match('|rv:([0-9.]+)|', $this->agent, $version); } - if (strpos($version[1], '.') !== false) { + if (str_contains($version[1], '.')) { list($this->majorVersion, $this->minorVersion) = explode('.', $version[1]); } else { $this->majorVersion = $version[1]; @@ -634,7 +634,7 @@ public function match($userAgent = null, $accept = null) } } elseif (preg_match('|ANTFresco\/([0-9]+)|', $this->agent, $version)) { $this->setBrowser('fresco'); - } elseif (strpos($this->lowerAgent, 'avantgo') !== false) { + } elseif (str_contains($this->lowerAgent, 'avantgo')) { $this->setBrowser('avantgo'); } elseif (preg_match('|[Kk]onqueror\/([0-9]+)|', $this->agent, $version) || preg_match('|Safari/([0-9]+)\.?([0-9]+)?|', $this->agent, $version)) { // Konqueror and Apple's Safari both use the KHTML rendering engine. @@ -645,7 +645,7 @@ public function match($userAgent = null, $accept = null) $this->minorVersion = $version[2]; } - if (strpos($this->agent, 'Safari') !== false && $this->majorVersion >= 60) { + if (str_contains($this->agent, 'Safari') && $this->majorVersion >= 60) { // Safari. $this->setBrowser('safari'); $this->identifyBrowserVersion(); @@ -660,25 +660,25 @@ public function match($userAgent = null, $accept = null) $this->setBrowser('links'); } elseif (preg_match('|HotJava\/([0-9]+)|', $this->agent, $version)) { $this->setBrowser('hotjava'); - } elseif (strpos($this->agent, 'UP/') !== false || strpos($this->agent, 'UP.B') !== false || strpos($this->agent, 'UP.L') !== false) { + } elseif (str_contains($this->agent, 'UP/') || str_contains($this->agent, 'UP.B') || str_contains($this->agent, 'UP.L')) { $this->setBrowser('up'); - } elseif (strpos($this->agent, 'Xiino/') !== false) { + } elseif (str_contains($this->agent, 'Xiino/')) { $this->setBrowser('xiino'); - } elseif (strpos($this->agent, 'Palmscape/') !== false) { + } elseif (str_contains($this->agent, 'Palmscape/')) { $this->setBrowser('palmscape'); - } elseif (strpos($this->agent, 'Nokia') !== false) { + } elseif (str_contains($this->agent, 'Nokia')) { $this->setBrowser('nokia'); - } elseif (strpos($this->agent, 'Ericsson') !== false) { + } elseif (str_contains($this->agent, 'Ericsson')) { $this->setBrowser('ericsson'); - } elseif (strpos($this->lowerAgent, 'wap') !== false) { + } elseif (str_contains($this->lowerAgent, 'wap')) { $this->setBrowser('wap'); - } elseif (strpos($this->lowerAgent, 'docomo') !== false || strpos($this->lowerAgent, 'portalmmm') !== false) { + } elseif (str_contains($this->lowerAgent, 'docomo') || str_contains($this->lowerAgent, 'portalmmm')) { $this->setBrowser('imode'); - } elseif (strpos($this->agent, 'BlackBerry') !== false) { + } elseif (str_contains($this->agent, 'BlackBerry')) { $this->setBrowser('blackberry'); - } elseif (strpos($this->agent, 'MOT-') !== false) { + } elseif (str_contains($this->agent, 'MOT-')) { $this->setBrowser('motorola'); - } elseif (strpos($this->lowerAgent, 'j-') !== false) { + } elseif (str_contains($this->lowerAgent, 'j-')) { $this->setBrowser('mml'); } elseif (preg_match('|Mozilla\/([0-9.]+)|', $this->agent, $version)) { $this->setBrowser('mozilla'); @@ -701,9 +701,9 @@ public function match($userAgent = null, $accept = null) */ protected function _setPlatform() { - if (strpos($this->lowerAgent, 'wind') !== false) { + if (str_contains($this->lowerAgent, 'wind')) { $this->platform = 'win'; - } elseif (strpos($this->lowerAgent, 'mac') !== false) { + } elseif (str_contains($this->lowerAgent, 'mac')) { $this->platform = 'mac'; } else { $this->platform = 'unix'; @@ -854,11 +854,11 @@ public function isViewable($mimetype) if (!empty($this->accept)) { $wildcard_match = false; - if (strpos($this->accept, $mimetype) !== false) { + if (str_contains($this->accept, $mimetype)) { return true; } - if (strpos($this->accept, '*/*') !== false) { + if (str_contains($this->accept, '*/*')) { $wildcard_match = true; if ($type !== 'image') { @@ -867,7 +867,7 @@ public function isViewable($mimetype) } // Deal with Mozilla pjpeg/jpeg issue - if ($this->isBrowser('mozilla') && ($mimetype === 'image/pjpeg') && (strpos($this->accept, 'image/jpeg') !== false)) { + if ($this->isBrowser('mozilla') && ($mimetype === 'image/pjpeg') && (str_contains($this->accept, 'image/jpeg'))) { return true; } diff --git a/libraries/src/Event/View/DisplayEvent.php b/libraries/src/Event/View/DisplayEvent.php index c7eb61068a079..4b33287928549 100644 --- a/libraries/src/Event/View/DisplayEvent.php +++ b/libraries/src/Event/View/DisplayEvent.php @@ -51,7 +51,7 @@ public function __construct($name, array $arguments = []) throw new \BadMethodCallException("Argument 'extension' of event {$this->name} is not of type 'string'"); } - if (strpos($arguments['extension'], '.') === false) { + if (!str_contains($arguments['extension'], '.')) { throw new \BadMethodCallException("Argument 'extension' of event {$this->name} has wrong format. Valid format: 'component.section'"); } diff --git a/libraries/src/Event/Workflow/AbstractEvent.php b/libraries/src/Event/Workflow/AbstractEvent.php index b020487ae3c4f..106e1582d355a 100644 --- a/libraries/src/Event/Workflow/AbstractEvent.php +++ b/libraries/src/Event/Workflow/AbstractEvent.php @@ -42,7 +42,7 @@ public function __construct($name, array $arguments = []) throw new \BadMethodCallException("Argument 'extension' of event {$this->name} is required but has not been provided"); } - if (strpos($arguments['extension'], '.') === false) { + if (!str_contains($arguments['extension'], '.')) { throw new \BadMethodCallException("Argument 'extension' of event {$this->name} has wrong format. Valid format: 'component.section'"); } diff --git a/libraries/src/Filesystem/File.php b/libraries/src/Filesystem/File.php index 020d7506d6a28..627c4c2ec97cd 100644 --- a/libraries/src/Filesystem/File.php +++ b/libraries/src/Filesystem/File.php @@ -56,7 +56,7 @@ public static function getExt($file) $ext = substr($file, $dot + 1); // Extension cannot contain slashes. - if (strpos($ext, '/') !== false || (DIRECTORY_SEPARATOR === '\\' && strpos($ext, '\\') !== false)) { + if (str_contains($ext, '/') || (DIRECTORY_SEPARATOR === '\\' && str_contains($ext, '\\'))) { return ''; } diff --git a/libraries/src/Form/Field/CaptchaField.php b/libraries/src/Form/Field/CaptchaField.php index bcfb6f6b96a15..b24514b312372 100644 --- a/libraries/src/Form/Field/CaptchaField.php +++ b/libraries/src/Form/Field/CaptchaField.php @@ -139,7 +139,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) // Obs: Don't put required="required" in the xml file, you just need to have validate="captcha" $this->required = true; - if (strpos($this->class, 'required') === false) { + if (!str_contains($this->class, 'required')) { $this->class .= ' required'; } diff --git a/libraries/src/Form/Field/MediaField.php b/libraries/src/Form/Field/MediaField.php index 73004903c7b6f..4fe134ae6f87f 100644 --- a/libraries/src/Form/Field/MediaField.php +++ b/libraries/src/Form/Field/MediaField.php @@ -274,7 +274,7 @@ public function getLayoutData() } // Value in new format such as images/headers/blue-flower.jpg#joomlaImage://local-images/headers/blue-flower.jpg?width=700&height=180 - if ($this->value && strpos($this->value, '#') !== false) { + if ($this->value && str_contains($this->value, '#')) { $uri = new Uri(explode('#', $this->value)[1]); $adapter = $uri->getHost(); $path = $uri->getPath(); diff --git a/libraries/src/Form/Field/TagField.php b/libraries/src/Form/Field/TagField.php index e81b268d5678a..6d0eadd76e196 100644 --- a/libraries/src/Form/Field/TagField.php +++ b/libraries/src/Form/Field/TagField.php @@ -153,7 +153,7 @@ protected function getOptions() } } elseif (!empty($this->element['language'])) { // Filter language - if (strpos($this->element['language'], ',') !== false) { + if (str_contains($this->element['language'], ',')) { $language = explode(',', $this->element['language']); } else { $language = [$this->element['language']]; diff --git a/libraries/src/Form/Field/TimezoneField.php b/libraries/src/Form/Field/TimezoneField.php index c7decb31f7204..1bddb7d57ef68 100644 --- a/libraries/src/Form/Field/TimezoneField.php +++ b/libraries/src/Form/Field/TimezoneField.php @@ -128,7 +128,7 @@ protected function getGroups() // Build the group lists. foreach ($zones as $zone) { // Time zones not in a group we will ignore. - if (strpos($zone, '/') === false) { + if (!str_contains($zone, '/')) { continue; } diff --git a/libraries/src/Form/Field/UsergrouplistField.php b/libraries/src/Form/Field/UsergrouplistField.php index 7899fb48957b8..68945e06f647c 100644 --- a/libraries/src/Form/Field/UsergrouplistField.php +++ b/libraries/src/Form/Field/UsergrouplistField.php @@ -54,7 +54,7 @@ class UsergrouplistField extends ListField */ public function setup(\SimpleXMLElement $element, $value, $group = null) { - if (\is_string($value) && strpos($value, ',') !== false) { + if (\is_string($value) && str_contains($value, ',')) { $value = explode(',', $value); } diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index 381fb97a2c9d7..738abe888ae6e 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -1094,7 +1094,7 @@ public function filter($value, $group = null, ?Registry $input = null) } // Check for a callback filter - if (strpos($filter, '::') !== false) { + if (str_contains($filter, '::')) { if (\is_callable(explode('::', $filter))) { return \call_user_func(explode('::', $filter), $value); } diff --git a/libraries/src/Form/FormHelper.php b/libraries/src/Form/FormHelper.php index 602745aaaecaf..749899d8c782d 100644 --- a/libraries/src/Form/FormHelper.php +++ b/libraries/src/Form/FormHelper.php @@ -509,7 +509,7 @@ public static function parseShowOnConditions($showOn, $formControl = null, $grou continue; } - $compareEqual = strpos($showOnPart, '!:') === false; + $compareEqual = !str_contains($showOnPart, '!:'); $showOnPartBlocks = explode(($compareEqual ? ':' : '!:'), $showOnPart, 2); $dotPos = strpos($showOnPartBlocks[0], '.'); diff --git a/libraries/src/Form/FormRule.php b/libraries/src/Form/FormRule.php index 2fe8c5c7c1b2f..7efa6265a35c8 100644 --- a/libraries/src/Form/FormRule.php +++ b/libraries/src/Form/FormRule.php @@ -85,7 +85,7 @@ public function test(\SimpleXMLElement $element, $value, $group = null, ?Registr // Add unicode property support if available. if ($unicodePropertiesSupport) { - $this->modifiers = (strpos($this->modifiers, 'u') !== false) ? $this->modifiers : $this->modifiers . 'u'; + $this->modifiers = (str_contains($this->modifiers, 'u')) ? $this->modifiers : $this->modifiers . 'u'; } // Test the value against the regular expression. diff --git a/libraries/src/HTML/HTMLHelper.php b/libraries/src/HTML/HTMLHelper.php index 0c7714675935e..d66622487f88b 100644 --- a/libraries/src/HTML/HTMLHelper.php +++ b/libraries/src/HTML/HTMLHelper.php @@ -755,7 +755,7 @@ public static function image($file, $alt, $attribs = null, $relative = false, $r // Go through each argument foreach (explode(' ', $attribs) as $attribute) { // When an argument without a value, default to an empty string - if (strpos($attribute, '=') === false) { + if (!str_contains($attribute, '=')) { $attributes[$attribute] = ''; continue; } @@ -1037,7 +1037,7 @@ public static function tooltipText($title = '', $content = '', $translate = true // Don't process empty strings if ($content !== '' || $title !== '') { // Split title into title and content if the title contains '::' (old Mootools format). - if ($content === '' && !(strpos($title, '::') === false)) { + if ($content === '' && !(!str_contains($title, '::'))) { list($title, $content) = explode('::', $title, 2); } @@ -1355,7 +1355,7 @@ public static function strftimeFormatToDateFormat(string $strftimeformat) * If there is % character left after replacing, that mean one of unsupported format is used * the conversion false */ - if (strpos($format, '%') !== false) { + if (str_contains($format, '%')) { return false; } diff --git a/libraries/src/HTML/Helpers/Number.php b/libraries/src/HTML/Helpers/Number.php index e0b30086a6459..0814e47eba685 100644 --- a/libraries/src/HTML/Helpers/Number.php +++ b/libraries/src/HTML/Helpers/Number.php @@ -58,7 +58,7 @@ public static function bytes($bytes, $unit = 'auto', $precision = 2, $iec = fals list(, $oBytes, $oUnit) = $matches; if ($oUnit && is_numeric($oBytes)) { - $oBase = $iec && strpos($oUnit, 'i') === false ? 1000 : 1024; + $oBase = $iec && !str_contains($oUnit, 'i') ? 1000 : 1024; $factor = pow($oBase, stripos('BKMGTPEZY', $oUnit[0])); $oBytes *= $factor; } diff --git a/libraries/src/HTML/Helpers/Select.php b/libraries/src/HTML/Helpers/Select.php index 476e976c2818f..0a6993e01be2d 100644 --- a/libraries/src/HTML/Helpers/Select.php +++ b/libraries/src/HTML/Helpers/Select.php @@ -140,7 +140,7 @@ public static function genericlist( $id = str_replace(['[', ']', ' '], '', $id); // If the selectbox contains "form-select-color-state" then load the JS file - if (strpos($attribs, 'form-select-color-state') !== false) { + if (str_contains($attribs, 'form-select-color-state')) { Factory::getDocument()->getWebAssetManager() ->registerAndUseScript( 'webcomponent.select-colour', diff --git a/libraries/src/HTML/Helpers/StringHelper.php b/libraries/src/HTML/Helpers/StringHelper.php index 293eff376172c..4b521cf2f6445 100644 --- a/libraries/src/HTML/Helpers/StringHelper.php +++ b/libraries/src/HTML/Helpers/StringHelper.php @@ -67,7 +67,7 @@ public static function truncate($text, $length = 0, $noSplit = true, $allowHtml if ($length > 0 && FrameworkStringHelper::strlen($text) > $length) { $tmp = trim(FrameworkStringHelper::substr($text, 0, $length)); - if ($tmp[0] === '<' && strpos($tmp, '>') === false) { + if ($tmp[0] === '<' && !str_contains($tmp, '>')) { return '...'; } @@ -165,7 +165,7 @@ public static function truncateComplex($html, $maxLength = 0, $noSplit = true) } // Take care of short simple cases. - if ($maxLength <= 3 && $html[0] !== '<' && strpos(substr($html, 0, $maxLength - 1), '<') === false && $baseLength > $maxLength) { + if ($maxLength <= 3 && $html[0] !== '<' && !str_contains(substr($html, 0, $maxLength - 1), '<') && $baseLength > $maxLength) { return '...'; } diff --git a/libraries/src/Helper/MediaHelper.php b/libraries/src/Helper/MediaHelper.php index 4b6ba22886464..85e7cfc6b9235 100644 --- a/libraries/src/Helper/MediaHelper.php +++ b/libraries/src/Helper/MediaHelper.php @@ -385,7 +385,7 @@ public function countFiles($dir) $d = dir($dir); while (($entry = $d->read()) !== false) { - if ($entry[0] !== '.' && strpos($entry, '.html') === false && strpos($entry, '.php') === false && is_file($dir . DIRECTORY_SEPARATOR . $entry)) { + if ($entry[0] !== '.' && !str_contains($entry, '.html') && !str_contains($entry, '.php') && is_file($dir . DIRECTORY_SEPARATOR . $entry)) { $total_file++; } diff --git a/libraries/src/Helper/ModuleHelper.php b/libraries/src/Helper/ModuleHelper.php index 704e8fd693731..f5a7b20398c60 100644 --- a/libraries/src/Helper/ModuleHelper.php +++ b/libraries/src/Helper/ModuleHelper.php @@ -319,7 +319,7 @@ public static function getLayoutPath($module, $layout = 'default') $defaultLayout = $layout; $template = $templateObj->template; - if (strpos($layout, ':') !== false) { + if (str_contains($layout, ':')) { // Get the template and file name from the string $temp = explode(':', $layout); $template = $temp[0] === '_' ? $template : $temp[0]; diff --git a/libraries/src/Helper/TagsHelper.php b/libraries/src/Helper/TagsHelper.php index 8eaf8a6956d5a..f26188f73a517 100644 --- a/libraries/src/Helper/TagsHelper.php +++ b/libraries/src/Helper/TagsHelper.php @@ -108,7 +108,7 @@ public function addTagMapping($ucmId, TableInterface $table, $tags = []) $typeId = $ucm->getTypeId(); // Insert the new tag maps - if (strpos(implode(',', $tags), '#') !== false) { + if (str_contains(implode(',', $tags), '#')) { $tags = $this->createTagsFromField($tags); } @@ -246,7 +246,7 @@ public function createTagsFromField($tags) foreach ($tags as $key => $tag) { // User is not allowed to create tags, so don't create. - if (!$canCreate && strpos($tag, '#new#') !== false) { + if (!$canCreate && str_contains($tag, '#new#')) { continue; } diff --git a/libraries/src/Installer/InstallerHelper.php b/libraries/src/Installer/InstallerHelper.php index 5f68dc4998ac5..7b14e6799e161 100644 --- a/libraries/src/Installer/InstallerHelper.php +++ b/libraries/src/Installer/InstallerHelper.php @@ -290,7 +290,7 @@ public static function getFilenameFromUrl($url) { $default = uniqid(); - if (!\is_string($url) || strpos($url, '/') === false) { + if (!\is_string($url) || !str_contains($url, '/')) { return $default; } diff --git a/libraries/src/Language/Language.php b/libraries/src/Language/Language.php index 6709047a9cc31..7c2089f7a5867 100644 --- a/libraries/src/Language/Language.php +++ b/libraries/src/Language/Language.php @@ -277,7 +277,7 @@ public function _($string, $jsSafe = false, $interpretBackSlashes = true) // Javascript filter $string = addslashes($string); } elseif ($interpretBackSlashes) { - if (strpos($string, '\\') !== false) { + if (str_contains($string, '\\')) { // Interpret \n and \t characters $string = str_replace(['\\\\', '\t', '\n'], ["\\", "\t", "\n"], $string); } diff --git a/libraries/src/Language/Text.php b/libraries/src/Language/Text.php index 90c910e651682..15af9680d16ab 100644 --- a/libraries/src/Language/Text.php +++ b/libraries/src/Language/Text.php @@ -92,7 +92,7 @@ public static function _($string, $jsSafe = false, $interpretBackSlashes = true, private static function passSprintf(&$string, $jsSafe = false, $interpretBackSlashes = true, $script = false) { // Check if string contains a comma - if (empty($string) || strpos($string, ',') === false) { + if (empty($string) || !str_contains($string, ',')) { return false; } diff --git a/libraries/src/MVC/Controller/BaseController.php b/libraries/src/MVC/Controller/BaseController.php index 3f942a0aa6080..980741de27004 100644 --- a/libraries/src/MVC/Controller/BaseController.php +++ b/libraries/src/MVC/Controller/BaseController.php @@ -300,7 +300,7 @@ public static function getInstance($prefix, $config = []) } // Check for a controller.task command. - if (strpos($command, '.') !== false) { + if (str_contains($command, '.')) { // Explode the controller.task command. list($type, $task) = explode('.', $command); diff --git a/libraries/src/MVC/Model/LegacyModelLoaderTrait.php b/libraries/src/MVC/Model/LegacyModelLoaderTrait.php index 4f120a6be8e3b..61a73f15dee41 100644 --- a/libraries/src/MVC/Model/LegacyModelLoaderTrait.php +++ b/libraries/src/MVC/Model/LegacyModelLoaderTrait.php @@ -160,12 +160,12 @@ private static function createModelFromComponent($type, $prefix = '', $config = $sitePath = Path::clean(JPATH_SITE . '/components/' . $componentName); foreach (self::addIncludePath() as $path) { - if (strpos($path, $adminPath) !== false) { + if (str_contains($path, $adminPath)) { $client = 'Administrator'; break; } - if (strpos($path, $sitePath) !== false) { + if (str_contains($path, $sitePath)) { $client = 'Site'; break; } diff --git a/libraries/src/MVC/View/HtmlView.php b/libraries/src/MVC/View/HtmlView.php index 7ef977e76f7bc..aa82b04dae6aa 100644 --- a/libraries/src/MVC/View/HtmlView.php +++ b/libraries/src/MVC/View/HtmlView.php @@ -281,7 +281,7 @@ public function setLayout($layout) { $previous = $this->_layout; - if (strpos($layout, ':') === false) { + if (!str_contains($layout, ':')) { $this->_layout = $layout; } else { // Convert parameter to array based on : diff --git a/libraries/src/Mail/MailHelper.php b/libraries/src/Mail/MailHelper.php index 196cc1fb836aa..349f067361b9a 100644 --- a/libraries/src/Mail/MailHelper.php +++ b/libraries/src/Mail/MailHelper.php @@ -202,7 +202,7 @@ public static function convertRelativeToAbsoluteUrls($content) $siteUrl = Uri::root(); // Replace none SEF URLs by absolute SEF URLs - if (strpos($content, 'href="index.php?') !== false) { + if (str_contains($content, 'href="index.php?')) { preg_match_all('#href="index.php\?([^"]+)"#m', $content, $matches); foreach ($matches[1] as $urlQueryString) { @@ -221,7 +221,7 @@ public static function convertRelativeToAbsoluteUrls($content) $attributes = ['href=', 'src=', 'poster=', 'loading=', 'data-path=']; foreach ($attributes as $attribute) { - if (strpos($content, $attribute) !== false) { + if (str_contains($content, $attribute)) { // If the attribute is 'loading=', remove loading="lazy" if ($attribute === 'loading=') { $content = preg_replace('/\s' . $attribute . '"lazy"/i', '', $content); diff --git a/libraries/src/Pathway/SitePathway.php b/libraries/src/Pathway/SitePathway.php index f6e6273990833..d60ce71db0f99 100644 --- a/libraries/src/Pathway/SitePathway.php +++ b/libraries/src/Pathway/SitePathway.php @@ -60,7 +60,7 @@ public function __construct(?SiteApplication $app = null) break; case 'url': - if ((str_starts_with($link->link, 'index.php?')) && (strpos($link->link, 'Itemid=') === false)) { + if ((str_starts_with($link->link, 'index.php?')) && (!str_contains($link->link, 'Itemid='))) { // If this is an internal Joomla link, ensure the Itemid is set. $url = $link->link . '&Itemid=' . $link->id; } else { diff --git a/libraries/src/Plugin/PluginHelper.php b/libraries/src/Plugin/PluginHelper.php index 9977628cc163d..bb78c1193a8ca 100644 --- a/libraries/src/Plugin/PluginHelper.php +++ b/libraries/src/Plugin/PluginHelper.php @@ -61,7 +61,7 @@ public static function getLayoutPath($type, $name, $layout = 'default') $defaultLayout = $layout; $template = $templateObj->template; - if (strpos($layout, ':') !== false) { + if (str_contains($layout, ':')) { // Get the template and file name from the string $temp = explode(':', $layout); $template = $temp[0] === '_' ? $templateObj->template : $temp[0]; diff --git a/libraries/src/Router/Router.php b/libraries/src/Router/Router.php index d4b09676c3700..56d02ecfb931d 100644 --- a/libraries/src/Router/Router.php +++ b/libraries/src/Router/Router.php @@ -469,7 +469,7 @@ protected function createUri($url) if (\is_string($url)) { $vars = []; - if (strpos($url, '&') !== false) { + if (str_contains($url, '&')) { $url = str_replace('&', '&', $url); } diff --git a/libraries/src/Session/Session.php b/libraries/src/Session/Session.php index 3ecab12b2b945..626f9675b63e9 100644 --- a/libraries/src/Session/Session.php +++ b/libraries/src/Session/Session.php @@ -202,7 +202,7 @@ public function get($name, $default = null) * This is no longer the case in Joomla 4 and will be converted * when saving new values in `self::set()` */ - if (strpos($name, '.') !== false && parent::has('__' . $name)) { + if (str_contains($name, '.') && parent::has('__' . $name)) { return parent::get('__' . $name, $default); } @@ -281,7 +281,7 @@ public function has($name) * This is no longer the case in Joomla 4 and will be converted * when saving new values in `self::set()` */ - if (strpos($name, '.') !== false && parent::has('__' . $name)) { + if (str_contains($name, '.') && parent::has('__' . $name)) { return true; } diff --git a/libraries/src/Uri/Uri.php b/libraries/src/Uri/Uri.php index 2c99156c6fdf3..d4036e83a6ddb 100644 --- a/libraries/src/Uri/Uri.php +++ b/libraries/src/Uri/Uri.php @@ -148,7 +148,7 @@ public static function base($pathonly = false) } else { static::$base['prefix'] = $uri->toString(['scheme', 'host', 'port']); - if (strpos(PHP_SAPI, 'cgi') !== false && !\ini_get('cgi.fix_pathinfo') && !empty($_SERVER['REQUEST_URI'])) { + if (str_contains(PHP_SAPI, 'cgi') && !\ini_get('cgi.fix_pathinfo') && !empty($_SERVER['REQUEST_URI'])) { // PHP-CGI on Apache with "cgi.fix_pathinfo = 0" // We shouldn't have user-supplied PATH_INFO in PHP_SELF in this case @@ -250,7 +250,7 @@ public static function isInternal($url) if ( empty($host) && str_starts_with($uri->path, 'index.php') || !empty($host) && preg_match('#^' . preg_quote(static::base(), '#') . '#', $base) - || !empty($host) && $host === static::getInstance(static::base())->host && strpos($uri->path, 'index.php') !== false + || !empty($host) && $host === static::getInstance(static::base())->host && str_contains($uri->path, 'index.php') || !empty($host) && $base === $host && preg_match('#^' . preg_quote($base, '#') . '#', static::base()) ) { return true; diff --git a/libraries/src/WebAsset/WebAssetItem.php b/libraries/src/WebAsset/WebAssetItem.php index aeac8f65805b7..2632f5cc2efe5 100644 --- a/libraries/src/WebAsset/WebAssetItem.php +++ b/libraries/src/WebAsset/WebAssetItem.php @@ -348,6 +348,6 @@ protected function isPathExternal(string $path): bool protected function isPathAbsolute(string $path): bool { // We have a full path or not - return strpos($path, '/') !== false && is_file(JPATH_ROOT . '/' . $path); + return str_contains($path, '/') && is_file(JPATH_ROOT . '/' . $path); } }