Replace mb_strpos !== false with str_contains

See: https://wiki.php.net/rfc/str_contains#case-insensitivity_and_multibyte_strings

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2021-07-10 13:43:40 -03:00
parent 6ae07c96fb
commit 1835ebb4fc
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
19 changed files with 50 additions and 49 deletions

View File

@ -242,7 +242,7 @@ class CheckUserPrivileges
$GLOBALS['dbs_to_test'][] = $showGrantsDbName;
}
if (mb_strpos($showGrantsString, 'RELOAD') !== false) {
if (str_contains($showGrantsString, 'RELOAD')) {
$GLOBALS['is_reload_priv'] = true;
}

View File

@ -17,7 +17,7 @@ use PhpMyAdmin\Url;
use function __;
use function in_array;
use function is_numeric;
use function mb_strpos;
use function str_contains;
class VariablesController extends AbstractController
{
@ -111,7 +111,7 @@ class VariablesController extends AbstractController
// Fields containing % are calculated,
// they can not be described in MySQL documentation
if (mb_strpos($name, '%') === false) {
if (! str_contains($name, '%')) {
$variables[$name]['doc'] = Generator::linkToVarDocumentation(
$name,
$this->dbi->isMariaDB()

View File

@ -110,7 +110,7 @@ class SqlController extends AbstractController
! str_contains($errorUrl, '?') ? '?' : '&'
);
if (
(mb_strpos(' ' . $errorUrl, 'db_') !== 1 || mb_strpos($errorUrl, '?route=/database/') === false)
(mb_strpos(' ' . $errorUrl, 'db_') !== 1 || ! str_contains($errorUrl, '?route=/database/'))
&& strlen($table) > 0
) {
$errorUrl .= '&amp;table=' . urlencode($table);

View File

@ -17,7 +17,7 @@ use function __;
use function array_fill;
use function count;
use function is_array;
use function mb_strpos;
use function str_contains;
use function strlen;
/**
@ -102,7 +102,7 @@ class ChangeController extends AbstractController
$_url_params = $this->insertEdit->getUrlParameters($db, $table);
$errorUrl = $GLOBALS['goto'] . Url::getCommon(
$_url_params,
mb_strpos($GLOBALS['goto'], '?') === false ? '?' : '&'
! str_contains($GLOBALS['goto'], '?') ? '?' : '&'
);
unset($_url_params);

View File

@ -17,9 +17,9 @@ use function explode;
use function htmlspecialchars;
use function in_array;
use function intval;
use function mb_strpos;
use function mb_strtoupper;
use function sprintf;
use function str_contains;
use function strtoupper;
use function trim;
@ -404,7 +404,7 @@ class Events
$query = 'CREATE ';
if (! empty($_POST['item_definer'])) {
if (
mb_strpos($_POST['item_definer'], '@') !== false
str_contains($_POST['item_definer'], '@')
) {
$arr = explode('@', $_POST['item_definer']);
$query .= 'DEFINER=' . Util::backquote($arr[0]);

View File

@ -28,11 +28,11 @@ use function in_array;
use function is_array;
use function is_string;
use function max;
use function mb_strpos;
use function mb_strtolower;
use function mb_strtoupper;
use function preg_match;
use function sprintf;
use function str_contains;
use function stripos;
use function substr;
use function trim;
@ -1037,7 +1037,7 @@ class Routines
$query = 'CREATE ';
if (! empty($itemDefiner)) {
if (mb_strpos($itemDefiner, '@') !== false) {
if (str_contains($itemDefiner, '@')) {
$arr = explode('@', $itemDefiner);
$do_backquote = true;

View File

@ -16,9 +16,9 @@ use function count;
use function explode;
use function htmlspecialchars;
use function in_array;
use function mb_strpos;
use function mb_strtoupper;
use function sprintf;
use function str_contains;
use function trim;
/**
@ -385,7 +385,7 @@ class Triggers
$query = 'CREATE ';
if (! empty($_POST['item_definer'])) {
if (
mb_strpos($_POST['item_definer'], '@') !== false
str_contains($_POST['item_definer'], '@')
) {
$arr = explode('@', $_POST['item_definer']);
$query .= 'DEFINER=' . Util::backquote($arr[0]);

View File

@ -1786,7 +1786,7 @@ class Results
$sortTableNew = $sortTable;
// Test to detect if the column name is a standard name
// Standard name has the table name prefixed to the column name
if (mb_strpos($nameToUseInSort, '.') !== false) {
if (str_contains($nameToUseInSort, '.')) {
$matches = explode('.', $nameToUseInSort);
// Matches[0] has the table name
// Matches[1] has the column name
@ -1804,7 +1804,7 @@ class Results
// order by clause to the column name
$queryHead = $isFirstClause ? "\nORDER BY " : '';
// Again a check to see if the given column is a aggregate column
if (mb_strpos($nameToUseInSort, '(') !== false) {
if (str_contains($nameToUseInSort, '(')) {
$sortOrder .= $queryHead . $nameToUseInSort . ' ';
} else {
if (strlen($sortTableNew) > 0) {
@ -1822,7 +1822,7 @@ class Results
$sortOrder = preg_replace('/\.\./', '.', $sortOrder);
// Incase this is the current column save $single_sort_order
if ($currentName == $nameToUseInSort) {
if (mb_strpos($currentName, '(') !== false) {
if (str_contains($currentName, '(')) {
$singleSortOrder = "\n" . 'ORDER BY ' . Util::backquote($currentName) . ' ';
} else {
$singleSortOrder = "\n" . 'ORDER BY ' . $sortTable
@ -1899,7 +1899,7 @@ class Results
$indexInExpression = 0;
foreach ($sortExpressionNoDirection as $index => $clause) {
if (mb_strpos($clause, '.') !== false) {
if (str_contains($clause, '.')) {
$fragments = explode('.', $clause);
$clause2 = $fragments[0] . '.' . str_replace('`', '', $fragments[1]);
} else {
@ -4261,7 +4261,7 @@ class Results
return null;
}
if (mb_strpos($sortExpressionNoDirection, '.') === false) {
if (! str_contains($sortExpressionNoDirection, '.')) {
$sortTable = $this->properties['table'];
$sortColumn = $sortExpressionNoDirection;
} else {

View File

@ -20,8 +20,8 @@ use function imagefilledpolygon;
use function imagestring;
use function json_encode;
use function mb_strlen;
use function mb_strpos;
use function mb_substr;
use function str_contains;
use function trim;
/**
@ -81,7 +81,7 @@ class GisMultiPolygon extends GisGeometry
foreach ($polygons as $polygon) {
// If the polygon doesn't have an inner ring, use polygon itself
if (mb_strpos($polygon, '),(') === false) {
if (! str_contains($polygon, '),(')) {
$ring = $polygon;
} else {
// Separate outer ring and use it to determine min-max
@ -135,7 +135,7 @@ class GisMultiPolygon extends GisGeometry
$points_arr = [];
foreach ($polygons as $polygon) {
// If the polygon doesn't have an inner polygon
if (mb_strpos($polygon, '),(') === false) {
if (! str_contains($polygon, '),(')) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Separate outer and inner polygons
@ -218,7 +218,7 @@ class GisMultiPolygon extends GisGeometry
$first_poly = true;
foreach ($polygons as $polygon) {
// If the polygon doesn't have an inner polygon
if (mb_strpos($polygon, '),(') === false) {
if (! str_contains($polygon, '),(')) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Separate outer and inner polygons
@ -298,7 +298,7 @@ class GisMultiPolygon extends GisGeometry
$row .= '<path d="';
// If the polygon doesn't have an inner polygon
if (mb_strpos($polygon, '),(') === false) {
if (! str_contains($polygon, '),(')) {
$row .= $this->drawPath($polygon, $scale_data);
} else {
// Separate outer and inner polygons
@ -620,7 +620,7 @@ class GisMultiPolygon extends GisGeometry
$k = 0;
foreach ($polygons as $polygon) {
// If the polygon doesn't have an inner polygon
if (mb_strpos($polygon, '),(') === false) {
if (! str_contains($polygon, '),(')) {
$param_row[$k]['no_of_lines'] = 1;
$points_arr = $this->extractPoints($polygon, null);
$no_of_points = count($points_arr);

View File

@ -21,11 +21,11 @@ use function imagestring;
use function json_encode;
use function max;
use function mb_strlen;
use function mb_strpos;
use function mb_substr;
use function min;
use function pow;
use function sqrt;
use function str_contains;
use function trim;
/**
@ -80,7 +80,7 @@ class GisPolygon extends GisGeometry
);
// If the polygon doesn't have an inner ring, use polygon itself
if (mb_strpos($polygon, '),(') === false) {
if (! str_contains($polygon, '),(')) {
$ring = $polygon;
} else {
// Separate outer ring and use it to determine min-max
@ -126,7 +126,7 @@ class GisPolygon extends GisGeometry
);
// If the polygon doesn't have an inner polygon
if (mb_strpos($polygon, '),(') === false) {
if (! str_contains($polygon, '),(')) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Separate outer and inner polygons
@ -194,7 +194,7 @@ class GisPolygon extends GisGeometry
);
// If the polygon doesn't have an inner polygon
if (mb_strpos($polygon, '),(') === false) {
if (! str_contains($polygon, '),(')) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Separate outer and inner polygons
@ -259,7 +259,7 @@ class GisPolygon extends GisGeometry
$row = '<path d="';
// If the polygon doesn't have an inner polygon
if (mb_strpos($polygon, '),(') === false) {
if (! str_contains($polygon, '),(')) {
$row .= $this->drawPath($polygon, $scale_data);
} else {
// Separate outer and inner polygons

View File

@ -33,6 +33,7 @@ use function pow;
use function preg_match;
use function preg_replace;
use function sprintf;
use function str_contains;
use function str_starts_with;
use function strcmp;
use function strlen;
@ -917,7 +918,7 @@ class Import
if (
$cell == (string) (float) $cell
&& mb_strpos((string) $cell, '.') !== false
&& str_contains((string) $cell, '.')
&& mb_substr_count((string) $cell, '.') === 1
) {
return self::DECIMAL;

View File

@ -33,7 +33,6 @@ use function is_string;
use function max;
use function mb_stripos;
use function mb_strlen;
use function mb_strpos;
use function mb_strstr;
use function mb_substr;
use function md5;
@ -868,7 +867,7 @@ class InsertEdit
if (
$column['is_char']
&& ($GLOBALS['cfg']['CharEditing'] === 'textarea'
|| mb_strpos($data, "\n") !== false)
|| str_contains($data, "\n"))
) {
$htmlOutput .= "\n";
$GLOBALS['cfg']['CharEditing'] = $defaultCharEditing;
@ -1108,7 +1107,7 @@ class InsertEdit
(substr($column['True_Type'], 0, 9) === 'timestamp'
|| $column['True_Type'] === 'datetime'
|| $column['True_Type'] === 'time')
&& (mb_strpos($currentRow[$column['Field']], '.') !== false)
&& (str_contains($currentRow[$column['Field']], '.'))
) {
$currentRow[$column['Field']] = $asIs
? $currentRow[$column['Field']]
@ -1155,7 +1154,7 @@ class InsertEdit
) {
if (
$column['Key'] === 'PRI'
&& mb_strpos($column['Extra'], 'auto_increment') !== false
&& str_contains($column['Extra'], 'auto_increment')
) {
$data = $specialCharsEncoded = $specialChars = null;
}

View File

@ -24,13 +24,13 @@ use function basename;
use function count;
use function is_array;
use function mb_strlen;
use function mb_strpos;
use function mb_strtolower;
use function mb_substr;
use function preg_grep;
use function preg_replace;
use function preg_split;
use function rtrim;
use function str_contains;
use function strlen;
use function strtr;
use function trim;
@ -243,10 +243,10 @@ class ImportCsv extends AbstractImportCsv
// and don't have new line inside
if (
($csv_new_line === 'auto'
&& mb_strpos($buffer, "\r") === false
&& mb_strpos($buffer, "\n") === false)
&& ! str_contains($buffer, "\r")
&& ! str_contains($buffer, "\n"))
|| ($csv_new_line !== 'auto'
&& mb_strpos($buffer, $csv_new_line) === false)
&& ! str_contains($buffer, $csv_new_line))
) {
continue;
}

View File

@ -19,6 +19,7 @@ use function mb_strlen;
use function mb_strpos;
use function mb_substr;
use function preg_match;
use function str_contains;
use function str_replace;
use function strcmp;
use function strlen;
@ -117,7 +118,7 @@ class ImportMediawiki extends ImportPlugin
unset($data);
// Don't parse string if we're not at the end
// and don't have a new line inside
if (mb_strpos($buffer, $mediawiki_new_line) === false) {
if (! str_contains($buffer, $mediawiki_new_line)) {
continue;
}
}
@ -579,7 +580,7 @@ class ImportMediawiki extends ImportPlugin
// A '|' inside an invalid link should not
// be mistaken as delimiting cell parameters
if (mb_strpos($cell_data[0], '[[') === false) {
if (! str_contains($cell_data[0], '[[')) {
return $cell;
}

View File

@ -3759,7 +3759,7 @@ class Privileges
} elseif (Compatibility::isMariaDb()) {
$createUserStmt .= ' IDENTIFIED BY \'%s\'';
} elseif (Compatibility::isMySqlOrPerconaDb() && $serverVersion >= 80011) {
if (mb_strpos($createUserStmt, 'IDENTIFIED') === false) {
if (! str_contains($createUserStmt, 'IDENTIFIED')) {
// Maybe the authentication_plugin was not posted and then a part is missing
$createUserStmt .= ' IDENTIFIED BY \'%s\'';
} else {

View File

@ -13,8 +13,8 @@ use PhpMyAdmin\Url;
use function __;
use function basename;
use function mb_strpos;
use function mb_strtolower;
use function str_contains;
/**
* This class provides data about the server status
@ -323,7 +323,7 @@ class Data
foreach ($server_status as $name => $value) {
$section_found = false;
foreach ($allocations as $filter => $section) {
if (mb_strpos($name, $filter) === false) {
if (! str_contains($name, $filter)) {
continue;
}

View File

@ -15,8 +15,8 @@ use function count;
use function gmdate;
use function implode;
use function is_array;
use function mb_strpos;
use function preg_replace;
use function str_contains;
use function strtr;
use function var_export;
@ -72,7 +72,7 @@ class ConfigGenerator
// keep 1d array keys which are present in $persist_keys (config.values.php)
foreach (array_keys($persistKeys) as $k) {
if (mb_strpos($k, '/') !== false) {
if (str_contains($k, '/')) {
continue;
}

View File

@ -12,7 +12,7 @@ use function htmlspecialchars;
use function http_build_query;
use function ini_get;
use function is_array;
use function mb_strpos;
use function str_contains;
use function strlen;
/**
@ -263,7 +263,7 @@ class Url
// (see https://www.w3.org/TR/1999/REC-html401-19991224/appendix
// /notes.html#h-B.2.2)
$arg_separator = (string) ini_get('arg_separator.input');
if (mb_strpos($arg_separator, ';') !== false) {
if (str_contains($arg_separator, ';')) {
$separator = ';';
} elseif (strlen($arg_separator) > 0) {
$separator = $arg_separator[0];

View File

@ -1794,12 +1794,12 @@ class Util
}
/* Backward compatibility in 3.5.x */
if (mb_strpos($string, '@FIELDS@') !== false) {
if (str_contains($string, '@FIELDS@')) {
$string = strtr($string, ['@FIELDS@' => '@COLUMNS@']);
}
/* Fetch columns list if required */
if (mb_strpos($string, '@COLUMNS@') !== false) {
if (str_contains($string, '@COLUMNS@')) {
$columnsList = $dbi->getColumns(
$GLOBALS['db'],
$GLOBALS['table']
@ -2177,7 +2177,7 @@ class Util
return $value;
}
if (mb_strpos($value, '.') === false) {
if (! str_contains($value, '.')) {
return $value . '.000000';
}