Remove nullability from $text

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2026-02-15 19:45:36 +00:00
parent f23caa7308
commit ce2f44e9e7
10 changed files with 9 additions and 36 deletions

View File

@ -287,7 +287,7 @@ class Plugins
$text = $propertyGroup->getText();
if ($text !== null && $text !== '') {
if ($text !== '') {
$ret .= '<h5 class="card-title mt-4 mb-2">' . $plugin->getTranslatedText($text) . '</h5>';
}

View File

@ -29,7 +29,7 @@ class BoolPropertyItem extends OptionsPropertyOneItem
$ret .= '>';
$ret .= '<label class="form-check-label" for="checkbox_' . $this->getName() . '">'
. $plugin->getTranslatedText($this->getText() ?? '') . '</label></div>';
. $plugin->getTranslatedText($this->getText()) . '</label></div>';
$ret .= Plugins::getDocumentationLinkHtml($this);
return $ret;

View File

@ -17,7 +17,7 @@ class MessageOnlyPropertyItem extends OptionsPropertyOneItem
public function getHtml(Plugin $plugin, PluginType $pluginType): string
{
$ret = '<li class="list-group-item">';
$ret .= $plugin->getTranslatedText($this->getText() ?? '');
$ret .= $plugin->getTranslatedText($this->getText());
$ret .= Plugins::getDocumentationLinkHtml($this);
return $ret;

View File

@ -20,7 +20,7 @@ class NumberPropertyItem extends OptionsPropertyOneItem
{
$ret = '<li class="list-group-item">';
$ret .= '<label for="number_' . $this->getName() . '" class="form-label">'
. $plugin->getTranslatedText($this->getText() ?? '') . '</label>';
. $plugin->getTranslatedText($this->getText()) . '</label>';
$ret .= '<input class="form-control" type="number" name="' . $this->getName() . '"'
. ' value="'
. htmlspecialchars($plugin->getTranslatedText(Plugins::getDefault(

View File

@ -20,7 +20,7 @@ class SelectPropertyItem extends OptionsPropertyOneItem
{
$ret = '<li class="list-group-item">';
$ret .= '<label for="select_' . $this->getName() . '" class="form-label">'
. $plugin->getTranslatedText($this->getText() ?? '') . '</label>';
. $plugin->getTranslatedText($this->getText()) . '</label>';
$ret .= '<select class="form-select" name="' . $this->getName() . '"'
. ' id="select_' . $this->getName() . '">';
$default = htmlspecialchars($plugin->getTranslatedText(Plugins::getDefault(

View File

@ -20,7 +20,7 @@ class TextPropertyItem extends OptionsPropertyOneItem
{
$ret = '<li class="list-group-item">';
$ret .= '<label for="text_' . $this->getName() . '" class="form-label">'
. $plugin->getTranslatedText($this->getText() ?? '') . '</label>';
. $plugin->getTranslatedText($this->getText()) . '</label>';
$ret .= '<input class="form-control" type="text" name="' . $this->getName() . '"'
. ' value="'
. htmlspecialchars($plugin->getTranslatedText(Plugins::getDefault(

View File

@ -25,7 +25,7 @@ abstract class OptionsPropertyGroup extends OptionsPropertyItem implements Count
*/
private SplObjectStorage $properties;
public function __construct(string|null $name = null, string|null $text = null)
public function __construct(string|null $name = null, string $text = '')
{
parent::__construct($name, $text);

View File

@ -15,7 +15,7 @@ namespace PhpMyAdmin\Properties\Options;
*/
abstract class OptionsPropertyItem
{
public function __construct(private string|null $name = null, private string|null $text = null)
public function __construct(private string|null $name = null, private readonly string $text = '')
{
}
@ -29,13 +29,8 @@ abstract class OptionsPropertyItem
$this->name = $name;
}
public function getText(): string|null
public function getText(): string
{
return $this->text;
}
public function setText(string $text): void
{
$this->text = $text;
}
}

View File

@ -19,13 +19,6 @@ class PropertyItemsTest extends AbstractTestCase
'Text',
$object->getText(),
);
$object->setText('xtext2');
self::assertSame(
'xtext2',
$object->getText(),
);
}
public function testBoolName(): void

View File

@ -38,19 +38,4 @@ class OptionsPropertyItemTest extends AbstractTestCase
$this->stub->getName(),
);
}
/**
* Test for
* - PhpMyAdmin\Properties\Options\OptionsPropertyItem::getText
* - PhpMyAdmin\Properties\Options\OptionsPropertyItem::setText
*/
public function testGetSetText(): void
{
$this->stub->setText('text123');
self::assertSame(
'text123',
$this->stub->getText(),
);
}
}