Remove unnecessary nullability

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2024-12-29 23:03:21 +00:00
parent f0f84295cc
commit 4e9866f797
5 changed files with 16 additions and 15 deletions

View File

@ -84,9 +84,9 @@ class Form
*
* @param string $optionName path or field name
*
* @return string|null one of: boolean, integer, double, string, select, array
* @return string one of: boolean, integer, double, string, select, array
*/
public function getOptionType(string $optionName): string|null
public function getOptionType(string $optionName): string
{
$key = ltrim(
mb_substr(
@ -96,7 +96,7 @@ class Form
'/',
);
return $this->fieldsTypes[$key] ?? null;
return $this->fieldsTypes[$key] ?? '';
}
/**

View File

@ -566,7 +566,7 @@ class FormDisplay
foreach ($form->fields as $field => $systemPath) {
$workPath = array_search($systemPath, $this->systemPaths);
$key = $this->translatedPaths[$workPath];
$type = (string) $form->getOptionType($field);
$type = $form->getOptionType($field);
// skip groups
if ($type === 'group') {

View File

@ -1235,10 +1235,10 @@ class Relation
/**
* Create a PDF page
*
* @param string|null $newpage name of the new PDF page
* @param string $db database name
* @param string $newpage name of the new PDF page
* @param string $db database name
*/
public function createPage(string|null $newpage, PdfFeature $pdfFeature, string $db): int
public function createPage(string $newpage, PdfFeature $pdfFeature, string $db): int
{
$insQuery = 'INSERT INTO '
. Util::backquote($pdfFeature->database) . '.'
@ -1247,7 +1247,7 @@ class Relation
. ' VALUES ('
. $this->dbi->quoteString($db, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString(
$newpage !== null && $newpage !== '' ? $newpage : __('no description'),
$newpage !== '' ? $newpage : __('no description'),
ConnectionType::ControlUser,
) . ')';
$this->dbi->tryQueryAsControlUser($insQuery);

View File

@ -42,7 +42,7 @@ final class CentralColumnsController implements InvocableController
$request->getParsedBodyParamAsString('orig_col_name'),
$request->getParsedBodyParamAsString('col_default'),
$request->getParsedBodyParamAsString('col_default_sel'),
$request->getParsedBodyParamAsStringOrNull('col_extra'),
$request->getParsedBodyParamAsString('col_extra', ''),
$request->getParsedBodyParamAsStringOrNull('col_isNull'),
$request->getParsedBodyParamAsString('col_length'),
$request->getParsedBodyParamAsString('col_attribute'),
@ -60,7 +60,7 @@ final class CentralColumnsController implements InvocableController
$request->getParsedBodyParamAsString('col_name'),
$request->getParsedBodyParamAsString('col_default'),
$request->getParsedBodyParamAsString('col_default_sel'),
$request->getParsedBodyParamAsStringOrNull('col_extra'),
$request->getParsedBodyParamAsString('col_extra', ''),
$request->getParsedBodyParamAsStringOrNull('col_isNull'),
$request->getParsedBodyParamAsString('col_length'),
$request->getParsedBodyParamAsString('col_attribute'),
@ -176,7 +176,7 @@ final class CentralColumnsController implements InvocableController
string $origColName,
string $colDefault,
string $colDefaultSel,
string|null $colExtra,
string $colExtra,
string|null $colIsNull,
string $colLength,
string $colAttribute,
@ -198,7 +198,7 @@ final class CentralColumnsController implements InvocableController
$colLength,
$colIsNull !== null,
$collation,
$colExtra ?? '',
$colExtra,
$columnDefault,
);
}
@ -207,7 +207,7 @@ final class CentralColumnsController implements InvocableController
string $colName,
string $colDefault,
string $colDefaultSel,
string|null $colExtra,
string $colExtra,
string|null $colIsNull,
string $colLength,
string $colAttribute,
@ -224,7 +224,7 @@ final class CentralColumnsController implements InvocableController
$colLength,
$colIsNull !== null,
$collation,
$colExtra ?? '',
$colExtra,
$colDefault === 'NONE' && $colDefaultSel !== 'USER_DEFINED' ? '' : $colDefault,
);
}

View File

@ -68,7 +68,8 @@ class FormTest extends AbstractTestCase
['7' => 'Seven'],
);
self::assertNull(
self::assertSame(
'',
$this->object->getOptionType('123/4/5/6'),
);