fix phpstan lvl 9 bugs

This commit is contained in:
Dennis Eichhorn 2022-12-26 20:52:58 +01:00
parent 7d2d776d80
commit 0fb0e8b3bd
7 changed files with 27 additions and 12 deletions

View File

@ -106,7 +106,12 @@ final class ApiController extends Controller
$internalResponse = new HttpResponse(); $internalResponse = new HttpResponse();
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null); $this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null);
$card->addTag($internalResponse->get($request->uri->__toString())['response']);
if (!\is_array($data = $internalResponse->get($request->uri->__toString()))) {
continue;
}
$card->addTag($data['response']);
} else { } else {
$card->addTag(new NullTag((int) $tag['id'])); $card->addTag(new NullTag((int) $tag['id']));
} }
@ -305,7 +310,12 @@ final class ApiController extends Controller
$internalResponse = new HttpResponse(); $internalResponse = new HttpResponse();
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null); $this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null);
$board->addTag($internalResponse->get($request->uri->__toString())['response']);
if (!\is_array($data = $internalResponse->get($request->uri->__toString()))) {
continue;
}
$board->addTag($data['response']);
} else { } else {
$board->addTag(new NullTag((int) $tag['id'])); $board->addTag(new NullTag((int) $tag['id']));
} }
@ -354,7 +364,9 @@ final class ApiController extends Controller
*/ */
public function apiKanbanBoardUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void public function apiKanbanBoardUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{ {
$old = clone KanbanBoardMapper::get()->where('id', (int) $request->getData('id'))->execute(); /** @var \Modules\Kanban\Models\KanbanBoard $old */
$old = KanbanBoardMapper::get()->where('id', (int) $request->getData('id'))->execute();
$old = clone $old;
$new = $this->updateBoardFromRequest($request); $new = $this->updateBoardFromRequest($request);
$this->updateModel($request->header->account, $old, $new, KanbanBoardMapper::class, 'board', $request->getOrigin()); $this->updateModel($request->header->account, $old, $new, KanbanBoardMapper::class, 'board', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Board', 'Board successfully updated', $new); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Board', 'Board successfully updated', $new);
@ -373,7 +385,7 @@ final class ApiController extends Controller
{ {
/** @var KanbanBoard $board */ /** @var KanbanBoard $board */
$board = KanbanBoardMapper::get()->where('id', (int) $request->getData('id'))->execute(); $board = KanbanBoardMapper::get()->where('id', (int) $request->getData('id'))->execute();
$board->name = $request->getData('title') ?? $board->name; $board->name = (string) ($request->getData('title') ?? $board->name);
$board->description = Markdown::parse((string) ($request->getData('plain') ?? $board->descriptionRaw)); $board->description = Markdown::parse((string) ($request->getData('plain') ?? $board->descriptionRaw));
$board->descriptionRaw = (string) ($request->getData('plain') ?? $board->descriptionRaw); $board->descriptionRaw = (string) ($request->getData('plain') ?? $board->descriptionRaw);
$board->order = (int) ($request->getData('order') ?? $board->order); $board->order = (int) ($request->getData('order') ?? $board->order);

View File

@ -104,6 +104,7 @@ final class BackendController extends Controller
{ {
$view = new View($this->app->l11nManager, $request, $response); $view = new View($this->app->l11nManager, $request, $response);
/** @var \Modules\Kanban\Models\KanbanBoard $board */
$board = KanbanBoardMapper::get() $board = KanbanBoardMapper::get()
->with('columns') ->with('columns')
->with('columns/cards') ->with('columns/cards')
@ -211,6 +212,7 @@ final class BackendController extends Controller
{ {
$view = new View($this->app->l11nManager, $request, $response); $view = new View($this->app->l11nManager, $request, $response);
/** @var \Modules\Kanban\Models\KanbanCard $card */
$card = KanbanCardMapper::get() $card = KanbanCardMapper::get()
->with('tags') ->with('tags')
->with('tags/title') ->with('tags/title')

View File

@ -221,13 +221,13 @@ class KanbanBoard implements \JsonSerializable
/** /**
* Add a column * Add a column
* *
* @param mixed $column Column * @param KanbanColumn $column Column
* *
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function addColumn($column) : void public function addColumn(KanbanColumn $column) : void
{ {
$this->columns[] = $column; $this->columns[] = $column;
} }

View File

@ -263,13 +263,13 @@ class KanbanCard implements \JsonSerializable
/** /**
* Add a comment * Add a comment
* *
* @param mixed $comment Comment * @param KanbanCardComment $comment Comment
* *
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function addComment($comment) : void public function addComment(KanbanCardComment $comment) : void
{ {
$this->comments[] = $comment; $this->comments[] = $comment;
} }

View File

@ -16,6 +16,7 @@ namespace Modules\Kanban\Models;
use Modules\Admin\Models\Account; use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount; use Modules\Admin\Models\NullAccount;
use Modules\Media\Models\Media;
/** /**
* Kanban card comment class. * Kanban card comment class.
@ -121,13 +122,13 @@ class KanbanCardComment implements \JsonSerializable
/** /**
* Add a media file * Add a media file
* *
* @param mixed $media Media * @param Media $media Media
* *
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function addMedia($media) : void public function addMedia(Media $media) : void
{ {
$this->media[] = $media; $this->media[] = $media;
} }

View File

@ -36,7 +36,7 @@ $columns = $board->getColumns();
<div class="portlet-foot"> <div class="portlet-foot">
<div class="overflowfix"> <div class="overflowfix">
<?php $tags = $card->getTags(); foreach ($tags as $tag) : ?> <?php $tags = $card->getTags(); foreach ($tags as $tag) : ?>
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= $tag->icon !== null ? '<i class="' . $this->printHtml($tag->icon ?? '') . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span> <span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= !empty($tag->icon) ? '<i class="' . $this->printHtml($tag->icon) . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
<?php endforeach; ?> <?php endforeach; ?>
<a href="<?= $url; ?>" class="button floatRight"><?= $this->getHtml('More', '0', '0'); ?></a> <a href="<?= $url; ?>" class="button floatRight"><?= $this->getHtml('More', '0', '0'); ?></a>
</div> </div>

View File

@ -37,7 +37,7 @@ echo $this->getData('nav')->render(); ?>
<div class="portlet-foot"> <div class="portlet-foot">
<div class="overflowfix"> <div class="overflowfix">
<?php $tags = $board->getTags(); foreach ($tags as $tag) : ?> <?php $tags = $board->getTags(); foreach ($tags as $tag) : ?>
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= $tag->icon !== null ? '<i class="' . $this->printHtml($tag->icon ?? '') . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span> <span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= !empty($tag->icon) ? '<i class="' . $this->printHtml($tag->icon) . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
<?php endforeach; ?> <?php endforeach; ?>
<a tabindex="0" href="<?= $url; ?>" class="button floatRight"><?= $this->getHtml('Open', '0', '0'); ?></a> <a tabindex="0" href="<?= $url; ?>" class="button floatRight"><?= $this->getHtml('Open', '0', '0'); ?></a>
</div> </div>