fix phpstan lvl 9 bugs

This commit is contained in:
Dennis Eichhorn 2022-12-26 20:52:58 +01:00
parent 0c00383430
commit 8e670f3a27
6 changed files with 9 additions and 8 deletions

View File

@ -17,8 +17,7 @@
"tag_icon": {
"name": "tag_icon",
"type": "VARCHAR(255)",
"null": true,
"default": null
"null": false
},
"tag_type": {
"name": "tag_type",

View File

@ -74,7 +74,8 @@ final class ApiController extends Controller
public function apiTagUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
/** @var Tag $old */
$old = clone TagMapper::get()->where('id', (int) $request->getData('id'))->execute();
$old = TagMapper::get()->where('id', (int) $request->getData('id'))->execute();
$old = clone $old;
$new = $this->updateTagFromRequest($request);
$this->updateModel($request->header->account, $old, $new, TagMapper::class, 'tag', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Tag', 'Tag successfully updated', $new);
@ -190,7 +191,7 @@ final class ApiController extends Controller
{
$tag = new Tag();
$tag->color = \str_pad($request->getData('color') ?? '#000000ff', 9, 'f');
$tag->icon = $request->getData('icon');
$tag->icon = (string) ($request->getData('icon') ?? '');
return $tag;
}

View File

@ -54,10 +54,10 @@ class Tag implements \JsonSerializable
/**
* Icon.
*
* @var null|string
* @var string
* @since 1.0.0
*/
public ?string $icon = null;
public string $icon = '';
/**
* Creator.

View File

@ -112,6 +112,7 @@ class BaseView extends View
*/
public function render(mixed ...$data) : string
{
/** @var array{0:string, 1:string, 2:string, 3:null|bool} $data */
$this->id = $data[0];
$this->name = $data[1];
$this->form = $data[2];

View File

@ -28,7 +28,7 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iColor"><?= $this->getHtml('Color'); ?></label>
<tr><td><input type="color" name="color" id="iColor"required>
<tr><td><label for="iIcon"><?= $this->getHtml('Icon'); ?></label>
<tr><td><input type="text" name="icon" id="iIcon" placeholder="&#xf040; oms" value="<?= $this->printHtml($tag->icon ?? ''); ?>">
<tr><td><input type="text" name="icon" id="iIcon" placeholder="&#xf040; oms" value="<?= $this->printHtml($tag->icon); ?>">
</table>
</div>
<div class="portlet-foot">

View File

@ -33,7 +33,7 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iColor"><?= $this->getHtml('Color'); ?></label>
<tr><td><input type="color" name="color" id="iColor" value="<?= $this->printHtml(\substr($tag->color, 0, 7)); ?>" required>
<tr><td><label for="iIcon"><?= $this->getHtml('Icon'); ?></label>
<tr><td><input type="text" name="icon" id="iIcon" placeholder="&#xf040; oms" value="<?= $this->printHtml($tag->icon ?? ''); ?>">
<tr><td><input type="text" name="icon" id="iIcon" placeholder="&#xf040; oms" value="<?= $this->printHtml($tag->icon); ?>">
</table>
</div>
<div class="portlet-foot">