Merge pull request #18094 from kamil-tekiela/new-phpstan-checks
New phpstan checks
This commit is contained in:
commit
c3516962c1
@ -13,6 +13,7 @@ use PhpMyAdmin\FieldMetadata;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_column;
|
||||
use function array_key_exists;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_string;
|
||||
@ -104,7 +105,11 @@ final class MysqliResult implements ResultInterface
|
||||
$row = $this->fetchRow();
|
||||
}
|
||||
|
||||
return $row[$field] ?? false;
|
||||
if (! array_key_exists($field, $row)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $row[$field];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -895,6 +895,21 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/ConfigStorage/Relation.php
|
||||
|
||||
-
|
||||
message: "#^Foreach overwrites \\$feature with its value variable\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/ConfigStorage/Relation.php
|
||||
|
||||
-
|
||||
message: "#^Foreach overwrites \\$table with its key variable\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/ConfigStorage/Relation.php
|
||||
|
||||
-
|
||||
message: "#^Foreach overwrites \\$work with its key variable\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/ConfigStorage/Relation.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:buildForeignDropdown\\(\\) has parameter \\$foreign with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -2390,6 +2405,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Table/Structure/SaveController.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
|
||||
count: 2
|
||||
path: libraries/classes/Controllers/Table/Structure/SaveController.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Controllers\\\\Table\\\\Structure\\\\SaveController\\:\\:adjustColumnPrivileges\\(\\) has parameter \\$adjust_privileges with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -2870,6 +2890,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Database/Qbe.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$columnIndex\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Database/Qbe.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Database\\\\Qbe\\:\\:__construct\\(\\) has parameter \\$savedSearchList with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -3170,6 +3195,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Database/Routines.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
|
||||
count: 2
|
||||
path: libraries/classes/Database/Routines.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Database\\\\Routines\\:\\:backupPrivileges\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -3570,6 +3600,36 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Dbal/MysqliResult.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$expr\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Display/Results.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$from\\.$#"
|
||||
count: 2
|
||||
path: libraries/classes/Display/Results.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$limit\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Display/Results.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$where\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Display/Results.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property object\\:\\:\\$column\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Display/Results.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property object\\:\\:\\$database\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Display/Results.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset int\\<0, max\\> on mixed\\.$#"
|
||||
count: 2
|
||||
@ -4545,6 +4605,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Gis/GisMultiPolygon.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$label_point in isset\\(\\) always exists and is not nullable\\.$#"
|
||||
count: 2
|
||||
path: libraries/classes/Gis/GisMultiPolygon.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Gis\\\\GisPoint\\:\\:generateParams\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -4840,11 +4905,6 @@ parameters:
|
||||
count: 2
|
||||
path: libraries/classes/Git.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$position might not be defined\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Git.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Header\\:\\:getJsParams\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -4945,6 +5005,11 @@ parameters:
|
||||
count: 2
|
||||
path: libraries/classes/Import.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
|
||||
count: 5
|
||||
path: libraries/classes/Import.php
|
||||
|
||||
-
|
||||
message: "#^Foreach overwrites \\$sqlQuery with its value variable\\.$#"
|
||||
count: 1
|
||||
@ -5015,6 +5080,11 @@ parameters:
|
||||
count: 2
|
||||
path: libraries/classes/Import.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$sql of method PhpMyAdmin\\\\Import\\:\\:executeQuery\\(\\) expects string, string\\|null given\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Import.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$sql of method PhpMyAdmin\\\\Import\\:\\:runQuery\\(\\) expects string, \\(array\\<int, string\\>\\|string\\|null\\) given\\.$#"
|
||||
count: 1
|
||||
@ -5625,6 +5695,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Navigation/Navigation.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\:\\:\\$secondIcon\\.$#"
|
||||
count: 2
|
||||
path: libraries/classes/Navigation/NavigationTree.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access property \\$pos2 on PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\|null\\.$#"
|
||||
count: 1
|
||||
@ -6235,6 +6310,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Export/ExportLatex.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
|
||||
count: 3
|
||||
path: libraries/classes/Plugins/Export/ExportMediawiki.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Export\\\\ExportMediawiki\\:\\:exportData\\(\\) has parameter \\$aliases with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -6345,6 +6425,11 @@ parameters:
|
||||
count: 2
|
||||
path: libraries/classes/Plugins/Export/ExportSql.php
|
||||
|
||||
-
|
||||
message: "#^Foreach overwrites \\$j with its key variable\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Export/ExportSql.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Export\\\\ExportSql\\:\\:exportData\\(\\) has parameter \\$aliases with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -6490,6 +6575,16 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Export/ExportYaml.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Export/Helpers/Pdf.php
|
||||
|
||||
-
|
||||
message: "#^Foreach overwrites \\$width with its value variable\\.$#"
|
||||
count: 2
|
||||
path: libraries/classes/Plugins/Export/Helpers/Pdf.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Export\\\\Helpers\\\\Pdf\\:\\:getTableDef\\(\\) has parameter \\$aliases with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -6565,11 +6660,6 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Export/Helpers/Pdf.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$columns_cnt might not be defined\\.$#"
|
||||
count: 6
|
||||
path: libraries/classes/Plugins/Export/Helpers/Pdf.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Export\\\\Helpers\\\\TableProperty\\:\\:__construct\\(\\) has parameter \\$row with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -6705,6 +6795,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Import/ImportMediawiki.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
|
||||
count: 2
|
||||
path: libraries/classes/Plugins/Import/ImportOds.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Import\\\\ImportOds\\:\\:iterateOverColumns\\(\\) has parameter \\$col_names with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -6805,6 +6900,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Import/ImportXml.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Import/ImportXml.php
|
||||
|
||||
-
|
||||
message: "#^Offset 'charset' does not exist on SimpleXMLElement\\|null\\.$#"
|
||||
count: 1
|
||||
@ -6840,6 +6940,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Import/ImportXml.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Import\\\\ShapeFileImport\\:\\:readSHP\\(\\) never returns false so it can be removed from the return type\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Import/ShapeFileImport.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Import\\\\Upload\\\\UploadNoplugin\\:\\:getUploadStatus\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -6925,6 +7030,11 @@ parameters:
|
||||
count: 2
|
||||
path: libraries/classes/Plugins/Schema/Eps/TableStatsEps.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Schema/Pdf/Pdf.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\Pdf\\:\\:row\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -6960,6 +7070,11 @@ parameters:
|
||||
count: 2
|
||||
path: libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$size\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\PdfRelationSchema\\:\\:dataDictionaryDoc\\(\\) has parameter \\$alltables with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -7950,6 +8065,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Server/Privileges.php
|
||||
|
||||
-
|
||||
message: "#^Access to an uninitialized property PhpMyAdmin\\\\Server\\\\Status\\\\Data\\:\\:\\$replicationInfo\\.$#"
|
||||
count: 2
|
||||
path: libraries/classes/Server/Status/Data.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Server\\\\Status\\\\Data\\:\\:calculateValues\\(\\) has parameter \\$server_status with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -8300,6 +8420,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Sql.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$where\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Sql.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Sql\\:\\:countQueryResults\\(\\) should return int\\|numeric\\-string but returns mixed\\.$#"
|
||||
count: 1
|
||||
@ -8540,6 +8665,11 @@ parameters:
|
||||
count: 5
|
||||
path: libraries/classes/Table.php
|
||||
|
||||
-
|
||||
message: "#^Foreach overwrites \\$trigger with its value variable\\.$#"
|
||||
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
|
||||
@ -8910,6 +9040,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Tracker.php
|
||||
|
||||
-
|
||||
message: "#^Foreach overwrites \\$logEntry with its value variable\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Tracker.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Tracker\\:\\:changeTrackingData\\(\\) has parameter \\$newData with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -9190,6 +9325,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Tracking.php
|
||||
|
||||
-
|
||||
message: "#^Foreach overwrites \\$file with its value variable\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Transformations.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Transformations\\:\\:getAvailableMimeTypes\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -9325,6 +9465,11 @@ parameters:
|
||||
count: 5
|
||||
path: libraries/classes/Util.php
|
||||
|
||||
-
|
||||
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Util.php
|
||||
|
||||
-
|
||||
message: "#^Foreach overwrites \\$quote with its value variable\\.$#"
|
||||
count: 1
|
||||
@ -9495,6 +9640,21 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Utils/HttpRequest.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property object\\:\\:\\$date\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/VersionInformation.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property object\\:\\:\\$releases\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/VersionInformation.php
|
||||
|
||||
-
|
||||
message: "#^Access to an undefined property object\\:\\:\\$version\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/VersionInformation.php
|
||||
|
||||
-
|
||||
message: "#^Comparison operation \"\\>\\=\" between int\\<1, max\\> and 1 is always true\\.$#"
|
||||
count: 1
|
||||
@ -11700,6 +11860,11 @@ parameters:
|
||||
count: 1
|
||||
path: test/classes/StorageEngineTest.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Tests\\\\Stubs\\\\DbiDummy\\:\\:connect\\(\\) never returns null so it can be removed from the return type\\.$#"
|
||||
count: 1
|
||||
path: test/classes/Stubs/DbiDummy.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Tests\\\\Stubs\\\\DbiDummy\\:\\:fetchAny\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
|
||||
@ -30,3 +30,10 @@ parameters:
|
||||
# Allow dynamic calls to static methods.
|
||||
strictCalls: false
|
||||
checkBenevolentUnionTypes: true
|
||||
checkAlwaysTrueCheckTypeFunctionCall: true
|
||||
checkAlwaysTrueStrictComparison: true
|
||||
checkUninitializedProperties: true
|
||||
polluteScopeWithAlwaysIterableForeach: true
|
||||
checkDynamicProperties: true
|
||||
checkTooWideReturnTypesInProtectedAndPublicMethods: true
|
||||
polluteScopeWithLoopInitialAssignments: true
|
||||
|
||||
@ -12,6 +12,7 @@ use PhpMyAdmin\Dbal\ResultInterface;
|
||||
use PhpMyAdmin\FieldMetadata;
|
||||
|
||||
use function array_column;
|
||||
use function array_key_exists;
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
@ -103,7 +104,11 @@ class DummyResult implements ResultInterface
|
||||
$row = $this->fetchRow();
|
||||
}
|
||||
|
||||
return $row[$field] ?? false;
|
||||
if (! array_key_exists($field, $row)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $row[$field];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user