Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libraries/src/Application/WebApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Authentication/Password/MD5Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/Client/FtpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Console/SetConfigurationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions libraries/src/Date/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Dispatcher/ComponentDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Document/Renderer/Feed/RssRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Document/Renderer/Html/ScriptsRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Document/Renderer/Html/StylesRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
50 changes: 25 additions & 25 deletions libraries/src/Environment/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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];
Expand Down Expand Up @@ -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 (
Expand All @@ -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];
Expand All @@ -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.
Expand All @@ -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();
Expand All @@ -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');
Expand All @@ -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';
Expand Down Expand Up @@ -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') {
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Event/View/DisplayEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'");
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Event/Workflow/AbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'");
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Filesystem/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/CaptchaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/MediaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/TagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']];
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/TimezoneField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/UsergrouplistField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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], '.');
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/FormRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions libraries/src/HTML/HTMLHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/HTML/Helpers/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading