Skip to content

Commit 8d2042d

Browse files
committed
fixed #272. phpdoc type and parameter validation.
1 parent 4810068 commit 8d2042d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Issue/IssueService.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function update($issueIdOrKey, $issueField, $paramArray = [])
214214
* Adds a new comment to an issue.
215215
*
216216
* @param string|int $issueIdOrKey Issue id or key
217-
* @param string $comment
217+
* @param Comment $comment
218218
*
219219
* @throws JiraException
220220
* @throws \JsonMapper_Exception
@@ -225,6 +225,10 @@ public function addComment($issueIdOrKey, $comment)
225225
{
226226
$this->log->info("addComment=\n");
227227

228+
if (! ($comment instanceof Comment) || empty($comment->body)) {
229+
throw new JiraException("comment param must instance of Comment and have to body text.!");
230+
}
231+
228232
$data = json_encode($comment);
229233

230234
$ret = $this->exec($this->uri."/$issueIdOrKey/comment", $data);
@@ -242,7 +246,7 @@ public function addComment($issueIdOrKey, $comment)
242246
*
243247
* @param string|int $issueIdOrKey Issue id or key
244248
* @param string|int $id Comment id
245-
* @param string $comment
249+
* @param Comment $comment
246250
*
247251
* @throws JiraException
248252
* @throws \JsonMapper_Exception
@@ -253,6 +257,10 @@ public function updateComment($issueIdOrKey, $id, $comment)
253257
{
254258
$this->log->info("updateComment=\n");
255259

260+
if (! ($comment instanceof Comment) || empty($comment->body)) {
261+
throw new JiraException("comment param must instance of Comment and have to body text.!");
262+
}
263+
256264
$data = json_encode($comment);
257265

258266
$ret = $this->exec($this->uri."/$issueIdOrKey/comment/$id", $data, 'PUT');

0 commit comments

Comments
 (0)