From e7765efd63e147b9af7cfef310fc6ab91da6a5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sun, 6 Jul 2025 15:44:31 -0300 Subject: [PATCH] Make some comparisons stricter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- phpstan-baseline.neon | 498 ++++-------------- psalm-baseline.xml | 42 +- src/Advisory/Advisor.php | 3 +- src/Config.php | 6 +- src/Config/ConfigFile.php | 2 +- src/Config/PageSettings.php | 4 +- src/Config/ServerConfigChecks.php | 2 +- src/ConfigStorage/Relation.php | 44 +- .../Database/DesignerController.php | 2 +- .../Structure/FavoriteTableController.php | 2 +- .../Database/StructureController.php | 2 +- src/Controllers/HomeController.php | 12 +- src/Controllers/Import/ImportController.php | 2 +- .../Operations/DatabaseController.php | 2 +- .../Table/FindReplaceController.php | 2 +- src/Controllers/Table/ReplaceController.php | 2 +- src/Controllers/Table/SearchController.php | 2 +- .../Table/ZoomSearchController.php | 4 +- src/Controllers/VersionCheckController.php | 2 +- src/Database/CentralColumns.php | 4 +- src/Database/Designer/Common.php | 2 +- src/Database/Search.php | 2 +- src/Dbal/DatabaseInterface.php | 4 +- src/Display/Results.php | 18 +- src/Encoding.php | 4 +- src/Error/ErrorReport.php | 2 +- src/Export/Export.php | 2 +- src/FieldMetadata.php | 2 +- src/File.php | 2 +- src/Git.php | 4 +- src/Html/Generator.php | 2 +- src/Import/Import.php | 4 +- src/Menu.php | 6 +- src/Navigation/NavigationTree.php | 2 +- src/Navigation/Nodes/Node.php | 4 +- src/Normalization.php | 4 +- src/Operations.php | 8 +- src/Plugins.php | 2 +- src/Plugins/Auth/AuthenticationConfig.php | 2 +- src/Plugins/Auth/AuthenticationCookie.php | 4 +- src/Plugins/Auth/AuthenticationSignon.php | 2 +- src/Plugins/Export/ExportMediawiki.php | 2 +- src/Plugins/Export/ExportOdt.php | 2 +- src/Plugins/Export/ExportTexytext.php | 2 +- src/Plugins/Export/Helpers/Pdf.php | 2 +- src/Plugins/Import/ImportCsv.php | 6 +- src/Plugins/Import/ImportOds.php | 4 +- src/Plugins/Import/ImportShp.php | 2 +- src/Plugins/Schema/Pdf/Pdf.php | 6 +- src/Plugins/Schema/Pdf/PdfRelationSchema.php | 4 +- src/Plugins/Schema/Svg/Svg.php | 2 +- .../Abs/DateFormatTransformationsPlugin.php | 2 +- .../Abs/SubstringTransformationsPlugin.php | 2 +- .../Input/Text_Plain_Iptobinary.php | 2 +- src/Replication/Replication.php | 2 +- src/Routing/Routing.php | 2 +- src/Server/Privileges.php | 4 +- src/Server/Status/Processes.php | 2 +- src/Setup/Index.php | 4 +- src/Sql.php | 25 +- src/Table/Search.php | 2 +- src/Table/Table.php | 22 +- src/Tracking/Tracker.php | 14 +- src/Tracking/Tracking.php | 26 +- src/Transformations.php | 8 +- src/UniqueCondition.php | 4 +- src/UserPrivilegesFactory.php | 2 +- src/Util.php | 11 +- 68 files changed, 298 insertions(+), 589 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8bab657995..c2aacf537f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -237,7 +237,7 @@ parameters: - message: '#^Loose comparison via "\=\=" is not allowed\.$#' identifier: equal.notAllowed - count: 2 + count: 1 path: src/Advisory/Advisor.php - @@ -495,18 +495,6 @@ parameters: count: 3 path: src/Config.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 2 - path: src/Config.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Config.php - - message: '#^Method PhpMyAdmin\\Config\:\:getChangeLogFilePath\(\) should return string but returns mixed\.$#' identifier: return.type @@ -642,12 +630,6 @@ parameters: count: 5 path: src/Config/ConfigFile.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Config/ConfigFile.php - - message: '#^Method PhpMyAdmin\\Config\\ConfigFile\:\:getCanonicalPath\(\) should return string but returns string\|null\.$#' identifier: return.type @@ -1078,9 +1060,9 @@ parameters: path: src/Config/PageSettings.php - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 2 + message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#' + identifier: booleanAnd.rightNotBoolean + count: 1 path: src/Config/PageSettings.php - @@ -1095,12 +1077,6 @@ parameters: count: 4 path: src/Config/ServerConfigChecks.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Config/ServerConfigChecks.php - - message: '#^Only booleans are allowed in &&, mixed given on the left side\.$#' identifier: booleanAnd.leftNotBoolean @@ -1476,18 +1452,6 @@ parameters: count: 1 path: src/ConfigStorage/Relation.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/ConfigStorage/Relation.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 21 - path: src/ConfigStorage/Relation.php - - message: '#^Method PhpMyAdmin\\ConfigStorage\\Relation\:\:getChildReferences\(\) should return array\\>\> but returns array\\.$#' identifier: return.type @@ -1698,6 +1662,12 @@ parameters: count: 2 path: src/ConfigStorage/Relation.php + - + message: '#^Strict comparison using \!\=\= between array\ and '''' will always evaluate to true\.$#' + identifier: notIdentical.alwaysTrue + count: 1 + path: src/ConfigStorage/Relation.php + - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\: @@ -1812,12 +1782,6 @@ parameters: count: 1 path: src/Controllers/Database/DesignerController.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Controllers/Database/DesignerController.php - - message: '#^Parameter \#1 \$db of method PhpMyAdmin\\Database\\Designer\:\:getHtmlForEditOrDeletePages\(\) expects string, string\|null given\.$#' identifier: argument.type @@ -2103,12 +2067,6 @@ parameters: count: 1 path: src/Controllers/Database/Structure/EmptyTableController.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Controllers/Database/Structure/FavoriteTableController.php - - message: '#^Cannot cast mixed to string\.$#' identifier: cast.string @@ -2181,12 +2139,6 @@ parameters: count: 2 path: src/Controllers/Database/StructureController.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 2 - path: src/Controllers/Database/StructureController.php - - message: '#^Method PhpMyAdmin\\Controllers\\Database\\StructureController\:\:getStuffForEngineTypeTable\(\) should return array\{array\, string, string, string, string, int, bool, int\} but returns array\{mixed, mixed, mixed, mixed, mixed, mixed, bool, mixed\}\.$#' identifier: return.type @@ -2397,16 +2349,10 @@ parameters: count: 5 path: src/Controllers/HomeController.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Controllers/HomeController.php - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' identifier: equal.notAllowed - count: 6 + count: 1 path: src/Controllers/HomeController.php - @@ -2469,12 +2415,6 @@ parameters: count: 2 path: src/Controllers/Import/ImportController.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Controllers/Import/ImportController.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -2487,6 +2427,12 @@ parameters: count: 1 path: src/Controllers/Import/ImportController.php + - + message: '#^Result of && is always false\.$#' + identifier: booleanAnd.alwaysFalse + count: 1 + path: src/Controllers/Import/ImportController.php + - message: '#^Result of \|\| is always true\.$#' identifier: booleanOr.alwaysTrue @@ -2517,6 +2463,12 @@ parameters: count: 1 path: src/Controllers/Import/ImportController.php + - + message: '#^Strict comparison using \=\=\= between int and \*NEVER\* will always evaluate to false\.$#' + identifier: identical.alwaysFalse + count: 1 + path: src/Controllers/Import/ImportController.php + - message: '#^Cannot access offset ''go_back_url'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -2613,12 +2565,6 @@ parameters: count: 1 path: src/Controllers/Operations/DatabaseController.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Controllers/Operations/DatabaseController.php - - message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#' identifier: booleanAnd.rightNotBoolean @@ -3357,12 +3303,6 @@ parameters: count: 2 path: src/Controllers/Table/FindReplaceController.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 2 - path: src/Controllers/Table/FindReplaceController.php - - message: '#^Parameter \#1 \$identifier of static method PhpMyAdmin\\Util\:\:backquote\(\) expects string\|Stringable\|null, mixed given\.$#' identifier: argument.type @@ -3597,12 +3537,6 @@ parameters: count: 6 path: src/Controllers/Table/ReplaceController.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Controllers/Table/ReplaceController.php - - message: '#^Method PhpMyAdmin\\Controllers\\Table\\ReplaceController\:\:getParamsForUpdateOrInsert\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -3615,6 +3549,12 @@ parameters: count: 1 path: src/Controllers/Table/ReplaceController.php + - + message: '#^Only booleans are allowed in an if condition, mixed given\.$#' + identifier: if.condNotBoolean + count: 1 + path: src/Controllers/Table/ReplaceController.php + - message: '#^PHPDoc tag @var for variable \$relationFields has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -3723,12 +3663,6 @@ parameters: count: 1 path: src/Controllers/Table/SearchController.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 2 - path: src/Controllers/Table/SearchController.php - - message: '#^Parameter \#1 \$column of method PhpMyAdmin\\Controllers\\Table\\SearchController\:\:getColumnMinMax\(\) expects string, mixed given\.$#' identifier: argument.type @@ -4224,7 +4158,13 @@ parameters: - message: '#^Loose comparison via "\=\=" is not allowed\.$#' identifier: equal.notAllowed - count: 5 + count: 2 + path: src/Controllers/Table/ZoomSearchController.php + + - + message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#' + identifier: booleanAnd.rightNotBoolean + count: 1 path: src/Controllers/Table/ZoomSearchController.php - @@ -4335,12 +4275,6 @@ parameters: count: 2 path: src/Controllers/Triggers/IndexController.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Controllers/VersionCheckController.php - - message: '#^Binary operation "\." between "\\r\\n \(" and mixed results in an error\.$#' identifier: binaryOp.invalid @@ -4776,12 +4710,6 @@ parameters: count: 11 path: src/Database/CentralColumns.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 2 - path: src/Database/CentralColumns.php - - message: '#^Method PhpMyAdmin\\Database\\CentralColumns\:\:findExistingColNames\(\) should return array\ but returns list\\.$#' identifier: return.type @@ -4956,12 +4884,6 @@ parameters: count: 1 path: src/Database/Designer/Common.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Database/Designer/Common.php - - message: '#^Only booleans are allowed in a negated boolean, PhpMyAdmin\\Dbal\\ResultInterface\|false given\.$#' identifier: booleanNot.exprNotBoolean @@ -5352,12 +5274,6 @@ parameters: count: 4 path: src/Database/Search.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Database/Search.php - - message: '#^Property PhpMyAdmin\\Database\\Search\:\:\$criteriaTables \(array\\) does not accept array\\.$#' identifier: assign.propertyType @@ -5436,12 +5352,6 @@ parameters: count: 1 path: src/Dbal/DatabaseInterface.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Dbal/DatabaseInterface.php - - message: '#^Method PhpMyAdmin\\Dbal\\DatabaseInterface\:\:getColumnNames\(\) should return list\ but returns list\\.$#' identifier: return.type @@ -5847,18 +5757,6 @@ parameters: count: 23 path: src/Display/Results.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 6 - path: src/Display/Results.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 3 - path: src/Display/Results.php - - message: '#^Method PhpMyAdmin\\Display\\Results\:\:getSortByKeyDropDown\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -5898,7 +5796,7 @@ parameters: - message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#' identifier: booleanNot.exprNotBoolean - count: 4 + count: 5 path: src/Display/Results.php - @@ -6108,12 +6006,6 @@ parameters: count: 1 path: src/Encoding.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 2 - path: src/Encoding.php - - message: '#^Method PhpMyAdmin\\Encoding\:\:convertString\(\) should return string but returns string\|false\.$#' identifier: return.type @@ -6354,12 +6246,6 @@ parameters: count: 2 path: src/Error/ErrorReport.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Error/ErrorReport.php - - message: '#^Only booleans are allowed in a negated boolean, int given\.$#' identifier: booleanNot.exprNotBoolean @@ -6459,12 +6345,6 @@ parameters: count: 4 path: src/Export/Export.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Export/Export.php - - message: '#^Method PhpMyAdmin\\Export\\Export\:\:compress\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -6675,12 +6555,6 @@ parameters: count: 1 path: src/Favorites/RecentFavoriteTables.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/FieldMetadata.php - - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\: @@ -6738,12 +6612,6 @@ parameters: count: 2 path: src/File.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/File.php - - message: '#^Method PhpMyAdmin\\File\:\:getCompression\(\) should return string but returns string\|false\.$#' identifier: return.type @@ -7413,13 +7281,7 @@ parameters: - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed - count: 3 - path: src/Git.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 + count: 2 path: src/Git.php - @@ -7605,12 +7467,6 @@ parameters: count: 7 path: src/Html/Generator.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Html/Generator.php - - message: '#^Only booleans are allowed in an if condition, string\|false given\.$#' identifier: if.condNotBoolean @@ -7926,18 +7782,6 @@ parameters: count: 1 path: src/Import/Import.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Import/Import.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Import/Import.php - - message: '#^Only booleans are allowed in &&, PhpMyAdmin\\Dbal\\ResultInterface\|false given on the left side\.$#' identifier: booleanAnd.leftNotBoolean @@ -8385,12 +8229,6 @@ parameters: count: 4 path: src/Menu.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 3 - path: src/Menu.php - - message: '#^Method PhpMyAdmin\\Menu\:\:getAllowedTabs\(\) should return array\ but returns mixed\.$#' identifier: return.type @@ -8481,7 +8319,7 @@ parameters: - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed - count: 2 + count: 1 path: src/Navigation/NavigationTree.php - @@ -8631,12 +8469,6 @@ parameters: count: 4 path: src/Navigation/Nodes/Node.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 2 - path: src/Navigation/Nodes/Node.php - - message: '#^Method PhpMyAdmin\\Navigation\\Nodes\\Node\:\:getDatabasesToSearch\(\) should return array\ but returns list\\|string\.$#' identifier: return.type @@ -8844,7 +8676,7 @@ parameters: - message: '#^Loose comparison via "\=\=" is not allowed\.$#' identifier: equal.notAllowed - count: 2 + count: 1 path: src/Normalization.php - @@ -9051,18 +8883,6 @@ parameters: count: 8 path: src/Operations.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Operations.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 3 - path: src/Operations.php - - message: '#^Parameter \#1 \$collation of static method PhpMyAdmin\\Util\:\:getCharsetQueryPart\(\) expects string, mixed given\.$#' identifier: argument.type @@ -9378,7 +9198,7 @@ parameters: - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed - count: 2 + count: 1 path: src/Plugins.php - @@ -9453,12 +9273,6 @@ parameters: count: 1 path: src/Plugins/Auth/AuthenticationConfig.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Plugins/Auth/AuthenticationConfig.php - - message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#' identifier: foreach.nonIterable @@ -9516,12 +9330,6 @@ parameters: count: 1 path: src/Plugins/Auth/AuthenticationCookie.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 2 - path: src/Plugins/Auth/AuthenticationCookie.php - - message: '#^Offset ''CaptchaSiteVerifyURL'' on array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\} on left side of \?\? always exists and is not nullable\.$#' identifier: nullCoalesce.offset @@ -9663,12 +9471,6 @@ parameters: count: 2 path: src/Plugins/Auth/AuthenticationSignon.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Plugins/Auth/AuthenticationSignon.php - - message: '#^Parameter \#1 \$id of function session_id expects string\|null, mixed given\.$#' identifier: argument.type @@ -10098,12 +9900,6 @@ parameters: count: 2 path: src/Plugins/Export/ExportMediawiki.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Plugins/Export/ExportMediawiki.php - - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\: @@ -10218,12 +10014,6 @@ parameters: count: 5 path: src/Plugins/Export/ExportOdt.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Plugins/Export/ExportOdt.php - - message: '#^Only booleans are allowed in an if condition, array\|false given\.$#' identifier: if.condNotBoolean @@ -10245,7 +10035,7 @@ parameters: - message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, string\|null given\.$#' identifier: argument.type - count: 7 + count: 8 path: src/Plugins/Export/ExportOdt.php - @@ -10590,7 +10380,7 @@ parameters: - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed - count: 3 + count: 2 path: src/Plugins/Export/ExportTexytext.php - @@ -10890,7 +10680,7 @@ parameters: - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed - count: 4 + count: 3 path: src/Plugins/Export/Helpers/Pdf.php - @@ -10899,6 +10689,12 @@ parameters: count: 6 path: src/Plugins/Export/Helpers/Pdf.php + - + message: '#^Only booleans are allowed in an if condition, mixed given\.$#' + identifier: if.condNotBoolean + count: 1 + path: src/Plugins/Export/Helpers/Pdf.php + - message: '#^Only numeric types are allowed in \-, \(array\|float\|int\) given on the left side\.$#' identifier: minus.leftNonNumeric @@ -11145,13 +10941,13 @@ parameters: - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed - count: 4 + count: 3 path: src/Plugins/Import/ImportCsv.php - message: '#^Loose comparison via "\=\=" is not allowed\.$#' identifier: equal.notAllowed - count: 19 + count: 17 path: src/Plugins/Import/ImportCsv.php - @@ -11232,18 +11028,6 @@ parameters: count: 1 path: src/Plugins/Import/ImportOds.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Plugins/Import/ImportOds.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Plugins/Import/ImportOds.php - - message: '#^Offset ''name'' might not exist on SimpleXMLElement\|null\.$#' identifier: offsetAccess.notFound @@ -11313,12 +11097,6 @@ parameters: count: 1 path: src/Plugins/Import/ImportShp.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Plugins/Import/ImportShp.php - - message: '#^Offset ''dirname'' might not exist on array\{dirname\?\: string, basename\: string, extension\?\: string, filename\: string\}\.$#' identifier: offsetAccess.notFound @@ -11781,7 +11559,7 @@ parameters: - message: '#^Loose comparison via "\=\=" is not allowed\.$#' identifier: equal.notAllowed - count: 5 + count: 2 path: src/Plugins/Schema/Pdf/Pdf.php - @@ -11889,16 +11667,10 @@ parameters: count: 1 path: src/Plugins/Schema/Pdf/PdfRelationSchema.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Plugins/Schema/Pdf/PdfRelationSchema.php - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' identifier: equal.notAllowed - count: 2 + count: 1 path: src/Plugins/Schema/Pdf/PdfRelationSchema.php - @@ -12111,12 +11883,6 @@ parameters: count: 7 path: src/Plugins/Schema/Svg/RelationStatsSvg.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 2 - path: src/Plugins/Schema/Svg/Svg.php - - message: '#^Parameter \#4 \$masterField of method PhpMyAdmin\\Plugins\\Schema\\Svg\\SvgRelationSchema\:\:addRelation\(\) expects string, \(int\|string\) given\.$#' identifier: argument.type @@ -12189,12 +11955,6 @@ parameters: count: 1 path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 2 - path: src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php - - message: '#^Parameter \#1 \.\.\.\$arrays of function array_merge expects array, mixed given\.$#' identifier: argument.type @@ -12327,12 +12087,6 @@ parameters: count: 2 path: src/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php - - message: '#^Binary operation "\." between mixed and string results in an error\.$#' identifier: binaryOp.invalid @@ -12375,12 +12129,6 @@ parameters: count: 2 path: src/Plugins/Transformations/Abs/TextLinkTransformationsPlugin.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 2 - path: src/Plugins/Transformations/Input/Text_Plain_Iptobinary.php - - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\: @@ -12642,12 +12390,6 @@ parameters: count: 2 path: src/Replication/Replication.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Replication/Replication.php - - message: '#^Method PhpMyAdmin\\Replication\\Replication\:\:replicaBinLogPrimary\(\) should return array\{File\?\: string, Position\?\: string\} but returns array\{\}\|array\{File\: string\|null, Position\: string\|null\}\.$#' identifier: return.type @@ -12862,14 +12604,14 @@ parameters: path: src/Routing/Routing.php - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed + message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#' + identifier: booleanAnd.rightNotBoolean count: 1 path: src/Routing/Routing.php - - message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#' - identifier: booleanAnd.rightNotBoolean + message: '#^Only booleans are allowed in an if condition, int\<0, max\>\|false given\.$#' + identifier: if.condNotBoolean count: 1 path: src/Routing/Routing.php @@ -13137,7 +12879,7 @@ parameters: - message: '#^Cannot cast mixed to int\.$#' identifier: cast.int - count: 4 + count: 6 path: src/Server/Privileges.php - @@ -13167,7 +12909,7 @@ parameters: - message: '#^Loose comparison via "\=\=" is not allowed\.$#' identifier: equal.notAllowed - count: 6 + count: 4 path: src/Server/Privileges.php - @@ -13665,12 +13407,6 @@ parameters: count: 3 path: src/Server/Status/Processes.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Server/Status/Processes.php - - message: '#^Method PhpMyAdmin\\Server\\Status\\Processes\:\:getList\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -13815,24 +13551,18 @@ parameters: count: 4 path: src/Setup/Index.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Setup/Index.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Setup/Index.php - - message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#' identifier: booleanNot.exprNotBoolean count: 1 path: src/Setup/Index.php + - + message: '#^Only booleans are allowed in an if condition, mixed given\.$#' + identifier: if.condNotBoolean + count: 1 + path: src/Setup/Index.php + - message: '#^PHPDoc tag @var with type PhpMyAdmin\\Config\\Forms\\BaseForm is not subtype of native type string\|null\.$#' identifier: varTag.nativeType @@ -13935,30 +13665,18 @@ parameters: count: 1 path: src/Sql.php + - + message: '#^Cannot cast mixed to int\.$#' + identifier: cast.int + count: 1 + path: src/Sql.php + - message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' identifier: empty.notAllowed count: 10 path: src/Sql.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 7 - path: src/Sql.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 6 - path: src/Sql.php - - - - message: '#^Method PhpMyAdmin\\Sql\:\:calculatePosForLastPage\(\) should return int but returns mixed\.$#' - identifier: return.type - count: 1 - path: src/Sql.php - - message: '#^Method PhpMyAdmin\\Sql\:\:countQueryResults\(\) should return int\|numeric\-string but returns float\|int\|numeric\-string\.$#' identifier: return.type @@ -13983,6 +13701,12 @@ parameters: count: 1 path: src/Sql.php + - + message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#' + identifier: booleanAnd.rightNotBoolean + count: 3 + path: src/Sql.php + - message: '#^Only booleans are allowed in &&, string given on the left side\.$#' identifier: booleanAnd.leftNotBoolean @@ -14007,6 +13731,12 @@ parameters: count: 1 path: src/Sql.php + - + message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#' + identifier: booleanNot.exprNotBoolean + count: 1 + path: src/Sql.php + - message: '#^Only booleans are allowed in an if condition, PhpMyAdmin\\Dbal\\ResultInterface\|false given\.$#' identifier: if.condNotBoolean @@ -14370,12 +14100,6 @@ parameters: count: 2 path: src/Table/Search.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/Table/Search.php - - message: '#^Parameter \#1 \$gisString of static method PhpMyAdmin\\Utils\\Gis\:\:createData\(\) expects string, mixed given\.$#' identifier: argument.type @@ -14523,13 +14247,7 @@ parameters: - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed - count: 12 - path: src/Table/Table.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 2 + count: 3 path: src/Table/Table.php - @@ -14790,18 +14508,6 @@ parameters: count: 1 path: src/Tracking/Tracker.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Tracking/Tracker.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 7 - path: src/Tracking/Tracker.php - - message: '#^Method PhpMyAdmin\\Tracking\\Tracker\:\:isTracked\(\) should return bool but returns mixed\.$#' identifier: return.type @@ -14920,8 +14626,8 @@ parameters: path: src/Tracking/Tracking.php - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed + message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#' + identifier: booleanAnd.rightNotBoolean count: 13 path: src/Tracking/Tracking.php @@ -14967,18 +14673,6 @@ parameters: count: 1 path: src/Tracking/Tracking.php - - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' - identifier: notEqual.notAllowed - count: 1 - path: src/Transformations.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 4 - path: src/Transformations.php - - message: '#^Method PhpMyAdmin\\Transformations\:\:getClassName\(\) should return class\-string\ but returns string\.$#' identifier: return.type @@ -15084,13 +14778,7 @@ parameters: - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed - count: 3 - path: src/UniqueCondition.php - - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 + count: 2 path: src/UniqueCondition.php - @@ -15234,12 +14922,6 @@ parameters: count: 1 path: src/UserPreferences.php - - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' - identifier: equal.notAllowed - count: 1 - path: src/UserPrivilegesFactory.php - - message: '#^Only booleans are allowed in a negated boolean, PhpMyAdmin\\Dbal\\ResultInterface\|false given\.$#' identifier: booleanNot.exprNotBoolean @@ -15381,13 +15063,13 @@ parameters: - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed - count: 3 + count: 2 path: src/Util.php - message: '#^Loose comparison via "\=\=" is not allowed\.$#' identifier: equal.notAllowed - count: 6 + count: 3 path: src/Util.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ee4d3b4c71..790f27269f 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -480,6 +480,9 @@ + + + @@ -613,6 +616,9 @@ + + + @@ -660,6 +666,9 @@ + + + config->selectedServer[$feature])]]> @@ -2933,6 +2942,7 @@ + collation)]]> @@ -5887,9 +5897,6 @@ - - - @@ -7905,6 +7912,9 @@ + + + @@ -8124,10 +8134,12 @@ + + @@ -8402,7 +8414,6 @@ - @@ -8417,8 +8428,6 @@ statement->where[0]->expr]]> - - @@ -8465,6 +8474,9 @@ isUnique()]]> + + + @@ -8910,9 +8922,6 @@ - - - list->tokens]]> fields[0]->table]]> @@ -8988,6 +8997,21 @@ + + + + + + + + + + + + + + + diff --git a/src/Advisory/Advisor.php b/src/Advisory/Advisor.php index 8f62d6831f..c137e06134 100644 --- a/src/Advisory/Advisor.php +++ b/src/Advisory/Advisor.php @@ -396,8 +396,7 @@ class Advisor } $num = round($num, $precision); - - if ($num == 0) { + if ($num === 0.0) { $num = '<' . 10 ** (-$precision); } diff --git a/src/Config.php b/src/Config.php index e98c9469bc..a40bb4b0fa 100644 --- a/src/Config.php +++ b/src/Config.php @@ -285,7 +285,7 @@ class Config (! isset($configData['ThemeDefault']) && $themeManager->theme->getId() !== 'original') || isset($configData['ThemeDefault']) - && $configData['ThemeDefault'] != $themeManager->theme->getId() + && $configData['ThemeDefault'] !== $themeManager->theme->getId() ) { $this->setUserValue( null, @@ -295,7 +295,7 @@ class Config ); } } elseif ( - $this->settings['ThemeDefault'] != $themeManager->theme->getId() + $this->settings['ThemeDefault'] !== $themeManager->theme->getId() && $themeManager->themeExists($this->settings['ThemeDefault']) ) { // no cookie - read default from settings @@ -536,7 +536,7 @@ class Config } elseif (Util::getProtoFromForwardedHeader(Core::getEnv('HTTP_FORWARDED')) === 'https') { // RFC 7239 Forwarded header $isHttps = true; - } elseif (Core::getEnv('SERVER_PORT') == 443) { + } elseif ((int) Core::getEnv('SERVER_PORT') === 443) { $isHttps = true; } diff --git a/src/Config/ConfigFile.php b/src/Config/ConfigFile.php index 3f8fed320c..0954aee4f9 100644 --- a/src/Config/ConfigFile.php +++ b/src/Config/ConfigFile.php @@ -430,7 +430,7 @@ class ConfigFile unset($_SESSION[$this->id]['Servers'][$lastServer]); - if (! isset($_SESSION[$this->id]['ServerDefault']) || $_SESSION[$this->id]['ServerDefault'] != $lastServer) { + if (! isset($_SESSION[$this->id]['ServerDefault']) || $_SESSION[$this->id]['ServerDefault'] !== $lastServer) { return; } diff --git a/src/Config/PageSettings.php b/src/Config/PageSettings.php index 540f1e6dc7..e43013ea63 100644 --- a/src/Config/PageSettings.php +++ b/src/Config/PageSettings.php @@ -55,7 +55,7 @@ class PageSettings return; } - if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') { + if (isset($_REQUEST['printview']) && $_REQUEST['printview']) { return; } @@ -72,7 +72,7 @@ class PageSettings // Process form $error = null; - if (isset($_POST['submit_save']) && $_POST['submit_save'] == $formGroupName) { + if (isset($_POST['submit_save']) && $_POST['submit_save'] === $formGroupName) { $error = $this->processPageSettings($formDisplay, $configFile); } diff --git a/src/Config/ServerConfigChecks.php b/src/Config/ServerConfigChecks.php index 23ce39c98f..c43c216a28 100644 --- a/src/Config/ServerConfigChecks.php +++ b/src/Config/ServerConfigChecks.php @@ -351,7 +351,7 @@ class ServerConfigChecks // $cfg['LoginCookieStore'] // LoginCookieValidity must be less or equal to LoginCookieStore if ( - $this->cfg->getValue('LoginCookieStore') == 0 + $this->cfg->getValue('LoginCookieStore') === 0 || $loginCookieValidity <= $this->cfg->getValue('LoginCookieStore') ) { return; diff --git a/src/ConfigStorage/Relation.php b/src/ConfigStorage/Relation.php index a4dfedb7ce..ec4673e161 100644 --- a/src/ConfigStorage/Relation.php +++ b/src/ConfigStorage/Relation.php @@ -160,43 +160,43 @@ class Relation } foreach ($tables as $table) { - if ($table == $this->config->selectedServer['bookmarktable']) { + if ($table === $this->config->selectedServer['bookmarktable']) { $relationParams['bookmark'] = $table; - } elseif ($table == $this->config->selectedServer['relation']) { + } elseif ($table === $this->config->selectedServer['relation']) { $relationParams['relation'] = $table; - } elseif ($table == $this->config->selectedServer['table_info']) { + } elseif ($table === $this->config->selectedServer['table_info']) { $relationParams['table_info'] = $table; - } elseif ($table == $this->config->selectedServer['table_coords']) { + } elseif ($table === $this->config->selectedServer['table_coords']) { $relationParams['table_coords'] = $table; - } elseif ($table == $this->config->selectedServer['column_info']) { + } elseif ($table === $this->config->selectedServer['column_info']) { $relationParams['column_info'] = $table; - } elseif ($table == $this->config->selectedServer['pdf_pages']) { + } elseif ($table === $this->config->selectedServer['pdf_pages']) { $relationParams['pdf_pages'] = $table; - } elseif ($table == $this->config->selectedServer['history']) { + } elseif ($table === $this->config->selectedServer['history']) { $relationParams['history'] = $table; - } elseif ($table == $this->config->selectedServer['recent']) { + } elseif ($table === $this->config->selectedServer['recent']) { $relationParams['recent'] = $table; - } elseif ($table == $this->config->selectedServer['favorite']) { + } elseif ($table === $this->config->selectedServer['favorite']) { $relationParams['favorite'] = $table; - } elseif ($table == $this->config->selectedServer['table_uiprefs']) { + } elseif ($table === $this->config->selectedServer['table_uiprefs']) { $relationParams['table_uiprefs'] = $table; - } elseif ($table == $this->config->selectedServer['tracking']) { + } elseif ($table === $this->config->selectedServer['tracking']) { $relationParams['tracking'] = $table; - } elseif ($table == $this->config->selectedServer['userconfig']) { + } elseif ($table === $this->config->selectedServer['userconfig']) { $relationParams['userconfig'] = $table; - } elseif ($table == $this->config->selectedServer['users']) { + } elseif ($table === $this->config->selectedServer['users']) { $relationParams['users'] = $table; - } elseif ($table == $this->config->selectedServer['usergroups']) { + } elseif ($table === $this->config->selectedServer['usergroups']) { $relationParams['usergroups'] = $table; - } elseif ($table == $this->config->selectedServer['navigationhiding']) { + } elseif ($table === $this->config->selectedServer['navigationhiding']) { $relationParams['navigationhiding'] = $table; - } elseif ($table == $this->config->selectedServer['savedsearches']) { + } elseif ($table === $this->config->selectedServer['savedsearches']) { $relationParams['savedsearches'] = $table; - } elseif ($table == $this->config->selectedServer['central_columns']) { + } elseif ($table === $this->config->selectedServer['central_columns']) { $relationParams['central_columns'] = $table; - } elseif ($table == $this->config->selectedServer['designer_settings']) { + } elseif ($table === $this->config->selectedServer['designer_settings']) { $relationParams['designer_settings'] = $table; - } elseif ($table == $this->config->selectedServer['export_templates']) { + } elseif ($table === $this->config->selectedServer['export_templates']) { $relationParams['export_templates'] = $table; } } @@ -421,7 +421,7 @@ class Relation foreach ($internalRelations[$table] as $field => $relations) { if ( ($column !== '' && $column !== $field) - || (isset($foreign[$field]) && $foreign[$field] != '') + || (isset($foreign[$field]) && $foreign[$field] !== '') ) { continue; } @@ -750,7 +750,7 @@ class Relation // beginning of dropdown $ret = ''; $topCount = count($top); - if ($max == -1 || $topCount < $max) { + if ($max === -1 || $topCount < $max) { $ret .= implode('', $top); if ($foreignDisplay && $topCount > 0) { // this empty option is to visually mark the beginning of the @@ -796,7 +796,7 @@ class Relation } $foreigner = $this->searchColumnInForeigners($foreigners, $field); - if ($foreigner == false) { + if ($foreigner === false || $foreigner === []) { break; } diff --git a/src/Controllers/Database/DesignerController.php b/src/Controllers/Database/DesignerController.php index 00901a4aa1..68dddfcfe9 100644 --- a/src/Controllers/Database/DesignerController.php +++ b/src/Controllers/Database/DesignerController.php @@ -189,7 +189,7 @@ final class DesignerController implements InvocableController } $selectedPage = null; - if ($displayPage != -1) { + if ($displayPage !== -1) { $selectedPage = $this->designerCommon->getPageName($displayPage); } diff --git a/src/Controllers/Database/Structure/FavoriteTableController.php b/src/Controllers/Database/Structure/FavoriteTableController.php index 7f4d1db6f8..678859c3b1 100644 --- a/src/Controllers/Database/Structure/FavoriteTableController.php +++ b/src/Controllers/Database/Structure/FavoriteTableController.php @@ -80,7 +80,7 @@ final readonly class FavoriteTableController implements InvocableController } elseif (isset($_REQUEST['add_favorite'])) { if (! $alreadyFavorite) { $numTables = count($favoriteInstance->getTables()); - if ($numTables == $this->config->settings['NumFavoriteTables']) { + if ($numTables === $this->config->settings['NumFavoriteTables']) { $changes = false; } else { // Otherwise add to favorite list. diff --git a/src/Controllers/Database/StructureController.php b/src/Controllers/Database/StructureController.php index a9903bce3d..83960fcb0c 100644 --- a/src/Controllers/Database/StructureController.php +++ b/src/Controllers/Database/StructureController.php @@ -596,7 +596,7 @@ final class StructureController implements InvocableController $do = (is_string($searchDoDBInTruename) && $searchDoDBInTruename !== '') || (is_string($searchDoDBInDB) && $searchDoDBInDB !== '') - || ($nbServReplicaDoDb == 0 && $nbServReplicaIgnoreDb == 0) + || ($nbServReplicaDoDb === 0 && $nbServReplicaIgnoreDb === 0) || $this->hasTable($replicaInfo['Wild_Do_Table'], $table); $searchDb = array_search(Current::$database, $replicaInfo['Ignore_DB']); diff --git a/src/Controllers/HomeController.php b/src/Controllers/HomeController.php index 4b59aa5b67..cd5719b0a9 100644 --- a/src/Controllers/HomeController.php +++ b/src/Controllers/HomeController.php @@ -102,7 +102,7 @@ final class HomeController implements InvocableController $hasServer = Current::$server > 0 || count($this->config->settings['Servers']) > 1; if ($hasServer) { - $hasServerSelection = $this->config->settings['ServerDefault'] == 0 + $hasServerSelection = $this->config->settings['ServerDefault'] === 0 || ( $this->config->settings['NavigationDisplayServers'] && ( @@ -188,14 +188,14 @@ final class HomeController implements InvocableController $relationParameters = $relation->getRelationParameters(); if ( ! $relationParameters->hasAllFeatures() - && $this->config->settings['PmaNoRelation_DisableWarning'] == false + && ! $this->config->settings['PmaNoRelation_DisableWarning'] ) { $messageText = __( 'The phpMyAdmin configuration storage is not completely ' . 'configured, some extended features have been deactivated. ' . '%sFind out why%s. ', ); - if ($this->config->settings['ZeroConf'] == true) { + if ($this->config->settings['ZeroConf']) { $messageText .= '
' . __('Or alternately go to \'Operations\' tab of any database to set it up there.'); } @@ -253,7 +253,7 @@ final class HomeController implements InvocableController { $this->checkPhpExtensionsRequirements(); - if ($this->config->settings['LoginCookieValidityDisableWarning'] == false) { + if (! $this->config->settings['LoginCookieValidityDisableWarning']) { /** * Check whether session.gc_maxlifetime limits session validity. */ @@ -276,7 +276,7 @@ final class HomeController implements InvocableController * Check whether LoginCookieValidity is limited by LoginCookieStore. */ if ( - $this->config->settings['LoginCookieStore'] != 0 + $this->config->settings['LoginCookieStore'] !== 0 && $this->config->settings['LoginCookieStore'] < $this->config->settings['LoginCookieValidity'] ) { $this->errors[] = [ @@ -361,7 +361,7 @@ final class HomeController implements InvocableController * Warning about Suhosin only if its simulation mode is not enabled */ if ( - $this->config->settings['SuhosinDisableWarning'] == false + ! $this->config->settings['SuhosinDisableWarning'] && ini_get('suhosin.request.max_value_length') && ini_get('suhosin.simulation') == '0' ) { diff --git a/src/Controllers/Import/ImportController.php b/src/Controllers/Import/ImportController.php index b3a619bf8e..db8fe1694d 100644 --- a/src/Controllers/Import/ImportController.php +++ b/src/Controllers/Import/ImportController.php @@ -560,7 +560,7 @@ final readonly class ImportController implements InvocableController Current::$message->addParamHtml(''); Current::$message->addParamHtml(''); - if (ImportSettings::$offset === 0 || (isset($originalSkip) && $originalSkip == ImportSettings::$offset)) { + if (ImportSettings::$offset === 0 || (isset($originalSkip) && $originalSkip === ImportSettings::$offset)) { Current::$message->addText( __( 'However on last run no data has been parsed,' diff --git a/src/Controllers/Operations/DatabaseController.php b/src/Controllers/Operations/DatabaseController.php index 8cbfa2aebd..731d6eb779 100644 --- a/src/Controllers/Operations/DatabaseController.php +++ b/src/Controllers/Operations/DatabaseController.php @@ -270,7 +270,7 @@ final readonly class DatabaseController implements InvocableController $collations = Charsets::getCollations($this->dbi, $this->config->selectedServer['DisableIS']); if ( - ! $relationParameters->hasAllFeatures() && $this->config->settings['PmaNoRelation_DisableWarning'] == false + ! $relationParameters->hasAllFeatures() && ! $this->config->settings['PmaNoRelation_DisableWarning'] ) { Current::$message = Message::notice( __( diff --git a/src/Controllers/Table/FindReplaceController.php b/src/Controllers/Table/FindReplaceController.php index ea54b31a37..287242b658 100644 --- a/src/Controllers/Table/FindReplaceController.php +++ b/src/Controllers/Table/FindReplaceController.php @@ -143,7 +143,7 @@ final class FindReplaceController implements InvocableController $type = $row->type; // reformat mysql query output - if (strncasecmp($type, 'set', 3) == 0 || strncasecmp($type, 'enum', 4) == 0) { + if (strncasecmp($type, 'set', 3) === 0 || strncasecmp($type, 'enum', 4) === 0) { $type = str_replace(',', ', ', $type); } else { // strip the "BINARY" attribute, except if we find "BINARY(" because diff --git a/src/Controllers/Table/ReplaceController.php b/src/Controllers/Table/ReplaceController.php index a837e53796..41ae3ac4fe 100644 --- a/src/Controllers/Table/ReplaceController.php +++ b/src/Controllers/Table/ReplaceController.php @@ -414,7 +414,7 @@ final class ReplaceController implements InvocableController } } - if ($request->getParsedBodyParam('do_transformations') == true) { + if ($request->getParsedBodyParam('do_transformations')) { $editedValues = []; parse_str($request->getParsedBodyParamAsString('transform_fields_list'), $editedValues); diff --git a/src/Controllers/Table/SearchController.php b/src/Controllers/Table/SearchController.php index 4ab1192df2..996b1a3ff3 100644 --- a/src/Controllers/Table/SearchController.php +++ b/src/Controllers/Table/SearchController.php @@ -121,7 +121,7 @@ final class SearchController implements InvocableController } // reformat mysql query output - if (strncasecmp($type, 'set', 3) == 0 || strncasecmp($type, 'enum', 4) == 0) { + if (strncasecmp($type, 'set', 3) === 0 || strncasecmp($type, 'enum', 4) === 0) { $type = str_replace(',', ', ', $type); } else { // strip the "BINARY" attribute, except if we find "BINARY(" because diff --git a/src/Controllers/Table/ZoomSearchController.php b/src/Controllers/Table/ZoomSearchController.php index 5cf6d32c2f..4bf05f942a 100644 --- a/src/Controllers/Table/ZoomSearchController.php +++ b/src/Controllers/Table/ZoomSearchController.php @@ -138,7 +138,7 @@ final class ZoomSearchController implements InvocableController /** * Handle AJAX request for data row on point select */ - if (isset($_POST['get_data_row']) && $_POST['get_data_row'] == true) { + if (isset($_POST['get_data_row']) && $_POST['get_data_row']) { $this->getDataRowAction(); return $this->response->response(); @@ -210,7 +210,7 @@ final class ZoomSearchController implements InvocableController } // reformat mysql query output - if (strncasecmp($type, 'set', 3) == 0 || strncasecmp($type, 'enum', 4) == 0) { + if (strncasecmp($type, 'set', 3) === 0 || strncasecmp($type, 'enum', 4) === 0) { $type = str_replace(',', ', ', $type); } else { // strip the "BINARY" attribute, except if we find "BINARY(" because diff --git a/src/Controllers/VersionCheckController.php b/src/Controllers/VersionCheckController.php index cfed961ec8..169d9d02c5 100644 --- a/src/Controllers/VersionCheckController.php +++ b/src/Controllers/VersionCheckController.php @@ -39,7 +39,7 @@ final class VersionCheckController implements InvocableController $latestCompatible = $this->versionInformation->getLatestCompatibleVersion($versionDetails); $version = ''; $date = ''; - if ($latestCompatible != null) { + if ($latestCompatible !== null) { $version = $latestCompatible->version; $date = $latestCompatible->date; } diff --git a/src/Database/CentralColumns.php b/src/Database/CentralColumns.php index ce0bdd89e0..6d51356e3c 100644 --- a/src/Database/CentralColumns.php +++ b/src/Database/CentralColumns.php @@ -614,7 +614,7 @@ class CentralColumns private function getHtmlForEditTableRow(array $row, int $rowNum): string { $meta = []; - if (! isset($row['col_default']) || $row['col_default'] == '') { + if (! isset($row['col_default']) || $row['col_default'] === '') { $meta['DefaultType'] = 'NONE'; } elseif ($row['col_default'] === 'CURRENT_TIMESTAMP' || $row['col_default'] === 'current_timestamp()') { $meta['DefaultType'] = 'CURRENT_TIMESTAMP'; @@ -819,7 +819,7 @@ class CentralColumns $rowNum = 0; foreach ($rowsList as $row) { $rowsMeta[$rowNum] = []; - if (! isset($row['col_default']) || $row['col_default'] == '') { + if (! isset($row['col_default']) || $row['col_default'] === '') { $rowsMeta[$rowNum]['DefaultType'] = 'NONE'; } elseif ($row['col_default'] === 'CURRENT_TIMESTAMP' || $row['col_default'] === 'current_timestamp()') { $rowsMeta[$rowNum]['DefaultType'] = 'CURRENT_TIMESTAMP'; diff --git a/src/Database/Designer/Common.php b/src/Database/Designer/Common.php index 0700e5d731..65ae036667 100644 --- a/src/Database/Designer/Common.php +++ b/src/Database/Designer/Common.php @@ -352,7 +352,7 @@ class Common } $defaultPageNo = $this->getDefaultPage($db); - if ($defaultPageNo != -1) { + if ($defaultPageNo !== -1) { return $defaultPageNo; } diff --git a/src/Database/Search.php b/src/Database/Search.php index 8ea1301722..a5563094df 100644 --- a/src/Database/Search.php +++ b/src/Database/Search.php @@ -193,7 +193,7 @@ class Search foreach ($allColumns as $column) { if ( $this->criteriaColumnName !== '' - && $column->field != $this->criteriaColumnName + && $column->field !== $this->criteriaColumnName ) { continue; } diff --git a/src/Dbal/DatabaseInterface.php b/src/Dbal/DatabaseInterface.php index 690491fa7e..c5813c0fe3 100644 --- a/src/Dbal/DatabaseInterface.php +++ b/src/Dbal/DatabaseInterface.php @@ -1000,8 +1000,8 @@ class DatabaseInterface string $value, ConnectionType $connectionType = ConnectionType::User, ): void { - $currentValue = $this->getVariable($var, self::GETVAR_SESSION, $connectionType); - if ($currentValue == $value) { + $currentValue = (string) $this->getVariable($var, self::GETVAR_SESSION, $connectionType); + if ($currentValue === $value) { return; } diff --git a/src/Display/Results.php b/src/Display/Results.php index 0303216bb9..e962b19a07 100644 --- a/src/Display/Results.php +++ b/src/Display/Results.php @@ -449,8 +449,8 @@ class Results // Displays edit/delete/sort/insert links? if ( $isLink - && $previousTable != '' - && $field->table != '' + && $previousTable !== '' + && $field->table !== '' && $field->table !== $previousTable ) { // don't display links @@ -461,14 +461,14 @@ class Results // Always display print view link $hasPrintLink = true; - if ($field->table == '') { + if ($field->table === '') { continue; } $previousTable = $field->table; } - if ($previousTable == '') { // no table for any of the columns + if ($previousTable === '') { // no table for any of the columns // don't display links $hasEditLink = false; $deleteLink = DeleteLinkEnum::NO_DELETE; @@ -1072,7 +1072,7 @@ class Results { if ( isset($_SESSION['tmpval']['possible_as_geometry']) - && $_SESSION['tmpval']['possible_as_geometry'] == false + && ! $_SESSION['tmpval']['possible_as_geometry'] && $_SESSION['tmpval']['geoOption'] === self::GEOMETRY_DISP_GEOM ) { $_SESSION['tmpval']['geoOption'] = self::GEOMETRY_DISP_WKT; @@ -1742,11 +1742,11 @@ class Results } $trClass = []; - if ($this->config->settings['BrowsePointerEnable'] != true) { + if (! $this->config->settings['BrowsePointerEnable']) { $trClass[] = 'nopointer'; } - if ($this->config->settings['BrowseMarkerEnable'] != true) { + if (! $this->config->settings['BrowseMarkerEnable']) { $trClass[] = 'nomarker'; } @@ -2033,7 +2033,7 @@ class Results : ''; $gridEdit = ''; - if ($meta->orgtable != '' && $gridEditConfig !== 'disabled') { + if ($meta->orgtable !== '' && $gridEditConfig !== 'disabled') { $gridEdit = $gridEditConfig === 'click' ? 'grid_edit click1' : 'grid_edit click2'; } @@ -3304,7 +3304,7 @@ class Results $message->addText('('); if ($messageViewWarning === false) { - if ($this->unlimNumRows != $total) { + if ($this->unlimNumRows !== $total) { $messageTotal = Message::notice( $preCount . __('%1$s total, %2$s in query'), ); diff --git a/src/Encoding.php b/src/Encoding.php index 9a7bdb6e43..18d004ffcc 100644 --- a/src/Encoding.php +++ b/src/Encoding.php @@ -118,7 +118,7 @@ class Encoding self::initEngine(); } - return self::$engine != self::ENGINE_NONE; + return self::$engine !== self::ENGINE_NONE; } /** @@ -300,7 +300,7 @@ class Encoding /* Most engines do not support listing */ $config = Config::getInstance(); - if (self::$engine != self::ENGINE_MBSTRING) { + if (self::$engine !== self::ENGINE_MBSTRING) { return array_filter($config->settings['AvailableCharsets'], static function (string $charset): bool { // Removes any ignored character $normalizedCharset = strtoupper((string) preg_replace(['/[^A-Za-z0-9\-\/]/'], '', $charset)); diff --git a/src/Error/ErrorReport.php b/src/Error/ErrorReport.php index c55254bce4..982f742332 100644 --- a/src/Error/ErrorReport.php +++ b/src/Error/ErrorReport.php @@ -116,7 +116,7 @@ class ErrorReport $errors = []; // create php error report $i = 0; - if (! isset($_SESSION['prev_errors']) || $_SESSION['prev_errors'] == '') { + if (! isset($_SESSION['prev_errors']) || $_SESSION['prev_errors'] === '') { return []; } diff --git a/src/Export/Export.php b/src/Export/Export.php index b41157b7f9..35b98d2a7b 100644 --- a/src/Export/Export.php +++ b/src/Export/Export.php @@ -184,7 +184,7 @@ class Export $writeResult = @fwrite(self::$fileHandle, $this->dumpBuffer); // Here, use strlen rather than mb_strlen to get the length // in bytes to compare against the number of bytes written. - if ($writeResult != strlen($this->dumpBuffer)) { + if ($writeResult === false || $writeResult !== strlen($this->dumpBuffer)) { Current::$message = Message::error( __('Insufficient space to save the file %s.'), ); diff --git a/src/FieldMetadata.php b/src/FieldMetadata.php index f25f10ed33..58566888d2 100644 --- a/src/FieldMetadata.php +++ b/src/FieldMetadata.php @@ -223,7 +223,7 @@ final class FieldMetadata $type === MYSQLI_TYPE_LONG_BLOB || $type === MYSQLI_TYPE_VAR_STRING || $type === MYSQLI_TYPE_STRING - ) && $this->charsetnr == 63; + ) && $this->charsetnr === 63; } /** diff --git a/src/File.php b/src/File.php index 9efeb33cf8..a313e182be 100644 --- a/src/File.php +++ b/src/File.php @@ -609,7 +609,7 @@ class File return feof($this->handle); } - return $this->offset == strlen($this->content ?? ''); + return $this->offset === strlen($this->content ?? ''); } /** diff --git a/src/Git.php b/src/Git.php index e2c9287169..2412c10732 100644 --- a/src/Git.php +++ b/src/Git.php @@ -219,7 +219,7 @@ class Git $firstbyte = intval(substr($hash, 0, 2), 16); // array is indexed from 1 and we need to get // previous entry for start - $start = $firstbyte == 0 ? 0 : $fanout[$firstbyte]; + $start = $firstbyte === 0 ? 0 : $fanout[$firstbyte]; $end = $fanout[$firstbyte + 1]; @@ -487,7 +487,7 @@ class Git // parse line $parts = explode(' ', $line); // care only about named refs - if (count($parts) != 2) { + if (count($parts) !== 2) { continue; } diff --git a/src/Html/Generator.php b/src/Html/Generator.php index 3f0ee376ac..e9609fc1a0 100644 --- a/src/Html/Generator.php +++ b/src/Html/Generator.php @@ -418,7 +418,7 @@ class Generator } $config = Config::getInstance(); - $renderSql = $config->settings['ShowSQL'] == true && $sqlQuery !== '' && $sqlQuery !== ';'; + $renderSql = $config->settings['ShowSQL'] && $sqlQuery !== '' && $sqlQuery !== ';'; if (isset(Sql::$usingBookmarkMessage)) { $retval .= Sql::$usingBookmarkMessage->getDisplay(); diff --git a/src/Import/Import.php b/src/Import/Import.php index cd3666a533..3626205c25 100644 --- a/src/Import/Import.php +++ b/src/Import/Import.php @@ -744,7 +744,7 @@ class Import ImportSettings::$importNotice = ''; /* Run the $additional_sql statements supplied by the caller plug-in */ - if ($additionalSql != null) { + if ($additionalSql !== null) { /* Clean the SQL first */ /** @@ -1056,7 +1056,7 @@ class Import $result = $dbi->tryQuery($checkQuery); - return $result && $result->numRows() == 1; + return $result && $result->numRows() === 1; } /** @return string[] */ diff --git a/src/Menu.php b/src/Menu.php index e91d3ccc20..3b9f021a9e 100644 --- a/src/Menu.php +++ b/src/Menu.php @@ -328,7 +328,7 @@ class Menu $tabs['search']['icon'] = 'b_search'; $tabs['search']['route'] = '/database/search'; $tabs['search']['active'] = $route === '/database/search'; - if ($numTables == 0) { + if ($numTables === 0) { $tabs['search']['warning'] = __('Database seems to be empty!'); } @@ -336,7 +336,7 @@ class Menu $tabs['query']['icon'] = 's_db'; $tabs['query']['route'] = '/database/multi-table-query'; $tabs['query']['active'] = $route === '/database/multi-table-query'; - if ($numTables == 0) { + if ($numTables === 0) { $tabs['query']['warning'] = __('Database seems to be empty!'); } @@ -344,7 +344,7 @@ class Menu $tabs['export']['icon'] = 'b_export'; $tabs['export']['route'] = '/database/export'; $tabs['export']['active'] = $route === '/database/export'; - if ($numTables == 0) { + if ($numTables === 0) { $tabs['export']['warning'] = __('Database seems to be empty!'); } diff --git a/src/Navigation/NavigationTree.php b/src/Navigation/NavigationTree.php index c04561fae5..fda567af5b 100644 --- a/src/Navigation/NavigationTree.php +++ b/src/Navigation/NavigationTree.php @@ -383,7 +383,7 @@ class NavigationTree array_shift($path); // remove db - if (($path === [] || ! array_key_exists($path[0], $containers)) && count($containers) != 1) { + if (($path === [] || ! array_key_exists($path[0], $containers)) && count($containers) !== 1) { return $db; } diff --git a/src/Navigation/Nodes/Node.php b/src/Navigation/Nodes/Node.php index 6d93c7770d..0e35c915e0 100644 --- a/src/Navigation/Nodes/Node.php +++ b/src/Navigation/Nodes/Node.php @@ -687,7 +687,7 @@ class Node } $prefixMap[$prefix] = 1; - if (count($prefixMap) == $total) { + if (count($prefixMap) === $total) { break; } } @@ -779,7 +779,7 @@ class Node } $prefixMap[$prefix] = 1; - if (count($prefixMap) == $total) { + if (count($prefixMap) === $total) { break 2; } } diff --git a/src/Normalization.php b/src/Normalization.php index 937702f756..b03fcc7453 100644 --- a/src/Normalization.php +++ b/src/Normalization.php @@ -989,8 +989,8 @@ class Normalization . 'COUNT(DISTINCT ' . $partialKey . ',' . $column . ') as pkColCnt ' . 'FROM (SELECT * FROM ' . Util::backquote($table) . ' LIMIT 500) as dt;'; - $pkColCnt = $this->dbi->fetchValue($query); - if ($pkCnt !== 0 && $pkCnt === $colCnt && $colCnt == $pkColCnt) { + $pkColCnt = (int) $this->dbi->fetchValue($query); + if ($pkCnt !== 0 && $pkCnt === $colCnt && $colCnt === $pkColCnt) { return true; } diff --git a/src/Operations.php b/src/Operations.php index fc451b9e99..681b3b03e8 100644 --- a/src/Operations.php +++ b/src/Operations.php @@ -502,7 +502,7 @@ class Operations * This patch is to support newer MySQL/MariaDB while also for backward compatibilities. */ if ( - (strtolower($innodbFileFormat) === 'barracuda') || ($innodbFileFormat == '') + strtolower($innodbFileFormat) === 'barracuda' || $innodbFileFormat === '' && $innodbEnginePlugin->supportsFilePerTable() ) { $possibleRowFormats['INNODB']['DYNAMIC'] = 'DYNAMIC'; @@ -568,7 +568,7 @@ class Operations . '.' . Util::backquote($arr['foreign_table']); - if ($arr['foreign_table'] == Current::$table) { + if ($arr['foreign_table'] === Current::$table) { $foreignTable = Current::$table . '1'; $joinQuery .= ' AS ' . Util::backquote($foreignTable); } else { @@ -657,7 +657,7 @@ class Operations if ( $pmaTable->isEngine(['MYISAM', 'ARIA', 'ISAM']) && isset($_POST['new_pack_keys']) - && $_POST['new_pack_keys'] != $packKeys + && $_POST['new_pack_keys'] !== $packKeys ) { $tableAlters[] = 'pack_keys = ' . $_POST['new_pack_keys']; } @@ -884,7 +884,7 @@ class Operations * A target table name has been sent to this script -> do the work */ if (isset($_POST['new_name']) && is_scalar($_POST['new_name']) && (string) $_POST['new_name'] !== '') { - if ($db === $targetDb && $table == $_POST['new_name']) { + if ($db === $targetDb && $table === $_POST['new_name']) { if (isset($_POST['submit_move'])) { $message = Message::error(__('Can\'t move table to same one!')); } else { diff --git a/src/Plugins.php b/src/Plugins.php index 313bd0747c..e692124d22 100644 --- a/src/Plugins.php +++ b/src/Plugins.php @@ -285,7 +285,7 @@ class Plugins $text = $propertyGroup->getText(); } - if ($text != null) { + if ($text !== null && $text !== '') { $ret .= '
' . $plugin->getTranslatedText($text) . '
'; } diff --git a/src/Plugins/Auth/AuthenticationConfig.php b/src/Plugins/Auth/AuthenticationConfig.php index 7f48a6ec82..743c5810a9 100644 --- a/src/Plugins/Auth/AuthenticationConfig.php +++ b/src/Plugins/Auth/AuthenticationConfig.php @@ -92,7 +92,7 @@ class AuthenticationConfig extends AuthenticationPlugin $errorHandler->addNotice($failure->getMessage()); } else { // Check whether user has configured something - if ($config->sourceMtime == 0) { + if ($config->sourceMtime === 0) { echo '

' , sprintf( __( 'You probably did not create a configuration file.' diff --git a/src/Plugins/Auth/AuthenticationCookie.php b/src/Plugins/Auth/AuthenticationCookie.php index 4112e18f72..cb97682abe 100644 --- a/src/Plugins/Auth/AuthenticationCookie.php +++ b/src/Plugins/Auth/AuthenticationCookie.php @@ -122,7 +122,7 @@ class AuthenticationCookie extends AuthenticationPlugin // Show error message if (self::$connectionError !== '') { $errorMessages = Message::rawError(self::$connectionError)->getDisplay(); - } elseif (isset($_GET['session_expired']) && (int) $_GET['session_expired'] == 1) { + } elseif (isset($_GET['session_expired']) && (int) $_GET['session_expired'] === 1) { $errorMessages = Message::rawError( __('Your session has expired. Please log in again.'), )->getDisplay(); @@ -264,7 +264,7 @@ class AuthenticationCookie extends AuthenticationPlugin ); // Check if the captcha entered is valid, if not stop the login. - if ($resp == null || ! $resp->isSuccess()) { + if (! $resp->isSuccess()) { $codes = $resp->getErrorCodes(); if (in_array('invalid-json', $codes)) { diff --git a/src/Plugins/Auth/AuthenticationSignon.php b/src/Plugins/Auth/AuthenticationSignon.php index 08cfe450af..f37d3fac71 100644 --- a/src/Plugins/Auth/AuthenticationSignon.php +++ b/src/Plugins/Auth/AuthenticationSignon.php @@ -103,7 +103,7 @@ class AuthenticationSignon extends AuthenticationPlugin $config = Config::getInstance(); /* Check if we're using same signon server */ $signonUrl = $config->selectedServer['SignonURL']; - if (isset($_SESSION['LAST_SIGNON_URL']) && $_SESSION['LAST_SIGNON_URL'] != $signonUrl) { + if (isset($_SESSION['LAST_SIGNON_URL']) && $_SESSION['LAST_SIGNON_URL'] !== $signonUrl) { return false; } diff --git a/src/Plugins/Export/ExportMediawiki.php b/src/Plugins/Export/ExportMediawiki.php index e318b056d1..f7fc49385a 100644 --- a/src/Plugins/Export/ExportMediawiki.php +++ b/src/Plugins/Export/ExportMediawiki.php @@ -242,7 +242,7 @@ class ExportMediawiki extends ExportPlugin // Print data comment $output = $this->exportComment( - $tableAlias != '' + $tableAlias !== '' ? 'Table data for ' . Util::backquote($tableAlias) : 'Query results', ); diff --git a/src/Plugins/Export/ExportOdt.php b/src/Plugins/Export/ExportOdt.php index 5a9d15e9d4..ee48895edf 100644 --- a/src/Plugins/Export/ExportOdt.php +++ b/src/Plugins/Export/ExportOdt.php @@ -240,7 +240,7 @@ class ExportOdt extends ExportPlugin $this->buffer .= ''; - $tableAlias != '' + $tableAlias !== '' ? $this->buffer .= __('Dumping data for table') . ' ' . htmlspecialchars($tableAlias) : $this->buffer .= __('Dumping data for query result'); $this->buffer .= '' diff --git a/src/Plugins/Export/ExportTexytext.php b/src/Plugins/Export/ExportTexytext.php index f1512f07a9..bcaba86abf 100644 --- a/src/Plugins/Export/ExportTexytext.php +++ b/src/Plugins/Export/ExportTexytext.php @@ -173,7 +173,7 @@ class ExportTexytext extends ExportPlugin if ( ! $this->export->outputHandler( - $tableAlias != '' + $tableAlias !== '' ? '== ' . __('Dumping data for table') . ' ' . $tableAlias . "\n\n" : '==' . __('Dumping data for query result') . "\n\n", ) diff --git a/src/Plugins/Export/Helpers/Pdf.php b/src/Plugins/Export/Helpers/Pdf.php index dc48476684..b486d30723 100644 --- a/src/Plugins/Export/Helpers/Pdf.php +++ b/src/Plugins/Export/Helpers/Pdf.php @@ -783,7 +783,7 @@ class Pdf extends PdfLib $this->tablewidths[$i] = $sColWidth + $surplusToAdd; } - if ($this->displayColumn[$i] != false) { + if ($this->displayColumn[$i]) { continue; } diff --git a/src/Plugins/Import/ImportCsv.php b/src/Plugins/Import/ImportCsv.php index c2f2909a9d..25d65166e7 100644 --- a/src/Plugins/Import/ImportCsv.php +++ b/src/Plugins/Import/ImportCsv.php @@ -544,13 +544,13 @@ class ImportCsv extends AbstractImportCsv $i = 0; $lasti = -1; $ch = mb_substr($buffer, 0, 1); - if ($this->maxLines > 0 && $line == $maxLinesConstraint) { + if ($this->maxLines > 0 && $line === $maxLinesConstraint) { ImportSettings::$finished = true; break; } } - if ($this->maxLines > 0 && $line == $maxLinesConstraint) { + if ($this->maxLines > 0 && $line === $maxLinesConstraint) { ImportSettings::$finished = true; break; } @@ -664,7 +664,7 @@ class ImportCsv extends AbstractImportCsv Current::$message->addParam(__('Columns escaped with')); Import::$hasError = true; $paramError = true; - } elseif (mb_strlen($csvNewLine) != 1 && $csvNewLine !== 'auto') { + } elseif (mb_strlen($csvNewLine) !== 1 && $csvNewLine !== 'auto') { Current::$message = Message::error( __('Invalid parameter for CSV import: %s'), ); diff --git a/src/Plugins/Import/ImportOds.php b/src/Plugins/Import/ImportOds.php index bbdba4e87f..e167666e6e 100644 --- a/src/Plugins/Import/ImportOds.php +++ b/src/Plugins/Import/ImportOds.php @@ -243,7 +243,7 @@ class ImportOds extends ImportPlugin $text = $cell->children('text', true); $cellAttrs = $cell->attributes('office', true); - if ($text->count() != 0) { + if ($text->count() !== 0) { $attr = $cell->attributes('table', true); $numRepeat = (int) $attr['number-columns-repeated']; $numIterations = $numRepeat !== 0 ? $numRepeat : 1; @@ -256,7 +256,7 @@ class ImportOds extends ImportPlugin } // skip empty repeats in the last row - if ($a == $cellCount) { + if ($a === $cellCount) { continue; } diff --git a/src/Plugins/Import/ImportShp.php b/src/Plugins/Import/ImportShp.php index aa655eaf40..73fda82e1e 100644 --- a/src/Plugins/Import/ImportShp.php +++ b/src/Plugins/Import/ImportShp.php @@ -222,7 +222,7 @@ class ImportShp extends ImportPlugin $colNames = []; foreach ($shp->records as $record) { $tempRow = []; - if ($gisObj == null || ! method_exists($gisObj, 'getShape')) { + if ($gisObj === null || ! method_exists($gisObj, 'getShape')) { $tempRow[] = null; } else { $tempRow[] = "GeomFromText('" . $gisObj->getShape($record->shpData) . "')"; diff --git a/src/Plugins/Schema/Pdf/Pdf.php b/src/Plugins/Schema/Pdf/Pdf.php index f3df242b26..dcc02e04e7 100644 --- a/src/Plugins/Schema/Pdf/Pdf.php +++ b/src/Plugins/Schema/Pdf/Pdf.php @@ -355,7 +355,7 @@ class Pdf extends PdfLib $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; $s = str_replace("\r", '', $txt); $nb = strlen($s); - if ($nb > 0 && $s[$nb - 1] == "\n") { + if ($nb > 0 && $s[$nb - 1] === "\n") { $nb--; } @@ -366,7 +366,7 @@ class Pdf extends PdfLib $nl = 1; while ($i < $nb) { $c = $s[$i]; - if ($c == "\n") { + if ($c === "\n") { $i++; $sep = -1; $j = $i; @@ -381,7 +381,7 @@ class Pdf extends PdfLib $l += $cw[mb_ord($c)] ?? 0; if ($l > $wmax) { - if ($sep == -1) { + if ($sep === -1) { if ($i === $j) { $i++; } diff --git a/src/Plugins/Schema/Pdf/PdfRelationSchema.php b/src/Plugins/Schema/Pdf/PdfRelationSchema.php index 8b453d8a92..fcd2eb8f63 100644 --- a/src/Plugins/Schema/Pdf/PdfRelationSchema.php +++ b/src/Plugins/Schema/Pdf/PdfRelationSchema.php @@ -592,7 +592,7 @@ class PdfRelationSchema extends ExportRelationSchema $break = true; } - if ($break == true) { + if ($break) { $this->pdf->Cell(0, 3, '', 0, 1); $this->pdf->Ln(); } @@ -650,7 +650,7 @@ class PdfRelationSchema extends ExportRelationSchema $linksTo = ''; if ($foreigner) { $linksTo = '-> '; - if ($foreigner['foreign_db'] != $this->db->getName()) { + if ($foreigner['foreign_db'] !== $this->db->getName()) { $linksTo .= $foreigner['foreign_db'] . '.'; } diff --git a/src/Plugins/Schema/Svg/Svg.php b/src/Plugins/Schema/Svg/Svg.php index 20bb53f5b6..232f5bc14b 100644 --- a/src/Plugins/Schema/Svg/Svg.php +++ b/src/Plugins/Schema/Svg/Svg.php @@ -129,7 +129,7 @@ class Svg extends XMLWriter $width = (int) $width; $height = (int) $height; - if ($x != 0 || $y != 0) { + if ((float) $x !== 0.0 || (float) $y !== 0.0) { $this->writeAttribute('viewBox', sprintf('%d %d %d %d', $x, $y, $width, $height)); } diff --git a/src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php b/src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php index 82257ebe7f..4c207c2e37 100644 --- a/src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php +++ b/src/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php @@ -77,7 +77,7 @@ abstract class DateFormatTransformationsPlugin extends TransformationsPlugin // (Note: prior to MySQL 4.1, TIMESTAMP has a display size // for example TIMESTAMP(8) means YYYYMMDD) } elseif (preg_match('/^(\d{2}){3,7}$/', $buffer) === 1) { - if (mb_strlen($buffer) == 14 || mb_strlen($buffer) == 8) { + if (mb_strlen($buffer) === 14 || mb_strlen($buffer) === 8) { $offset = 4; } else { $offset = 2; diff --git a/src/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php b/src/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php index e5f3a2c210..0740e37bef 100644 --- a/src/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php +++ b/src/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php @@ -65,7 +65,7 @@ abstract class SubstringTransformationsPlugin extends TransformationsPlugin $newtext = $options[2] . $newtext; } - if ($length + $optionZero != $baselength) { + if ($length + $optionZero !== $baselength) { $newtext .= $options[2]; } } diff --git a/src/Plugins/Transformations/Input/Text_Plain_Iptobinary.php b/src/Plugins/Transformations/Input/Text_Plain_Iptobinary.php index 4bf5f05d5d..09e1544a31 100644 --- a/src/Plugins/Transformations/Input/Text_Plain_Iptobinary.php +++ b/src/Plugins/Transformations/Input/Text_Plain_Iptobinary.php @@ -68,7 +68,7 @@ class Text_Plain_Iptobinary extends IOTransformationsPlugin $val = ''; if ($value !== '') { $length = strlen($value); - if ($length == 4 || $length == 16) { + if ($length === 4 || $length === 16) { $ip = @inet_ntop(pack('A' . $length, $value)); if ($ip !== false) { $val = $ip; diff --git a/src/Replication/Replication.php b/src/Replication/Replication.php index 49975a0bd6..f4218ba4e0 100644 --- a/src/Replication/Replication.php +++ b/src/Replication/Replication.php @@ -65,7 +65,7 @@ class Replication return -1; } - if ($control !== 'SQL_THREAD' && $control !== 'IO_THREAD' && $control != null) { + if ($control !== 'SQL_THREAD' && $control !== 'IO_THREAD' && $control !== '') { return -1; } diff --git a/src/Routing/Routing.php b/src/Routing/Routing.php index 052cd5d846..2ca6ef6cc4 100644 --- a/src/Routing/Routing.php +++ b/src/Routing/Routing.php @@ -223,7 +223,7 @@ class Routing $pathInfo = Core::getEnv('PATH_INFO'); if ($pathInfo !== '' && $pmaPhpSelf !== '') { $questionPos = mb_strpos($pmaPhpSelf, '?'); - if ($questionPos != false) { + if ($questionPos) { $pmaPhpSelf = mb_substr($pmaPhpSelf, 0, $questionPos); } diff --git a/src/Server/Privileges.php b/src/Server/Privileges.php index b45c0c5727..2f824722ff 100644 --- a/src/Server/Privileges.php +++ b/src/Server/Privileges.php @@ -237,7 +237,7 @@ class Privileges ($grantValue === 'Y') || ($row === null && is_array($grantValue) - && count($grantValue) == $_REQUEST['column_count'] + && count($grantValue) === (int) $_REQUEST['column_count'] && empty($_POST[$currentGrant[0] . '_none'])) ) { if ($enableHTML) { @@ -275,7 +275,7 @@ class Privileges } else { $privs[] = 'USAGE'; } - } elseif ($allPrivileges && (! isset($_POST['grant_count']) || count($privs) == $_POST['grant_count'])) { + } elseif ($allPrivileges && (! isset($_POST['grant_count']) || count($privs) === (int) $_POST['grant_count'])) { if ($enableHTML) { $privs = ['ALL PRIVILEGES']; } else { diff --git a/src/Server/Status/Processes.php b/src/Server/Status/Processes.php index 33914c2eb4..cca11965e6 100644 --- a/src/Server/Status/Processes.php +++ b/src/Server/Status/Processes.php @@ -108,7 +108,7 @@ final class Processes foreach ($sortableColumns as $columnKey => $column) { $isSorted = $orderByField !== '' && $sortOrder !== '' - && $orderByField == $column['order_by_field']; + && $orderByField === $column['order_by_field']; $column['sort_order'] = 'ASC'; if ($isSorted && $sortOrder === 'ASC') { diff --git a/src/Setup/Index.php b/src/Setup/Index.php index f1848ee1f9..00db71eb22 100644 --- a/src/Setup/Index.php +++ b/src/Setup/Index.php @@ -69,7 +69,7 @@ class Index foreach ($_SESSION['messages'] as &$messages) { $removeIds = []; foreach ($messages as $id => $msg) { - if ($msg['active'] != false) { + if ($msg['active']) { continue; } @@ -132,7 +132,7 @@ class Index } $latestCompatible = $versionInformation->getLatestCompatibleVersion($versionData); - if ($latestCompatible == null) { + if ($latestCompatible === null) { return; } diff --git a/src/Sql.php b/src/Sql.php index 380e9b14f2..d2a803a0a9 100644 --- a/src/Sql.php +++ b/src/Sql.php @@ -40,6 +40,7 @@ use function count; use function defined; use function htmlspecialchars; use function in_array; +use function is_string; use function session_start; use function session_write_close; use function sprintf; @@ -153,18 +154,18 @@ class Sql $justOneTable = true; $prevTable = ''; foreach ($fieldsMeta as $oneFieldMeta) { - if ($oneFieldMeta->table != '' && $prevTable != '' && $oneFieldMeta->table != $prevTable) { + if ($oneFieldMeta->table !== '' && $prevTable !== '' && $oneFieldMeta->table !== $prevTable) { $justOneTable = false; } - if ($oneFieldMeta->table == '') { + if ($oneFieldMeta->table === '') { continue; } $prevTable = $oneFieldMeta->table; } - return $justOneTable && $prevTable != ''; + return $justOneTable && $prevTable !== ''; } /** @@ -576,10 +577,10 @@ class Sql return false; } + /** Is false, except when a USE statement was sent. */ $currentDb = $this->dbi->fetchValue('SELECT DATABASE()'); - // $current_db is false, except when a USE statement was sent - return ($currentDb != false) && ($db !== $currentDb); + return is_string($currentDb) && $db !== $currentDb; } /** @@ -1082,7 +1083,7 @@ class Sql StatementInfo $statementInfo, bool $isLimitedDisplay = false, ): string { - $printView = isset($_POST['printview']) && $_POST['printview'] == '1'; + $printView = isset($_POST['printview']) && $_POST['printview']; $isBrowseDistinct = ! empty($_POST['is_browse_distinct']); if ($statementInfo->flags->isProcedure) { @@ -1273,7 +1274,7 @@ class Sql ): string { // If we are retrieving the full value of a truncated field or the original // value of a transformed field, show it here - if (isset($_POST['grid_edit']) && $_POST['grid_edit'] == true) { + if (isset($_POST['grid_edit']) && $_POST['grid_edit']) { $this->getResponseForGridEdit($result); ResponseRenderer::getInstance()->callExit(); } @@ -1343,7 +1344,7 @@ class Sql ]); } - if (isset($_POST['printview']) && $_POST['printview'] == '1') { + if (isset($_POST['printview']) && $_POST['printview']) { $displayParts = DisplayParts::fromArray([ 'hasEditLink' => false, 'deleteLink' => DeleteLinkEnum::NO_DELETE, @@ -1355,7 +1356,7 @@ class Sql ]); } - if (! isset($_POST['printview']) || $_POST['printview'] != '1') { + if (! isset($_POST['printview']) || ! $_POST['printview']) { $scripts->addFile('makegrid.js'); $scripts->addFile('sql.js'); Current::$message = null; @@ -1561,7 +1562,7 @@ class Sql $warningMessages = $this->dbi->getWarnings(); // No rows returned -> move back to the calling page - if (($numRows == 0 && $unlimNumRows == 0) || $statementInfo->flags->isAffected || $result === false) { + if (($numRows === 0 && $unlimNumRows === 0) || $statementInfo->flags->isAffected || $result === false) { $htmlOutput = $this->getQueryResponseForNoResultsReturned( $statementInfo, $db, @@ -1631,13 +1632,13 @@ class Sql public function calculatePosForLastPage(string $db, string $table, int|null $pos): int { if ($pos === null) { - $pos = $_SESSION['tmpval']['pos']; + $pos = (int) $_SESSION['tmpval']['pos']; } $tableObject = new Table($table, $db, $this->dbi); $unlimNumRows = $tableObject->countRecords(true); //If position is higher than number of rows - if ($unlimNumRows <= $pos && $pos != 0) { + if ($unlimNumRows <= $pos && $pos !== 0) { return $this->getStartPosToDisplayRow($unlimNumRows); } diff --git a/src/Table/Search.php b/src/Table/Search.php index e85e9de122..8688f2512b 100644 --- a/src/Table/Search.php +++ b/src/Table/Search.php @@ -150,7 +150,7 @@ final class Search $where = ''; if ($unaryFlag) { $where = $backquotedName . ' ' . $funcType; - } elseif (strncasecmp($types, 'enum', 4) == 0 && ! empty($criteriaValues)) { + } elseif (strncasecmp($types, 'enum', 4) === 0 && ! empty($criteriaValues)) { $where = $backquotedName; $where .= $this->getEnumWhereClause($criteriaValues, $funcType); } elseif ($criteriaValues != '') { diff --git a/src/Table/Table.php b/src/Table/Table.php index c2397b84d7..b7cb511db4 100644 --- a/src/Table/Table.php +++ b/src/Table/Table.php @@ -660,7 +660,7 @@ class Table implements Stringable $rowCount = $this->dbi->fetchValue( 'SELECT COUNT(*) FROM ' . Util::backquote($this->dbName) . '.' . Util::backquote($this->name), ); - } elseif ($config->settings['MaxExactCountViews'] == 0) { + } elseif ($config->settings['MaxExactCountViews'] === 0) { // For complex views, even trying to get a partial record // count could bring down a server, so we offer an // alternative: setting MaxExactCountViews to 0 will bypass @@ -1208,7 +1208,7 @@ class Table implements Stringable } // check if the table has not been modified - if ($this->getStatusInfo('Create_time') == $this->uiprefs['CREATE_TIME']) { + if ($this->getStatusInfo('Create_time') === $this->uiprefs['CREATE_TIME']) { return array_map(intval(...), $this->uiprefs[$property->value]); } @@ -1241,7 +1241,7 @@ class Table implements Stringable && ($property === UiProperty::ColumnOrder || $property === UiProperty::ColumnVisibility) ) { $currCreateTime = $this->getStatusInfo('CREATE_TIME'); - if ($tableCreateTime === null || $tableCreateTime != $currCreateTime) { + if ($tableCreateTime === null || $tableCreateTime !== $currCreateTime) { // there is no $table_create_time, or // supplied $table_create_time is older than current create time, // so don't save @@ -1396,9 +1396,9 @@ class Table implements Stringable . $this->dbi->quoteString($foreignTable, ConnectionType::ControlUser) . ',' . $this->dbi->quoteString($foreignField, ConnectionType::ControlUser) . ')'; } elseif ( - $existrel[$masterField]['foreign_db'] != $foreignDb - || $existrel[$masterField]['foreign_table'] != $foreignTable - || $existrel[$masterField]['foreign_field'] != $foreignField + $existrel[$masterField]['foreign_db'] !== $foreignDb + || $existrel[$masterField]['foreign_table'] !== $foreignTable + || $existrel[$masterField]['foreign_field'] !== $foreignField ) { $updQuery = 'UPDATE ' . Util::backquote($relationFeature->database) @@ -1507,11 +1507,11 @@ class Table implements Stringable if ( $refDbName != $foreignDb || $existrelForeign[$masterFieldMd5]->refTableName != $foreignTable - || $existrelForeign[$masterFieldMd5]->refIndexList != $foreignField - || $existrelForeign[$masterFieldMd5]->indexList != $masterField + || $existrelForeign[$masterFieldMd5]->refIndexList !== $foreignField + || $existrelForeign[$masterFieldMd5]->indexList !== $masterField || $_POST['constraint_name'][$masterFieldMd5] != $constraintName - || ($_POST['on_delete'][$masterFieldMd5] != $onDelete) - || ($_POST['on_update'][$masterFieldMd5] != $onUpdate) + || ($_POST['on_delete'][$masterFieldMd5] !== $onDelete) + || ($_POST['on_update'][$masterFieldMd5] !== $onUpdate) ) { // another foreign key is already defined for this field // or an option has been changed for ON DELETE or ON UPDATE @@ -1716,7 +1716,7 @@ class Table implements Stringable $fields = TableUtils::getFields($stmt); } - if ($column != null) { + if ($column !== null && $column !== '') { $expression = isset($fields[$column]['expr']) ? substr($fields[$column]['expr'], 1, -1) : ''; return [$column => $expression]; diff --git a/src/Tracking/Tracker.php b/src/Tracking/Tracker.php index d101326a8c..bbee8a63ab 100644 --- a/src/Tracking/Tracker.php +++ b/src/Tracking/Tracker.php @@ -121,7 +121,7 @@ class Tracker $dbi->quoteString($tableName, ConnectionType::ControlUser), ); - $result = $dbi->fetchValue($sqlQuery, 0, ConnectionType::ControlUser) == 1; + $result = (int) $dbi->fetchValue($sqlQuery, 0, ConnectionType::ControlUser) === 1; self::$trackingCache[$dbName][$tableName] = $result; @@ -199,12 +199,12 @@ class Tracker // Get DROP TABLE / DROP VIEW and CREATE TABLE SQL statements $createSql = ''; - if ($config->selectedServer['tracking_add_drop_table'] == true && ! $isView) { + if ($config->selectedServer['tracking_add_drop_table'] && ! $isView) { $createSql .= self::getLogComment() . 'DROP TABLE IF EXISTS ' . Util::backquote($tableName) . ";\n"; } - if ($config->selectedServer['tracking_add_drop_view'] == true && $isView) { + if ($config->selectedServer['tracking_add_drop_view'] && $isView) { $createSql .= self::getLogComment() . 'DROP VIEW IF EXISTS ' . Util::backquote($tableName) . ";\n"; } @@ -267,7 +267,7 @@ class Tracker $createSql = ''; - if ($config->selectedServer['tracking_add_drop_database'] == true) { + if ($config->selectedServer['tracking_add_drop_database']) { $createSql .= self::getLogComment() . 'DROP DATABASE IF EXISTS ' . Util::backquote($dbName) . ";\n"; } @@ -387,7 +387,7 @@ class Tracker $dbi->quoteString($tablename, ConnectionType::ControlUser), ); - if ($statement != '') { + if ($statement !== null && $statement !== '') { $sqlQuery .= " AND FIND_IN_SET('" . $statement . "',tracking) > 0"; } @@ -592,7 +592,7 @@ class Tracker $version = self::getVersion($dbname, $result['tablename'], $result['identifier']); // If version not exists and auto-creation is enabled - if (Config::getInstance()->selectedServer['tracking_version_auto_create'] == true && $version == -1) { + if (Config::getInstance()->selectedServer['tracking_version_auto_create'] && $version === -1) { // Create the version switch ($result['identifier']) { @@ -609,7 +609,7 @@ class Tracker } // If version exists - if ($version == -1) { + if ($version === -1) { return; } diff --git a/src/Tracking/Tracking.php b/src/Tracking/Tracking.php index b0f5f70c3a..9eb144a135 100644 --- a/src/Tracking/Tracking.php +++ b/src/Tracking/Tracking.php @@ -887,55 +887,55 @@ class Tracking // a key is absent from the request if it has been removed from // tracking_default_statements in the config - if (isset($_POST['alter_table']) && $_POST['alter_table'] == true) { + if (isset($_POST['alter_table']) && $_POST['alter_table']) { $trackingSet .= 'ALTER TABLE,'; } - if (isset($_POST['rename_table']) && $_POST['rename_table'] == true) { + if (isset($_POST['rename_table']) && $_POST['rename_table']) { $trackingSet .= 'RENAME TABLE,'; } - if (isset($_POST['create_table']) && $_POST['create_table'] == true) { + if (isset($_POST['create_table']) && $_POST['create_table']) { $trackingSet .= 'CREATE TABLE,'; } - if (isset($_POST['drop_table']) && $_POST['drop_table'] == true) { + if (isset($_POST['drop_table']) && $_POST['drop_table']) { $trackingSet .= 'DROP TABLE,'; } - if (isset($_POST['alter_view']) && $_POST['alter_view'] == true) { + if (isset($_POST['alter_view']) && $_POST['alter_view']) { $trackingSet .= 'ALTER VIEW,'; } - if (isset($_POST['create_view']) && $_POST['create_view'] == true) { + if (isset($_POST['create_view']) && $_POST['create_view']) { $trackingSet .= 'CREATE VIEW,'; } - if (isset($_POST['drop_view']) && $_POST['drop_view'] == true) { + if (isset($_POST['drop_view']) && $_POST['drop_view']) { $trackingSet .= 'DROP VIEW,'; } - if (isset($_POST['create_index']) && $_POST['create_index'] == true) { + if (isset($_POST['create_index']) && $_POST['create_index']) { $trackingSet .= 'CREATE INDEX,'; } - if (isset($_POST['drop_index']) && $_POST['drop_index'] == true) { + if (isset($_POST['drop_index']) && $_POST['drop_index']) { $trackingSet .= 'DROP INDEX,'; } - if (isset($_POST['insert']) && $_POST['insert'] == true) { + if (isset($_POST['insert']) && $_POST['insert']) { $trackingSet .= 'INSERT,'; } - if (isset($_POST['update']) && $_POST['update'] == true) { + if (isset($_POST['update']) && $_POST['update']) { $trackingSet .= 'UPDATE,'; } - if (isset($_POST['delete']) && $_POST['delete'] == true) { + if (isset($_POST['delete']) && $_POST['delete']) { $trackingSet .= 'DELETE,'; } - if (isset($_POST['truncate']) && $_POST['truncate'] == true) { + if (isset($_POST['truncate']) && $_POST['truncate']) { $trackingSet .= 'TRUNCATE,'; } diff --git a/src/Transformations.php b/src/Transformations.php index df45df6f1a..3328beff17 100644 --- a/src/Transformations.php +++ b/src/Transformations.php @@ -86,10 +86,10 @@ class Transformations while (($option = array_shift($transformOptions)) !== null) { $trimmed = trim($option); - if (strlen($trimmed) > 1 && $trimmed[0] == "'" && $trimmed[strlen($trimmed) - 1] == "'") { + if (strlen($trimmed) > 1 && $trimmed[0] === "'" && $trimmed[strlen($trimmed) - 1] === "'") { // '...' $option = mb_substr($trimmed, 1, -1); - } elseif (isset($trimmed[0]) && $trimmed[0] == "'") { + } elseif (isset($trimmed[0]) && $trimmed[0] === "'") { // '..., $trimmed = ltrim($option); $rtrimmed = ''; @@ -98,7 +98,7 @@ class Transformations // ..., $trimmed .= ',' . $option; $rtrimmed = rtrim($trimmed); - if ($rtrimmed[strlen($rtrimmed) - 1] == "'") { + if ($rtrimmed[strlen($rtrimmed) - 1] === "'") { // ,...' break; } @@ -403,7 +403,7 @@ class Transformations if ($testRs->numRows() > 0) { $row = $testRs->fetchAssoc(); - if (! $forcedelete && ($hasValue || $row['comment'] != '')) { + if (! $forcedelete && ($hasValue || $row['comment'] !== null && $row['comment'] !== '')) { $updQuery = 'UPDATE ' . Util::backquote($browserTransformationFeature->database) . '.' . Util::backquote($browserTransformationFeature->columnInfo) diff --git a/src/UniqueCondition.php b/src/UniqueCondition.php index b0de51b4a8..f9d30873cd 100644 --- a/src/UniqueCondition.php +++ b/src/UniqueCondition.php @@ -62,7 +62,7 @@ class UniqueCondition continue; } - if (strcasecmp($meta->name, $expression->alias) == 0) { + if (strcasecmp($meta->name, $expression->alias) === 0) { $meta->orgname = $expression->column; break; } @@ -87,7 +87,7 @@ class UniqueCondition // If this field is not from the table which the unique clause needs // to be restricted to. - if ($restrictToTable !== '' && $restrictToTable != $meta->table) { + if ($restrictToTable !== '' && $restrictToTable !== $meta->table) { continue; } diff --git a/src/UserPrivilegesFactory.php b/src/UserPrivilegesFactory.php index b55c2d53a7..eb05acdf0a 100644 --- a/src/UserPrivilegesFactory.php +++ b/src/UserPrivilegesFactory.php @@ -179,7 +179,7 @@ class UserPrivilegesFactory $dbNameToTest, ), ) - || mb_substr($this->dbi->getError(), 1, 4) == 1044) + || (int) mb_substr($this->dbi->getError(), 1, 4) === 1044) ) { continue; } diff --git a/src/Util.php b/src/Util.php index 0b907decac..7e2f3c013c 100644 --- a/src/Util.php +++ b/src/Util.php @@ -765,7 +765,7 @@ class Util } foreach ($pages as $i) { - if ($i == $pageNow) { + if ($i === $pageNow) { $selected = 'selected style="font-weight: bold"'; } else { $selected = ''; @@ -842,7 +842,7 @@ class Util public static function printableBitValue(int $value, int $length): string { // if running on a 64-bit server or the length is safe for decbin() - if (PHP_INT_SIZE == 8 || $length < 33) { + if (PHP_INT_SIZE === 8 || $length < 33) { $printable = decbin($value); } else { // FIXME: does not work for the leftmost bit of a 64-bit value @@ -1818,7 +1818,7 @@ class Util $orderLinkParams = []; $orderLinkParams['title'] = __('Sort'); // If this column was requested to be sorted. - if ($requestedSort == $sort) { + if ($requestedSort === $sort) { if ($requestedSortOrder === 'ASC') { $futureSortOrder = 'DESC'; // current sort order is ASC @@ -1917,7 +1917,10 @@ class Util public static function getTableListPosition(ServerRequest $request, string $db): int { - if (! isset($_SESSION['tmpval']['table_limit_offset']) || $_SESSION['tmpval']['table_limit_offset_db'] != $db) { + if ( + ! isset($_SESSION['tmpval']['table_limit_offset']) + || $_SESSION['tmpval']['table_limit_offset_db'] !== $db + ) { $_SESSION['tmpval']['table_limit_offset'] = 0; $_SESSION['tmpval']['table_limit_offset_db'] = $db; }