diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 9ab00ce..6f6591b 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -97,7 +97,8 @@ final class ApiController extends Controller public function apiCommentListUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { /** @var \Modules\Comments\Models\CommentList $old */ - $old = clone CommentListMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $old = CommentListMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $old = clone $old; $new = $this->updateCommentListFromRequest($request); $this->updateModel($request->header->account, $old, $new, CommentListMapper::class, 'comment_list', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Comment List', 'Comment list successfully updated', $new); @@ -319,7 +320,8 @@ final class ApiController extends Controller public function apiCommentUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { /** @var \Modules\Comments\Models\Comment $old */ - $old = clone CommentMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $old = CommentMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $old = clone $old; $new = $this->updateCommentFromRequest($request); $this->updateModel($request->header->account, $old, $new, CommentMapper::class, 'comment', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Comment', 'Comment successfully updated', $new); @@ -338,10 +340,10 @@ final class ApiController extends Controller { /** @var \Modules\Comments\Models\Comment $comment */ $comment = CommentMapper::get()->where('id', (int) $request->getData('id'))->execute(); - $comment->title = $request->getData('title') ?? $comment->title; - $comment->contentRaw = $request->getData('plain') ?? $comment->contentRaw; + $comment->title = (string) ($request->getData('title') ?? $comment->title); + $comment->contentRaw = (string) ($request->getData('plain') ?? $comment->contentRaw); $comment->content = Markdown::parse((string) ($request->getData('plain') ?? $comment->contentRaw)); - $comment->ref = $request->getData('ref') ?? $comment->ref; + $comment->ref = $request->hasData('ref') ? (int) $request->getData('ref') : $comment->ref; return $comment; } diff --git a/Models/CommentVoteMapper.php b/Models/CommentVoteMapper.php index 195fbd2..6425510 100755 --- a/Models/CommentVoteMapper.php +++ b/Models/CommentVoteMapper.php @@ -76,7 +76,11 @@ final class CommentVoteMapper extends DataMapperFactory */ public static function findVote(int $comment, int $account) : CommentVote { - $results = self::getAll()->where('comment', $comment)->where('createdBy', $account)->execute(); + /** @var CommentVote[] $results */ + $results = self::getAll() + ->where('comment', $comment) + ->where('createdBy', $account) + ->execute(); return empty($results) ? new NullCommentVote() : \reset($results); } diff --git a/Theme/Backend/Components/Comment/CreateView.php b/Theme/Backend/Components/Comment/CreateView.php index 54a5147..135e2e1 100755 --- a/Theme/Backend/Components/Comment/CreateView.php +++ b/Theme/Backend/Components/Comment/CreateView.php @@ -36,7 +36,7 @@ class CreateView extends View * @var int * @since 1.0.0 */ - protected $list = 0; + protected int $list = 0; /** * {@inheritdoc} @@ -52,6 +52,7 @@ class CreateView extends View */ public function render(mixed ...$data) : string { + /** @var array{0:int} $data */ $this->list = $data[0]; return parent::render(); diff --git a/Theme/Backend/Components/Comment/ListView.php b/Theme/Backend/Components/Comment/ListView.php index 6dbcbaf..2135af8 100755 --- a/Theme/Backend/Components/Comment/ListView.php +++ b/Theme/Backend/Components/Comment/ListView.php @@ -53,6 +53,7 @@ class ListView extends View */ public function render(mixed ...$data) : string { + /** @var array{0:null|CommentList} $data */ $this->commentList = $data[0]; return parent::render();