Skip to content

Commit 4e9866f

Browse files
committed
Remove unnecessary nullability
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent f0f8429 commit 4e9866f

5 files changed

Lines changed: 16 additions & 15 deletions

File tree

src/Config/Form.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public function __construct(
8484
*
8585
* @param string $optionName path or field name
8686
*
87-
* @return string|null one of: boolean, integer, double, string, select, array
87+
* @return string one of: boolean, integer, double, string, select, array
8888
*/
89-
public function getOptionType(string $optionName): string|null
89+
public function getOptionType(string $optionName): string
9090
{
9191
$key = ltrim(
9292
mb_substr(
@@ -96,7 +96,7 @@ public function getOptionType(string $optionName): string|null
9696
'/',
9797
);
9898

99-
return $this->fieldsTypes[$key] ?? null;
99+
return $this->fieldsTypes[$key] ?? '';
100100
}
101101

102102
/**

src/Config/FormDisplay.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ public function save(array $forms, bool $allowPartialSave = true): bool
566566
foreach ($form->fields as $field => $systemPath) {
567567
$workPath = array_search($systemPath, $this->systemPaths);
568568
$key = $this->translatedPaths[$workPath];
569-
$type = (string) $form->getOptionType($field);
569+
$type = $form->getOptionType($field);
570570

571571
// skip groups
572572
if ($type === 'group') {

src/ConfigStorage/Relation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,10 +1235,10 @@ public function renameTable(string $sourceDb, string $targetDb, string $sourceTa
12351235
/**
12361236
* Create a PDF page
12371237
*
1238-
* @param string|null $newpage name of the new PDF page
1239-
* @param string $db database name
1238+
* @param string $newpage name of the new PDF page
1239+
* @param string $db database name
12401240
*/
1241-
public function createPage(string|null $newpage, PdfFeature $pdfFeature, string $db): int
1241+
public function createPage(string $newpage, PdfFeature $pdfFeature, string $db): int
12421242
{
12431243
$insQuery = 'INSERT INTO '
12441244
. Util::backquote($pdfFeature->database) . '.'
@@ -1247,7 +1247,7 @@ public function createPage(string|null $newpage, PdfFeature $pdfFeature, string
12471247
. ' VALUES ('
12481248
. $this->dbi->quoteString($db, ConnectionType::ControlUser) . ', '
12491249
. $this->dbi->quoteString(
1250-
$newpage !== null && $newpage !== '' ? $newpage : __('no description'),
1250+
$newpage !== '' ? $newpage : __('no description'),
12511251
ConnectionType::ControlUser,
12521252
) . ')';
12531253
$this->dbi->tryQueryAsControlUser($insQuery);

src/Controllers/Database/CentralColumnsController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __invoke(ServerRequest $request): Response
4242
$request->getParsedBodyParamAsString('orig_col_name'),
4343
$request->getParsedBodyParamAsString('col_default'),
4444
$request->getParsedBodyParamAsString('col_default_sel'),
45-
$request->getParsedBodyParamAsStringOrNull('col_extra'),
45+
$request->getParsedBodyParamAsString('col_extra', ''),
4646
$request->getParsedBodyParamAsStringOrNull('col_isNull'),
4747
$request->getParsedBodyParamAsString('col_length'),
4848
$request->getParsedBodyParamAsString('col_attribute'),
@@ -60,7 +60,7 @@ public function __invoke(ServerRequest $request): Response
6060
$request->getParsedBodyParamAsString('col_name'),
6161
$request->getParsedBodyParamAsString('col_default'),
6262
$request->getParsedBodyParamAsString('col_default_sel'),
63-
$request->getParsedBodyParamAsStringOrNull('col_extra'),
63+
$request->getParsedBodyParamAsString('col_extra', ''),
6464
$request->getParsedBodyParamAsStringOrNull('col_isNull'),
6565
$request->getParsedBodyParamAsString('col_length'),
6666
$request->getParsedBodyParamAsString('col_attribute'),
@@ -176,7 +176,7 @@ public function editSave(
176176
string $origColName,
177177
string $colDefault,
178178
string $colDefaultSel,
179-
string|null $colExtra,
179+
string $colExtra,
180180
string|null $colIsNull,
181181
string $colLength,
182182
string $colAttribute,
@@ -198,7 +198,7 @@ public function editSave(
198198
$colLength,
199199
$colIsNull !== null,
200200
$collation,
201-
$colExtra ?? '',
201+
$colExtra,
202202
$columnDefault,
203203
);
204204
}
@@ -207,7 +207,7 @@ public function addNewColumn(
207207
string $colName,
208208
string $colDefault,
209209
string $colDefaultSel,
210-
string|null $colExtra,
210+
string $colExtra,
211211
string|null $colIsNull,
212212
string $colLength,
213213
string $colAttribute,
@@ -224,7 +224,7 @@ public function addNewColumn(
224224
$colLength,
225225
$colIsNull !== null,
226226
$collation,
227-
$colExtra ?? '',
227+
$colExtra,
228228
$colDefault === 'NONE' && $colDefaultSel !== 'USER_DEFINED' ? '' : $colDefault,
229229
);
230230
}

tests/unit/Config/FormTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public function testGetOptionType(): void
6868
['7' => 'Seven'],
6969
);
7070

71-
self::assertNull(
71+
self::assertSame(
72+
'',
7273
$this->object->getOptionType('123/4/5/6'),
7374
);
7475

0 commit comments

Comments
 (0)