Skip to content

Commit ccd5dd9

Browse files
Merge pull request #19984 from kamil-tekiela/issets
Remove all redundant issets
2 parents 0080806 + 6521d36 commit ccd5dd9

22 files changed

Lines changed: 34 additions & 68 deletions

phpstan-baseline.neon

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3582,7 +3582,7 @@ parameters:
35823582
-
35833583
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
35843584
identifier: empty.notAllowed
3585-
count: 2
3585+
count: 1
35863586
path: src/Controllers/Table/Structure/PartitioningController.php
35873587

35883588
-
@@ -3591,12 +3591,6 @@ parameters:
35913591
count: 1
35923592
path: src/Controllers/Table/Structure/PartitioningController.php
35933593

3594-
-
3595-
message: '#^Offset ''partition_by'' on array\{partition_by\: string, partition_expr\: string, partition_count\: mixed, subpartition_by\: string, subpartition_expr\: string, subpartition_count\: mixed, can_have_subpartitions\: bool\} in isset\(\) always exists and is not nullable\.$#'
3596-
identifier: isset.offset
3597-
count: 1
3598-
path: src/Controllers/Table/Structure/PartitioningController.php
3599-
36003594
-
36013595
message: '#^Offset 0 might not exist on array\<PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition\>\|null\.$#'
36023596
identifier: offsetAccess.notFound
@@ -7770,7 +7764,7 @@ parameters:
77707764
-
77717765
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
77727766
identifier: equal.notAllowed
7773-
count: 3
7767+
count: 1
77747768
path: src/InsertEdit.php
77757769

77767770
-
@@ -14190,12 +14184,6 @@ parameters:
1419014184
count: 1
1419114185
path: src/Util.php
1419214186

14193-
-
14194-
message: '#^Offset int\<1, 6\> on array\{string, string, string, string, string, string, string\} in isset\(\) always exists and is not nullable\.$#'
14195-
identifier: isset.offset
14196-
count: 1
14197-
path: src/Util.php
14198-
1419914187
-
1420014188
message: '#^Only booleans are allowed in a negated boolean, int\<0, 2\> given\.$#'
1420114189
identifier: booleanNot.exprNotBoolean
@@ -17056,21 +17044,9 @@ parameters:
1705617044
path: tests/unit/Navigation/Nodes/NodeTest.php
1705717045

