Merge pull request #18125 from kamil-tekiela/UseIdenticalOverEqualWithSameTypeRector

Use identical over equal with same type rector
This commit is contained in:
Maurício Meneghini Fauth 2023-02-19 20:25:11 -03:00 committed by GitHub
commit 5280f044f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 78 additions and 82 deletions

View File

@ -325,7 +325,7 @@ class BrowseForeigners
*/
public function getForeignLimit(?string $foreignShowAll): ?string
{
if (isset($foreignShowAll) && $foreignShowAll == __('Show all')) {
if ($foreignShowAll === __('Show all')) {
return null;
}

View File

@ -424,7 +424,7 @@ final class Common
$path_info_pos = mb_strrpos($GLOBALS['PMA_PHP_SELF'], $_PATH_INFO);
if ($path_info_pos !== false) {
$path_info_part = mb_substr($GLOBALS['PMA_PHP_SELF'], $path_info_pos, mb_strlen($_PATH_INFO));
if ($path_info_part == $_PATH_INFO) {
if ($path_info_part === $_PATH_INFO) {
$GLOBALS['PMA_PHP_SELF'] = mb_substr($GLOBALS['PMA_PHP_SELF'], 0, $path_info_pos);
}
}

View File

@ -1106,7 +1106,7 @@ class Config
if (
$server['host'] == $request
|| $server['verbose'] == $request
|| $verboseToLower == $serverToLower
|| $verboseToLower === $serverToLower
|| md5($verboseToLower) === $serverToLower
) {
$request = $i;

View File

@ -837,9 +837,9 @@ class Relation
} else {
$key = '0x' . bin2hex($key);
if (str_contains($data, '0x')) {
$selected = ($key == trim($data));
$selected = ($key === trim($data));
} else {
$selected = ($key == '0x' . $data);
$selected = ($key === '0x' . $data);
}
}

View File

@ -381,7 +381,7 @@ final class RelationController extends AbstractController
$tables_rs = $this->dbi->query($query);
foreach ($tables_rs as $row) {
if (! isset($row['Engine']) || mb_strtoupper($row['Engine']) != $storageEngine) {
if (! isset($row['Engine']) || mb_strtoupper($row['Engine']) !== $storageEngine) {
continue;
}

View File

@ -554,7 +554,7 @@ class Common
$type_T2 = mb_strtoupper($tables[$T2]['ENGINE'] ?? '');
// native foreign key
if (ForeignKey::isSupported($type_T1) && ForeignKey::isSupported($type_T2) && $type_T1 == $type_T2) {
if (ForeignKey::isSupported($type_T1) && ForeignKey::isSupported($type_T2) && $type_T1 === $type_T2) {
// relation exists?
$existrel_foreign = $this->relation->getForeigners($DB2, $T2, '', 'foreign');
$foreigner = $this->relation->searchColumnInForeigners($existrel_foreign, $F2);
@ -693,7 +693,7 @@ class Common
$tables = $this->dbi->getTablesFull($DB2, $T2);
$type_T2 = mb_strtoupper($tables[$T2]['ENGINE']);
if (ForeignKey::isSupported($type_T1) && ForeignKey::isSupported($type_T2) && $type_T1 == $type_T2) {
if (ForeignKey::isSupported($type_T1) && ForeignKey::isSupported($type_T2) && $type_T1 === $type_T2) {
// InnoDB
$existrel_foreign = $this->relation->getForeigners($DB2, $T2, '', 'foreign');
$foreigner = $this->relation->searchColumnInForeigners($existrel_foreign, $F2);

View File

@ -819,7 +819,7 @@ class Qbe
$htmlOutput .= $this->getAndOrColCell(
$newColumnCount,
$checkedOptions,
$columnIndex + 1 == $this->criteriaColumnCount
$columnIndex + 1 === $this->criteriaColumnCount
);
$newColumnCount++;
}
@ -1573,7 +1573,7 @@ class Qbe
}
// We are done if all tables are in $finalized
if (count($finalized) == count($searchTables)) {
if (count($finalized) === count($searchTables)) {
return;
}
}

View File

@ -884,7 +884,7 @@ class Routines
}
}
if ($i == count($itemParamName) - 1) {
if ($i === count($itemParamName) - 1) {
continue;
}

View File

@ -182,7 +182,7 @@ class DbiMysqli implements DbiExtension
public function realQuery(string $query, Connection $connection, int $options): MysqliResult|false
{
$method = MYSQLI_STORE_RESULT;
if ($options == ($options | DatabaseInterface::QUERY_UNBUFFERED)) {
if ($options === ($options | DatabaseInterface::QUERY_UNBUFFERED)) {
$method = MYSQLI_USE_RESULT;
}

View File

@ -526,7 +526,7 @@ class Results
$isLink
&& $previousTable != ''
&& $fieldsMeta[$i]->table != ''
&& $fieldsMeta[$i]->table != $previousTable
&& $fieldsMeta[$i]->table !== $previousTable
) {
// don't display links
$hasEditLink = false;
@ -3636,7 +3636,7 @@ class Results
$sortedColumnIndex = false;
foreach ($fieldsMeta as $key => $meta) {
if (($meta->table == $sortTable) && ($meta->name == $sortColumn)) {
if (($meta->table === $sortTable) && ($meta->name === $sortColumn)) {
$sortedColumnIndex = $key;
break;
}

View File

@ -177,7 +177,7 @@ class Encoding
string $dest_charset,
string $what
): string {
if ($src_charset == $dest_charset) {
if ($src_charset === $dest_charset) {
return $what;
}
@ -263,7 +263,7 @@ class Encoding
$str = $dist;
}
if ($string_encoding != $enc && $enc != '') {
if ($string_encoding !== $enc && $enc != '') {
return mb_convert_encoding($str, $enc, $string_encoding);
}

View File

@ -513,7 +513,7 @@ class Error extends Message
$destParts = explode(DIRECTORY_SEPARATOR, $dest);
$result = '.';
while (implode(DIRECTORY_SEPARATOR, $destParts) != implode(DIRECTORY_SEPARATOR, $hereParts)) {
while (implode(DIRECTORY_SEPARATOR, $destParts) !== implode(DIRECTORY_SEPARATOR, $hereParts)) {
if (count($hereParts) > count($destParts)) {
array_pop($hereParts);
$result .= DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..';

View File

@ -416,7 +416,7 @@ class ErrorHandler
// if preference is not 'never' and
// there are 'actual' errors to be reported
if ($GLOBALS['cfg']['SendErrorReports'] !== 'never' && $this->countErrors() != $this->countUserErrors()) {
if ($GLOBALS['cfg']['SendErrorReports'] !== 'never' && $this->countErrors() !== $this->countUserErrors()) {
// add report button.
$retval .= '<form method="post" action="' . Url::getFromRoute('/error-report')
. '" id="pma_report_errors_form"';
@ -571,7 +571,7 @@ class ErrorHandler
public function hasErrorsForPrompt(): bool
{
return $GLOBALS['cfg']['SendErrorReports'] !== 'never'
&& $this->countErrors() != $this->countUserErrors();
&& $this->countErrors() !== $this->countUserErrors();
}
/**
@ -582,7 +582,7 @@ class ErrorHandler
public function reportErrors(): void
{
// if there're no actual errors,
if (! $this->hasErrors() || $this->countErrors() == $this->countUserErrors()) {
if (! $this->hasErrors() || $this->countErrors() === $this->countUserErrors()) {
// then simply return.
return;
}

View File

@ -311,7 +311,7 @@ class Export
$requiredExtension = '.' . $exportPlugin->getProperties()->getExtension();
$extensionLength = mb_strlen($requiredExtension);
$userExtension = mb_substr($filename, -$extensionLength);
if (mb_strtolower($userExtension) != $requiredExtension) {
if (mb_strtolower($userExtension) !== $requiredExtension) {
$filename .= $requiredExtension;
}

View File

@ -261,7 +261,7 @@ class GisVisualization
$required_extension = '.' . $ext;
$extension_length = mb_strlen($required_extension);
$user_extension = mb_substr($file_name, -$extension_length);
if (mb_strtolower($user_extension) != $required_extension) {
if (mb_strtolower($user_extension) !== $required_extension) {
$file_name .= $required_extension;
}

View File

@ -233,7 +233,7 @@ class Git
substr($index_data, $offset + ($position * 20), 20)
)
);
if ($sha == $hash) {
if ($sha === $hash) {
$found = true;
break;
}
@ -501,7 +501,7 @@ class Git
}
// have found our ref?
if ($parts[1] == $refHead) {
if ($parts[1] === $refHead) {
$hash = $parts[0];
break;
}

View File

@ -1093,7 +1093,7 @@ class Import
for ($m = 0; $m < $numCols; ++$m) {
$tempSQLStr .= Util::backquote($tables[$i][self::COL_NAMES][$m]);
if ($m == $numCols - 1) {
if ($m === $numCols - 1) {
continue;
}
@ -1131,11 +1131,11 @@ class Import
: (string) $tables[$i][self::ROWS][$j][$k];
}
if ($k != $numCols - 1) {
if ($k !== $numCols - 1) {
$tempSQLStr .= ', ';
}
if ($colCount == $numCols - 1) {
if ($colCount === $numCols - 1) {
$colCount = 0;
} else {
$colCount++;
@ -1147,7 +1147,7 @@ class Import
$tempSQLStr .= ')';
if ($j != $numRows - 1) {
if ($j !== $numRows - 1) {
$tempSQLStr .= ",\n ";
}

View File

@ -81,7 +81,7 @@ class IpAllowDeny
$maskl += 2 ** (30 - $i);
}
return ($maskl & $rangel) == ($maskl & $ipl);
return ($maskl & $rangel) === ($maskl & $ipl);
}
// range based
@ -95,7 +95,7 @@ class IpAllowDeny
$result = false;
}
} else {
if ($maskocts[$i] <> $ipocts[$i]) {
if ($maskocts[$i] !== $ipocts[$i]) {
$result = false;
}
}

View File

@ -26,10 +26,10 @@ class Mime
*
* @return string
*/
public static function detect($test)
public static function detect(string $test)
{
$len = mb_strlen($test);
if ($len >= 2 && $test[0] == chr(0xff) && $test[1] == chr(0xd8)) {
if ($len >= 2 && $test[0] === chr(0xff) && $test[1] === chr(0xd8)) {
return 'image/jpeg';
}

View File

@ -430,7 +430,7 @@ class NavigationTree
continue;
}
if ($type2 == $container->realName) {
if ($type2 === $container->realName) {
$node->pos2 = $pos2;
}
@ -455,7 +455,7 @@ class NavigationTree
}
$node = NodeFactory::getInstance(NodeTable::class, $path[0]);
if ($type2 == $container->realName) {
if ($type2 === $container->realName) {
$node->pos2 = $pos2;
}
@ -498,7 +498,7 @@ class NavigationTree
}
$node->pos2 = $container->parent->pos2;
if ($type3 == $container->realName) {
if ($type3 === $container->realName) {
$node->pos3 = $pos3;
}
@ -544,7 +544,7 @@ class NavigationTree
// Add all new Nodes to the tree
foreach ($retval as $node) {
$node->pos2 = $pos2;
if ($type3 == $node->realName) {
if ($type3 === $node->realName) {
$node->pos3 = $pos3;
}
@ -552,7 +552,7 @@ class NavigationTree
}
} else {
foreach ($table->children as $node) {
if ($type3 == $node->realName) {
if ($type3 === $node->realName) {
$node->pos3 = $pos3;
}
@ -626,7 +626,7 @@ class NavigationTree
// Add all new Nodes to the tree
foreach ($retval as $node) {
if ($type == $node->realName) {
if ($type === $node->realName) {
$node->pos2 = $pos2;
}
@ -634,7 +634,7 @@ class NavigationTree
}
} else {
foreach ($db->children as $node) {
if ($type == $node->realName) {
if ($type === $node->realName) {
$node->pos2 = $pos2;
}
@ -777,7 +777,10 @@ class NavigationTree
foreach ($node->children as $child) {
$keySeparatorLength = mb_strlen((string) $key) + $separatorLength;
$nameSubstring = mb_substr((string) $child->name, 0, $keySeparatorLength);
if (($nameSubstring != $key . $separator && $child->name != $key) || $child->type != Node::OBJECT) {
if (
($nameSubstring !== $key . $separator && $child->name !== $key)
|| $child->type != Node::OBJECT
) {
continue;
}
@ -1162,7 +1165,7 @@ class NavigationTree
$buffer = '';
$extraClass = '';
for ($i = 0, $nbChildren = count($children); $i < $nbChildren; $i++) {
if ($i + 1 == $nbChildren) {
if ($i + 1 === $nbChildren) {
$extraClass = ' last';
}

View File

@ -414,7 +414,7 @@ class Normalization
if (count($primarycols) > 1) {
$this->dbi->selectDb($db);
$columns = $this->dbi->getColumnNames($db, $table);
if (count($pk) == count($columns)) {
if (count($pk) === count($columns)) {
$headText = sprintf(
__(
'No partial dependencies possible as '

View File

@ -297,7 +297,7 @@ class ImportCsv extends AbstractImportCsv
if (! $csv_finish) {
// Grab empty field
if ($ch == $GLOBALS['csv_terminated']) {
if ($i == $len - 1) {
if ($i === $len - 1) {
break;
}
@ -315,7 +315,7 @@ class ImportCsv extends AbstractImportCsv
// Grab one field
$fallbacki = $i;
if ($ch == $GLOBALS['csv_enclosed']) {
if ($i == $len - 1) {
if ($i === $len - 1) {
break;
}
@ -343,7 +343,7 @@ class ImportCsv extends AbstractImportCsv
&& ($ch == "\r" || $ch == "\n"))))
) {
if ($ch == $GLOBALS['csv_escaped']) {
if ($i == $len - 1) {
if ($i === $len - 1) {
$fail = true;
break;
}
@ -367,7 +367,7 @@ class ImportCsv extends AbstractImportCsv
}
$value .= $ch;
if ($i == $len - 1) {
if ($i === $len - 1) {
if (! $GLOBALS['finished']) {
$fail = true;
}
@ -402,9 +402,9 @@ class ImportCsv extends AbstractImportCsv
// Need to strip trailing enclosing char?
if ($need_end && $ch == $GLOBALS['csv_enclosed']) {
if ($GLOBALS['finished'] && $i == $len - 1) {
if ($GLOBALS['finished'] && $i === $len - 1) {
$ch = null;
} elseif ($i == $len - 1) {
} elseif ($i === $len - 1) {
$i = $fallbacki;
$ch = mb_substr($buffer, $i, 1);
if ($csv_terminated_len > 1 && $ch == $GLOBALS['csv_terminated'][0]) {
@ -426,14 +426,14 @@ class ImportCsv extends AbstractImportCsv
if (
$ch == $GLOBALS['csv_new_line']
|| ($GLOBALS['csv_new_line'] === 'auto' && ($ch == "\r" || $ch == "\n"))
|| ($GLOBALS['finished'] && $i == $len - 1)
|| ($GLOBALS['finished'] && $i === $len - 1)
) {
$csv_finish = true;
}
// Go to next char
if ($ch == $GLOBALS['csv_terminated']) {
if ($i == $len - 1) {
if ($i === $len - 1) {
$i = $fallbacki;
$ch = mb_substr($buffer, $i, 1);
if ($csv_terminated_len > 1 && $ch == $GLOBALS['csv_terminated'][0]) {

View File

@ -401,7 +401,7 @@ class Pdf extends PdfLib
$l += $cw[mb_ord($c)] ?? 0;
if ($l > $wmax) {
if ($sep == -1) {
if ($i == $j) {
if ($i === $j) {
$i++;
}
} else {

View File

@ -61,7 +61,7 @@ abstract class SubstringTransformationsPlugin extends TransformationsPlugin
$length = mb_strlen($newtext);
$baselength = mb_strlen((string) $buffer);
if ($length != $baselength) {
if ($length !== $baselength) {
if ($optionZero !== 0) {
$newtext = $options[2] . $newtext;
}

View File

@ -1279,7 +1279,7 @@ class Privileges
foreach ($grantsArr as $grant) {
$specificPrivileges[$grant[0]] = 'N';
foreach ($tablePrivs as $tablePriv) {
if ($grant[0] != $tablePriv) {
if ($grant[0] !== $tablePriv) {
continue;
}

View File

@ -187,7 +187,7 @@ class Session
$session_result = session_start();
if ($session_result !== true || $orig_error_count != $errorHandler->countErrors(false)) {
if ($session_result !== true || $orig_error_count !== $errorHandler->countErrors(false)) {
setcookie($httpCookieName, '', 1);
$errors = $errorHandler->sliceErrors($orig_error_count);
self::sessionFailed($errors);

View File

@ -208,7 +208,7 @@ class Sql
$numberFound++;
}
if ($numberFound == count($indexColumns)) {
if ($numberFound === count($indexColumns)) {
return true;
}
}

View File

@ -114,7 +114,7 @@ class SystemDatabase
break;
}
if ($columnCount == count($columnMap)) {
if ($columnCount === count($columnMap)) {
break;
}
}

View File

@ -830,12 +830,12 @@ class Table implements Stringable
* Inserts existing entries in a PMA_* table by reading a value from an old
* entry
*
* @param string $work The array index, which Relation feature to check ('relwork', 'commwork', ...)
* @param string $table The array index, which PMA-table to update ('bookmark', 'relation', ...)
* @param array $getFields Which fields will be SELECT'ed from the old entry
* @param array $whereFields Which fields will be used for the WHERE query (array('FIELDNAME' => 'FIELDVALUE'))
* @param array $newFields Which fields will be used as new VALUES. These are the important keys which differ
* from the old entry (array('FIELDNAME' => 'NEW FIELDVALUE'))
* @param string $work The array index, which Relation feature to check ('relwork', 'commwork', ...)
* @param string $table The array index, which PMA-table to update ('bookmark', 'relation', ...)
* @param string[] $getFields Which fields will be SELECT'ed from the old entry
* @param array $whereFields Which fields will be used for the WHERE query (array('FIELDNAME' => 'FIELDVALUE'))
* @param array $newFields Which fields will be used as new VALUES. These are the important keys which differ
* from the old entry (array('FIELDNAME' => 'NEW FIELDVALUE'))
*/
public static function duplicateInfo(
$work,
@ -857,7 +857,7 @@ class Table implements Stringable
$rowFields = [];
foreach ($getFields as $getField) {
$selectParts[] = Util::backquote($getField);
$rowFields[$getField] = 'cc';
$rowFields[] = $getField;
}
$whereParts = [];
@ -886,7 +886,7 @@ class Table implements Stringable
foreach ($tableCopyRs as $tableCopyRow) {
$valueParts = [];
foreach ($tableCopyRow as $key => $val) {
if (! isset($rowFields[$key]) || $rowFields[$key] != 'cc') {
if (! in_array($key, $rowFields)) {
continue;
}

View File

@ -444,7 +444,7 @@ class Util
}
}
if ($unit != $byteUnits[0]) {
if ($unit !== $byteUnits[0]) {
// if the unit is not bytes (as represented in current language)
// reformat with max length of 5
// 4th parameter=true means do not reformat if value < 1
@ -980,7 +980,7 @@ class Util
}
return $keyword . $charset
. ($charset == $collation ? '' : ' COLLATE ' . $collation);
. ($charset === $collation ? '' : ' COLLATE ' . $collation);
}
/**
@ -1942,7 +1942,7 @@ class Util
$len = strlen($test);
fclose($file);
if ($len >= 2 && $test[0] == chr(31) && $test[1] == chr(139)) {
if ($len >= 2 && $test[0] === chr(31) && $test[1] === chr(139)) {
return 'application/gzip';
}

View File

@ -8530,11 +8530,6 @@ parameters:
count: 1
path: libraries/classes/Table.php
-
message: "#^Method PhpMyAdmin\\\\Table\\:\\:duplicateInfo\\(\\) has parameter \\$getFields with no value type specified in iterable type array\\.$#"
count: 1
path: libraries/classes/Table.php
-
message: "#^Method PhpMyAdmin\\\\Table\\:\\:duplicateInfo\\(\\) has parameter \\$newFields with no value type specified in iterable type array\\.$#"
count: 1
@ -8735,11 +8730,6 @@ parameters:
count: 1
path: libraries/classes/Table.php
-
message: "#^Right side of \\|\\| is always false\\.$#"
count: 1
path: libraries/classes/Table.php
-
message: "#^Method PhpMyAdmin\\\\Table\\\\ColumnsDefinition\\:\\:displayForm\\(\\) has parameter \\$fields_meta with no value type specified in iterable type array\\.$#"
count: 1

View File

@ -4325,7 +4325,6 @@
</PossiblyInvalidOperand>
<PossiblyNullArgument>
<code>$result</code>
<code>$result</code>
</PossiblyNullArgument>
<PossiblyUnusedParam>
<code>$request</code>
@ -7693,6 +7692,10 @@
<code>mixed</code>
<code>mixed</code>
</PossiblyUnusedReturnValue>
<RedundantCondition>
<code>mb_strtolower($userExtension) !== $requiredExtension</code>
<code>mb_strtolower($userExtension) !== $requiredExtension</code>
</RedundantCondition>
</file>
<file src="libraries/classes/Export/Options.php">
<InvalidArrayOffset>
@ -8689,6 +8692,10 @@
<PropertyNotSetInConstructor>
<code>$modifiedSql</code>
</PropertyNotSetInConstructor>
<RedundantCondition>
<code>mb_strtolower($user_extension) !== $required_extension</code>
<code>mb_strtolower($user_extension) !== $required_extension</code>
</RedundantCondition>
<RedundantConditionGivenDocblockType>
<code>is_numeric($pos)</code>
<code>is_numeric($rows)</code>
@ -14904,7 +14911,6 @@
<code>$foreignTable</code>
<code>$foreignTable</code>
<code>$foreignTable</code>
<code>$getField</code>
<code>$index</code>
<code>$index[0]</code>
<code>$masterField</code>
@ -14988,7 +14994,6 @@
<code><![CDATA[$optionsArray[$_POST['on_update'][$masterFieldMd5]]]]></code>
<code><![CDATA[$optionsArray[$existrelForeign[$masterFieldMd5]['on_delete'] ?? '']]]></code>
<code><![CDATA[$optionsArray[$existrelForeign[$masterFieldMd5]['on_update'] ?? '']]]></code>
<code>$rowFields[$getField]</code>
</MixedArrayOffset>
<MixedArrayTypeCoercion>
<code><![CDATA[$optionsArray[$existrelForeign[$masterFieldMd5]['on_delete'] ?? '']]]></code>
@ -15014,7 +15019,6 @@
<code>$foreignField</code>
<code>$foreignTable</code>
<code>$foreignTable</code>
<code>$getField</code>
<code>$index</code>
<code>$key</code>
<code>$masterField</code>
@ -15167,7 +15171,6 @@
</ReferenceConstraintViolation>
<TypeDoesNotContainType>
<code><![CDATA[! $this->dbi->query($GLOBALS['sql_query'])]]></code>
<code><![CDATA[$rowFields[$key] != 'cc']]></code>
</TypeDoesNotContainType>
<UnusedVariable>
<code>$maintainRelations</code>