From 0fb0e8b3bdfc3f2386526e8e4f9afc563a699328 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 26 Dec 2022 20:52:58 +0100 Subject: [PATCH] fix phpstan lvl 9 bugs --- Controller/ApiController.php | 20 ++++++++++++++++---- Controller/BackendController.php | 2 ++ Models/KanbanBoard.php | 4 ++-- Models/KanbanCard.php | 4 ++-- Models/KanbanCardComment.php | 5 +++-- Theme/Backend/kanban-board.tpl.php | 2 +- Theme/Backend/kanban-dashboard.tpl.php | 2 +- 7 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index ea45752..18e2c2d 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -106,7 +106,12 @@ final class ApiController extends Controller $internalResponse = new HttpResponse(); $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 { $card->addTag(new NullTag((int) $tag['id'])); } @@ -305,7 +310,12 @@ final class ApiController extends Controller $internalResponse = new HttpResponse(); $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 { $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 { - $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); $this->updateModel($request->header->account, $old, $new, KanbanBoardMapper::class, 'board', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Board', 'Board successfully updated', $new); @@ -373,7 +385,7 @@ final class ApiController extends Controller { /** @var KanbanBoard $board */ $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->descriptionRaw = (string) ($request->getData('plain') ?? $board->descriptionRaw); $board->order = (int) ($request->getData('order') ?? $board->order); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index cb19913..b81935a 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -104,6 +104,7 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); + /** @var \Modules\Kanban\Models\KanbanBoard $board */ $board = KanbanBoardMapper::get() ->with('columns') ->with('columns/cards') @@ -211,6 +212,7 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); + /** @var \Modules\Kanban\Models\KanbanCard $card */ $card = KanbanCardMapper::get() ->with('tags') ->with('tags/title') diff --git a/Models/KanbanBoard.php b/Models/KanbanBoard.php index 0ff8551..982ef5f 100755 --- a/Models/KanbanBoard.php +++ b/Models/KanbanBoard.php @@ -221,13 +221,13 @@ class KanbanBoard implements \JsonSerializable /** * Add a column * - * @param mixed $column Column + * @param KanbanColumn $column Column * * @return void * * @since 1.0.0 */ - public function addColumn($column) : void + public function addColumn(KanbanColumn $column) : void { $this->columns[] = $column; } diff --git a/Models/KanbanCard.php b/Models/KanbanCard.php index 4f73eb8..78aacc3 100755 --- a/Models/KanbanCard.php +++ b/Models/KanbanCard.php @@ -263,13 +263,13 @@ class KanbanCard implements \JsonSerializable /** * Add a comment * - * @param mixed $comment Comment + * @param KanbanCardComment $comment Comment * * @return void * * @since 1.0.0 */ - public function addComment($comment) : void + public function addComment(KanbanCardComment $comment) : void { $this->comments[] = $comment; } diff --git a/Models/KanbanCardComment.php b/Models/KanbanCardComment.php index 1a5559b..7bdf4e8 100755 --- a/Models/KanbanCardComment.php +++ b/Models/KanbanCardComment.php @@ -16,6 +16,7 @@ namespace Modules\Kanban\Models; use Modules\Admin\Models\Account; use Modules\Admin\Models\NullAccount; +use Modules\Media\Models\Media; /** * Kanban card comment class. @@ -121,13 +122,13 @@ class KanbanCardComment implements \JsonSerializable /** * Add a media file * - * @param mixed $media Media + * @param Media $media Media * * @return void * * @since 1.0.0 */ - public function addMedia($media) : void + public function addMedia(Media $media) : void { $this->media[] = $media; } diff --git a/Theme/Backend/kanban-board.tpl.php b/Theme/Backend/kanban-board.tpl.php index 51df03c..c3c75e1 100755 --- a/Theme/Backend/kanban-board.tpl.php +++ b/Theme/Backend/kanban-board.tpl.php @@ -36,7 +36,7 @@ $columns = $board->getColumns();
getTags(); foreach ($tags as $tag) : ?> - icon !== null ? '' : ''; ?>printHtml($tag->getL11n()); ?> + icon) ? '' : ''; ?>printHtml($tag->getL11n()); ?> getHtml('More', '0', '0'); ?>
diff --git a/Theme/Backend/kanban-dashboard.tpl.php b/Theme/Backend/kanban-dashboard.tpl.php index 90d5298..df4ee6c 100755 --- a/Theme/Backend/kanban-dashboard.tpl.php +++ b/Theme/Backend/kanban-dashboard.tpl.php @@ -37,7 +37,7 @@ echo $this->getData('nav')->render(); ?>
getTags(); foreach ($tags as $tag) : ?> - icon !== null ? '' : ''; ?>printHtml($tag->getL11n()); ?> + icon) ? '' : ''; ?>printHtml($tag->getL11n()); ?> getHtml('Open', '0', '0'); ?>