1705817046
-
17059-
message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\<''AllowDeny''\|''AllowNoPassword''\|''AllowRoot''\|''auth_http_realm''\|''auth_type''\|''bookmarktable''\|''central_columns''\|''column_info''\|''compress''\|''control_compress''\|''control_hide…''\|''control_socket''\|''control_ssl''\|''control_ssl_ca''\|''control_ssl_ca_path''\|''control_ssl_cert''\|''control_ssl_ciphers''\|''control_ssl_key''\|''control_ssl_verify''\|''controlhost''\|''controlpass''\|''controlport''\|''controluser''\|''designer_settings''\|''DisableIS''\|''export_templates''\|''favorite''\|''history''\|''host''\|''LogoutURL''\|''MaxTableUiprefs''\|''navigationhiding''\|''only_db''\|''password''\|''pdf_pages''\|''pmadb''\|''port''\|''recent''\|''relation''\|''savedsearches''\|''SessionTimeZone''\|''SignonCookieParams''\|''SignonScript''\|''SignonSession''\|''SignonURL''\|''socket''\|''ssl''\|''ssl_ca''\|''ssl_ca_path''\|''ssl_cert''\|''ssl_ciphers''\|''ssl_key''\|''ssl_verify''\|''table_coords''\|''table_info''\|''table_uiprefs''\|''tracking''\|''user''\|''userconfig''\|''usergroups''\|''users''\|''verbose'', array\<array\<string\>\|bool\|int\<0, max\>\|string\>\|bool\|int\<1, max\>\|string\|null\>\.$#'
17060-
identifier: assign.propertyType
17061-
count: 1
17062-
path: tests/unit/Navigation/Nodes/NodeTest.php
17063-
17064-
-
17065-
message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\<''AllowDeny''\|''AllowNoPassword''\|''AllowRoot''\|''auth_http_realm''\|''auth_type''\|''bookmarktable''\|''central_columns''\|''column_info''\|''compress''\|''control_compress''\|''control_hide…''\|''control_socket''\|''control_ssl''\|''control_ssl_ca''\|''control_ssl_ca_path''\|''control_ssl_cert''\|''control_ssl_ciphers''\|''control_ssl_key''\|''control_ssl_verify''\|''controlhost''\|''controlpass''\|''controlport''\|''controluser''\|''designer_settings''\|''DisableIS''\|''export_templates''\|''favorite''\|''history''\|''host''\|''LogoutURL''\|''MaxTableUiprefs''\|''navigationhiding''\|''password''\|''pdf_pages''\|''pmadb''\|''port''\|''recent''\|''relation''\|''savedsearches''\|''SessionTimeZone''\|''SignonCookieParams''\|''SignonScript''\|''SignonSession''\|''SignonURL''\|''socket''\|''ssl''\|''ssl_ca''\|''ssl_ca_path''\|''ssl_cert''\|''ssl_ciphers''\|''ssl_key''\|''ssl_verify''\|''table_coords''\|''table_info''\|''table_uiprefs''\|''tracking''\|''user''\|''userconfig''\|''usergroups''\|''users''\|''verbose'', array\<array\<string\>\|bool\|int\<0, max\>\|string\>\|bool\|int\<1, max\>\|string\|null\>\.$#'
17066-
identifier: assign.propertyType
17067-
count: 2
17068-
path: tests/unit/Navigation/Nodes/NodeTest.php
17069-
17070-
-
17071-
message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\{\}\.$#'
17047+
message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\.$#'
1707217048
identifier: assign.propertyType
17073-
count: 1
17049+
count: 3
1707417050
path: tests/unit/Navigation/Nodes/NodeTest.php
1707517051

1707617052
-

psalm-baseline.xml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,12 +1639,10 @@
16391639
<code><![CDATA[__construct]]></code>
16401640
</PossiblyUnusedMethod>
16411641
<RedundantCondition>
1642-
<code><![CDATA[$request->hasBodyParam('import_type')
1643-
&& $request->getParsedBodyParam('import_type') === 'text_file'
1642+
<code><![CDATA[$request->getParsedBodyParam('import_type') === 'text_file'
16441643
&& isset($_FILES['import_file'])
16451644
&& is_array($_FILES['import_file'])]]></code>
1646-
<code><![CDATA[$request->hasBodyParam('import_type')
1647-
&& $request->getParsedBodyParam('import_type') === 'text_file'
1645+
<code><![CDATA[$request->getParsedBodyParam('import_type') === 'text_file'
16481646
&& isset($_FILES['import_file'])
16491647
&& is_array($_FILES['import_file'])
16501648
&& $_FILES['import_file']['error'] == UPLOAD_ERR_OK
@@ -2639,7 +2637,6 @@
26392637
<code><![CDATA[__construct]]></code>
26402638
</PossiblyUnusedMethod>
26412639
<RiskyTruthyFalsyComparison>
2642-
<code><![CDATA[empty($stmt->partitionBy)]]></code>
26432640
<code><![CDATA[empty($stmt->subpartitionBy)]]></code>
26442641
</RiskyTruthyFalsyComparison>
26452642
</file>
@@ -10731,14 +10728,9 @@
1073110728
<code><![CDATA[Config::getInstance()]]></code>
1073210729
<code><![CDATA[Config::getInstance()]]></code>
1073310730
</DeprecatedMethod>
10734-
<DocblockTypeContradiction>
10735-
<code><![CDATA[isset($config->selectedServer)]]></code>
10736-
</DocblockTypeContradiction>
1073710731
<InvalidPropertyAssignmentValue>
1073810732
<code><![CDATA[$config->selectedServer]]></code>
1073910733
<code><![CDATA[$config->selectedServer]]></code>
10740-
<code><![CDATA[$config->selectedServer]]></code>
10741-
<code><![CDATA[[]]]></code>
1074210734
</InvalidPropertyAssignmentValue>
1074310735
</file>
1074410736
<file src="tests/unit/Navigation/Nodes/ObjectFetcherTest.php">

src/Controllers/BrowseForeignersController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __invoke(ServerRequest $request): Response
3535
$foreignFilter = $request->getParsedBodyParamAsString('foreign_filter', '');
3636
$rownumber = $request->getParsedBodyParamAsStringOrNull('rownumber');
3737

38-
if (! isset($database, $table, $field)) {
38+
if ($database === null || $table === null || $field === null) {
3939
return $this->response->response();
4040
}
4141

src/Controllers/ColumnController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __invoke(ServerRequest $request): Response
2323
$db = $request->getParsedBodyParamAsStringOrNull('db');
2424
$table = $request->getParsedBodyParamAsStringOrNull('table');
2525

26-
if (! isset($db, $table)) {
26+
if ($db === null || $table === null) {
2727
$this->response->setRequestStatus(false);
2828
$this->response->addJSON(['message' => Message::error()]);
2929

src/Controllers/Export/ExportController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function __invoke(ServerRequest $request): Response
227227
// Do we need to convert charset?
228228
Export::$outputCharsetConversion = Export::$asFile
229229
&& Encoding::isSupported()
230-
&& isset(Current::$charset) && Current::$charset !== 'utf-8'
230+
&& Current::$charset !== null && Current::$charset !== 'utf-8'
231231
&& in_array(Current::$charset, Encoding::listEncodings(), true);
232232

233233
// Use on the fly compression?

src/Controllers/GisDataEditorController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __invoke(ServerRequest $request): Response
5454
$value = $request->getParsedBodyParamAsStringOrNull('value');
5555
$inputName = $request->getParsedBodyParamAsStringOrNull('input_name');
5656

57-
if (! isset($field)) {
57+
if ($field === null) {
5858
return $this->response->response();
5959
}
6060

@@ -70,7 +70,7 @@ public function __invoke(ServerRequest $request): Response
7070
return $this->response->response();
7171
}
7272

73-
if (isset($value)) {
73+
if ($value !== null) {
7474
$gisData = array_merge($gisData, $gisObj->generateParams($value));
7575
}
7676

src/Controllers/Normalization/AddNewPrimaryController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function __invoke(ServerRequest $request): Response
3434

3535
$db = DatabaseName::tryFrom(Current::$database);
3636
$table = TableName::tryFrom(Current::$table);
37-
$dbName = isset($db) ? $db->getName() : '';
38-
$tableName = isset($table) ? $table->getName() : '';
37+
$dbName = $db?->getName() ?? '';
38+
$tableName = $table?->getName() ?? '';
3939

4040
$columnMeta = ['Field' => $tableName . '_id', 'Extra' => 'auto_increment'];
4141
$html = $this->normalization->getHtmlForCreateNewColumn(

src/Controllers/Preferences/ManageController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ public function __invoke(ServerRequest $request): Response
106106
// load from JSON file
107107
$json = '';
108108
if (
109-
$request->hasBodyParam('import_type')
110-
&& $request->getParsedBodyParam('import_type') === 'text_file'
109+
$request->getParsedBodyParam('import_type') === 'text_file'
111110
&& isset($_FILES['import_file'])
112111
&& is_array($_FILES['import_file'])
113112
&& $_FILES['import_file']['error'] == UPLOAD_ERR_OK

src/Controllers/Server/PrivilegesController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function __invoke(ServerRequest $request): Response
166166
$relationParameters->configurableMenusFeature !== null,
167167
);
168168
//update the old variables
169-
if (isset($retMessage)) {
169+
if ($retMessage !== null) {
170170
Current::$message = $retMessage;
171171
unset($retMessage);
172172
}

src/Controllers/Sql/SqlController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function __invoke(ServerRequest $request): Response
178178
Import::$importText,
179179
Current::$messageToShow,
180180
UrlParams::$goto,
181-
isset(Current::$dispQuery) ? Current::$displayQuery : null,
181+
Current::$dispQuery !== null ? Current::$displayQuery : null,
182182
Current::$displayMessage ?? '',
183183
Current::$sqlQuery,
184184
Current::$completeQuery ?? Current::$sqlQuery,

0 commit comments

Comments
 (0)