From 146790c0d0c1929bcaf25a485fbde9f1c3a57527 Mon Sep 17 00:00:00 2001 From: KwangSeob Jeong Date: Sun, 22 Mar 2020 06:33:46 +0000 Subject: [PATCH] Apply fixes from StyleCI [ci skip] [skip ci] --- src/Attachment/AttachmentService.php | 3 +- src/Auth/AuthService.php | 6 +- src/Field/FieldService.php | 7 ++- src/Field/Schema.php | 2 +- src/Group/GroupService.php | 9 ++- src/Issue/IssueService.php | 90 +++++++++++++++++++--------- src/Issue/JqlQuery.php | 18 ++++-- src/IssueLink/IssueLinkService.php | 4 +- src/JiraClient.php | 28 ++++++--- src/Project/ProjectService.php | 31 +++++++--- src/Sprint/SprintService.php | 6 +- src/User/UserService.php | 15 +++-- 12 files changed, 150 insertions(+), 69 deletions(-) diff --git a/src/Attachment/AttachmentService.php b/src/Attachment/AttachmentService.php index 9e12664e..80b5c4d0 100644 --- a/src/Attachment/AttachmentService.php +++ b/src/Attachment/AttachmentService.php @@ -32,7 +32,8 @@ public function get($id, $outDir = null, $overwrite = false, $mode = 0777, $recu $this->log->info("Result=\n".$ret); $attachment = $this->json_mapper->map( - json_decode($ret), new Attachment() + json_decode($ret), + new Attachment() ); if ($outDir == null) { diff --git a/src/Auth/AuthService.php b/src/Auth/AuthService.php index b3fdd23b..1827d42a 100644 --- a/src/Auth/AuthService.php +++ b/src/Auth/AuthService.php @@ -102,7 +102,8 @@ public function getCurrentUser() $ret = $this->exec($this->uri); $user = $this->json_mapper->map( - json_decode($ret), new CurrentUser() + json_decode($ret), + new CurrentUser() ); return $user; @@ -157,7 +158,8 @@ public function login($username = null, $password = null) ]), 'POST'); $session = $this->json_mapper->map( - json_decode($ret), new AuthSession() + json_decode($ret), + new AuthSession() ); return $session; diff --git a/src/Field/FieldService.php b/src/Field/FieldService.php index 719c88a3..266034a6 100644 --- a/src/Field/FieldService.php +++ b/src/Field/FieldService.php @@ -20,7 +20,9 @@ public function getAllFields($fieldType = Field::BOTH) $ret = $this->exec($this->uri, null); $fields = $this->json_mapper->mapArray( - json_decode($ret, false), new \ArrayObject(), '\JiraRestApi\Field\Field' + json_decode($ret, false), + new \ArrayObject(), + '\JiraRestApi\Field\Field' ); // temp array @@ -85,7 +87,8 @@ public function create(Field $field) $ret = $this->exec($this->uri, $data, 'POST'); $cf = $this->json_mapper->map( - json_decode($ret), new Field() + json_decode($ret), + new Field() ); return $cf; diff --git a/src/Field/Schema.php b/src/Field/Schema.php index a4eb777b..ac9e4406 100644 --- a/src/Field/Schema.php +++ b/src/Field/Schema.php @@ -32,7 +32,7 @@ class Schema */ public $custom; - /** custom filed id. Ex: 10201 + /** custom filed id. Ex: 10201. * @var string */ public $customId; diff --git a/src/Group/GroupService.php b/src/Group/GroupService.php index 0868fa95..ffe36aff 100644 --- a/src/Group/GroupService.php +++ b/src/Group/GroupService.php @@ -29,7 +29,8 @@ public function get($paramArray) $this->log->info("Result=\n".$ret); return $this->json_mapper->map( - json_decode($ret), new Group() + json_decode($ret), + new Group() ); } @@ -77,7 +78,8 @@ public function createGroup($group) $this->log->info("Result=\n".$ret); $group = $this->json_mapper->map( - json_decode($ret), new Group() + json_decode($ret), + new Group() ); return $group; @@ -103,7 +105,8 @@ public function addUserToGroup($groupName, $userName) $this->log->info("Result=\n".$ret); $group = $this->json_mapper->map( - json_decode($ret), new Group() + json_decode($ret), + new Group() ); return $group; diff --git a/src/Issue/IssueService.php b/src/Issue/IssueService.php index 7b0331de..b027a433 100644 --- a/src/Issue/IssueService.php +++ b/src/Issue/IssueService.php @@ -18,7 +18,8 @@ class IssueService extends \JiraRestApi\JiraClient public function getIssueFromJSON($json) { $issue = $this->json_mapper->map( - $json, new Issue() + $json, + new Issue() ); return $issue; @@ -50,7 +51,8 @@ public function get($issueIdOrKey, $paramArray = [], $issueObject = null) $this->log->info("Result=\n".$ret); return $issue = $this->json_mapper->map( - json_decode($ret), $issueObject + json_decode($ret), + $issueObject ); } @@ -162,16 +164,21 @@ public function addAttachments($issueIdOrKey, $filePathArray) $ret = json_decode($ret); if (is_array($ret)) { $tmpArr = $this->json_mapper->mapArray( - $ret, new \ArrayObject(), '\JiraRestApi\Issue\Attachment' + $ret, + new \ArrayObject(), + '\JiraRestApi\Issue\Attachment' ); foreach ($tmpArr as $t) { array_push($attachArr, $t); } } elseif (is_object($ret)) { - array_push($attachArr, $this->json_mapper->map( - $ret, new Attachment() - ) + array_push( + $attachArr, + $this->json_mapper->map( + $ret, + new Attachment() + ) ); } } @@ -235,7 +242,8 @@ public function addComment($issueIdOrKey, $comment) $this->log->debug('add comment result='.var_export($ret, true)); $comment = $this->json_mapper->map( - json_decode($ret), new Comment() + json_decode($ret), + new Comment() ); return $comment; @@ -267,7 +275,8 @@ public function updateComment($issueIdOrKey, $id, $comment) $this->log->debug('update comment result='.var_export($ret, true)); $comment = $this->json_mapper->map( - json_decode($ret), new Comment() + json_decode($ret), + new Comment() ); return $comment; @@ -292,8 +301,9 @@ public function getComment($issueIdOrKey, $id) $this->log->debug('get comment result='.var_export($ret, true)); $comment = $this->json_mapper->map( - json_decode($ret), new Comment() - ); + json_decode($ret), + new Comment() + ); return $comment; } @@ -316,8 +326,9 @@ public function getComments($issueIdOrKey) $this->log->debug('get comments result='.var_export($ret, true)); $comment = $this->json_mapper->map( - json_decode($ret), new Comment() - ); + json_decode($ret), + new Comment() + ); return $comment; } @@ -439,7 +450,9 @@ public function getTransition($issueIdOrKey, $paramArray = []) $data = json_encode(json_decode($ret)->transitions); $transitions = $this->json_mapper->mapArray( - json_decode($data), new \ArrayObject(), '\JiraRestApi\Issue\Transition' + json_decode($data), + new \ArrayObject(), + '\JiraRestApi\Issue\Transition' ); return $transitions; @@ -536,11 +549,13 @@ public function search($jql, $startAt = 0, $maxResults = 15, $fields = [], $expa $result = null; if ($this->isRestApiV3()) { $result = $this->json_mapper->map( - $json, new IssueSearchResultV3() + $json, + new IssueSearchResultV3() ); } else { $result = $this->json_mapper->map( - $json, new IssueSearchResult() + $json, + new IssueSearchResult() ); } @@ -563,7 +578,8 @@ public function getTimeTracking($issueIdOrKey) $this->log->debug("getTimeTracking res=$ret\n"); $issue = $this->json_mapper->map( - json_decode($ret), new Issue() + json_decode($ret), + new Issue() ); return $issue->fields->timeTracking; @@ -614,7 +630,8 @@ public function getWorklog($issueIdOrKey) $ret = $this->exec($this->uri."/$issueIdOrKey/worklog"); $this->log->debug("getWorklog res=$ret\n"); $worklog = $this->json_mapper->map( - json_decode($ret), new PaginatedWorklog() + json_decode($ret), + new PaginatedWorklog() ); return $worklog; @@ -636,7 +653,8 @@ public function getWorklogById($issueIdOrKey, $workLogId) $ret = $this->exec($this->uri."/$issueIdOrKey/worklog/$workLogId"); $this->log->debug("getWorklogById res=$ret\n"); $worklog = $this->json_mapper->map( - json_decode($ret), new Worklog() + json_decode($ret), + new Worklog() ); return $worklog; @@ -664,7 +682,8 @@ public function addWorklog($issueIdOrKey, $worklog) $ret = $this->exec($url, $data, $type); $ret_worklog = $this->json_mapper->map( - json_decode($ret), new Worklog() + json_decode($ret), + new Worklog() ); return $ret_worklog; @@ -693,7 +712,8 @@ public function editWorklog($issueIdOrKey, $worklog, $worklogId) $ret = $this->exec($url, $data, $type); $ret_worklog = $this->json_mapper->map( - json_decode($ret), new Worklog() + json_decode($ret), + new Worklog() ); return $ret_worklog; @@ -718,7 +738,7 @@ public function deleteWorklog($issueIdOrKey, $worklogId) $ret = $this->exec($url, null, $type); - return (bool)$ret; + return (bool) $ret; } /** @@ -733,7 +753,9 @@ public function getAllPriorities() $ret = $this->exec('priority', null); $priorities = $this->json_mapper->mapArray( - json_decode($ret, false), new \ArrayObject(), '\JiraRestApi\Issue\Priority' + json_decode($ret, false), + new \ArrayObject(), + '\JiraRestApi\Issue\Priority' ); return $priorities; @@ -757,7 +779,8 @@ public function getPriority($priorityId) $this->log->info('Result='.$ret); $prio = $this->json_mapper->map( - json_decode($ret), new Priority() + json_decode($ret), + new Priority() ); return $prio; @@ -781,7 +804,8 @@ public function getCustomFields($priorityId) $this->log->info('Result='.$ret); $prio = $this->json_mapper->map( - json_decode($ret), new Priority() + json_decode($ret), + new Priority() ); return $prio; @@ -805,7 +829,9 @@ public function getWatchers($issueIdOrKey) $ret = $this->exec($url, null); $watchers = $this->json_mapper->mapArray( - json_decode($ret, false)->watchers, new \ArrayObject(), '\JiraRestApi\Issue\Reporter' + json_decode($ret, false)->watchers, + new \ArrayObject(), + '\JiraRestApi\Issue\Reporter' ); return $watchers; @@ -987,7 +1013,9 @@ public function getRemoteIssueLink($issueIdOrKey) $ret = $this->exec($full_uri, null); $rils = $this->json_mapper->mapArray( - json_decode($ret, false), new \ArrayObject(), RemoteIssueLink::class + json_decode($ret, false), + new \ArrayObject(), + RemoteIssueLink::class ); return $rils; @@ -1013,7 +1041,8 @@ public function createOrUpdateRemoteIssueLink($issueIdOrKey, RemoteIssueLink $ri $ret = $this->exec($full_uri, $data, 'POST'); $res = $this->json_mapper->map( - json_decode($ret), new RemoteIssueLink() + json_decode($ret), + new RemoteIssueLink() ); return $res; @@ -1067,7 +1096,9 @@ public function getAllIssueSecuritySchemes() $schemes = json_decode(json_encode($data['issueSecuritySchemes']), false); $res = $this->json_mapper->mapArray( - $schemes, new \ArrayObject(), '\JiraRestApi\Issue\SecurityScheme' + $schemes, + new \ArrayObject(), + '\JiraRestApi\Issue\SecurityScheme' ); return $res; @@ -1090,7 +1121,8 @@ public function getIssueSecuritySchemes($securityId) $ret = $this->exec($url); $res = $this->json_mapper->map( - json_decode($ret), new SecurityScheme() + json_decode($ret), + new SecurityScheme() ); return $res; diff --git a/src/Issue/JqlQuery.php b/src/Issue/JqlQuery.php index 159381cb..7141e107 100644 --- a/src/Issue/JqlQuery.php +++ b/src/Issue/JqlQuery.php @@ -539,8 +539,10 @@ public function addAnyExpression($expression) */ public function addExpression($field, $operator, $value, $logicLinkKeyword = self::KEYWORD_AND) { - $this->joinExpression(self::quoteField($field)." $operator ".self::quote($value), - $logicLinkKeyword); + $this->joinExpression( + self::quoteField($field)." $operator ".self::quote($value), + $logicLinkKeyword + ); return $this; } @@ -563,8 +565,10 @@ public function addInExpression($field, $values, $logicLinkKeyword = self::KEYWO foreach ($values as $value) { $valuesQuoted[] = self::quote($value); } - $this->joinExpression(self::quoteField($field).' in ('.implode(', ', $valuesQuoted).')', - $logicLinkKeyword); + $this->joinExpression( + self::quoteField($field).' in ('.implode(', ', $valuesQuoted).')', + $logicLinkKeyword + ); return $this; } @@ -587,8 +591,10 @@ public function addNotInExpression($field, $values, $logicLinkKeyword = self::KE foreach ($values as $value) { $valuesQuoted[] = self::quote($value); } - $this->joinExpression(self::quoteField($field).' not in ('.implode(', ', $valuesQuoted).')', - $logicLinkKeyword); + $this->joinExpression( + self::quoteField($field).' not in ('.implode(', ', $valuesQuoted).')', + $logicLinkKeyword + ); return $this; } diff --git a/src/IssueLink/IssueLinkService.php b/src/IssueLink/IssueLinkService.php index b8322cb7..c95d908c 100644 --- a/src/IssueLink/IssueLinkService.php +++ b/src/IssueLink/IssueLinkService.php @@ -41,7 +41,9 @@ public function getIssueLinkTypes() $data = json_encode(json_decode($ret)->issueLinkTypes); $linkTypes = $this->json_mapper->mapArray( - json_decode($data, false), new \ArrayObject(), '\JiraRestApi\IssueLink\IssueLinkType' + json_decode($data, false), + new \ArrayObject(), + '\JiraRestApi\IssueLink\IssueLinkType' ); return $linkTypes; diff --git a/src/JiraClient.php b/src/JiraClient.php index eadb7c3c..756b39db 100644 --- a/src/JiraClient.php +++ b/src/JiraClient.php @@ -225,8 +225,11 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki } curl_setopt($ch, CURLOPT_ENCODING, ''); - curl_setopt($ch, CURLOPT_HTTPHEADER, - ['Accept: */*', 'Content-Type: application/json', 'X-Atlassian-Token: no-check']); + curl_setopt( + $ch, + CURLOPT_HTTPHEADER, + ['Accept: */*', 'Content-Type: application/json', 'X-Atlassian-Token: no-check'] + ); curl_setopt($ch, CURLOPT_VERBOSE, $this->getConfiguration()->isCurlOptVerbose()); @@ -290,8 +293,11 @@ private function createUploadHandle($url, $upload_file, $ch) $attachments = realpath($upload_file); $filename = basename($upload_file); - curl_setopt($ch, CURLOPT_POSTFIELDS, - ['file' => '@'.$attachments.';filename='.$filename]); + curl_setopt( + $ch, + CURLOPT_POSTFIELDS, + ['file' => '@'.$attachments.';filename='.$filename] + ); $this->log->debug('using legacy file upload'); } else { @@ -299,8 +305,11 @@ private function createUploadHandle($url, $upload_file, $ch) $attachments = new \CURLFile(realpath($upload_file)); $attachments->setPostFilename(basename($upload_file)); - curl_setopt($ch, CURLOPT_POSTFIELDS, - ['file' => $attachments]); + curl_setopt( + $ch, + CURLOPT_POSTFIELDS, + ['file' => $attachments] + ); $this->log->debug('using CURLFile='.var_export($attachments, true)); } @@ -523,8 +532,11 @@ public function download($url, $outDir, $file, $cookieFile = null) curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); } - curl_setopt($ch, CURLOPT_HTTPHEADER, - ['Accept: */*', 'Content-Type: application/json', 'X-Atlassian-Token: no-check']); + curl_setopt( + $ch, + CURLOPT_HTTPHEADER, + ['Accept: */*', 'Content-Type: application/json', 'X-Atlassian-Token: no-check'] + ); curl_setopt($ch, CURLOPT_VERBOSE, $this->getConfiguration()->isCurlOptVerbose()); diff --git a/src/Project/ProjectService.php b/src/Project/ProjectService.php index ae1dfe30..1cff7895 100644 --- a/src/Project/ProjectService.php +++ b/src/Project/ProjectService.php @@ -25,7 +25,9 @@ public function getAllProjects($paramArray = []) $ret = $this->exec($this->uri.$this->toHttpQueryParameter($paramArray), null); $prjs = $this->json_mapper->mapArray( - json_decode($ret, false), new \ArrayObject(), '\JiraRestApi\Project\Project' + json_decode($ret, false), + new \ArrayObject(), + '\JiraRestApi\Project\Project' ); return $prjs; @@ -49,7 +51,8 @@ public function get($projectIdOrKey) $this->log->info('Result='.$ret); $prj = $this->json_mapper->map( - json_decode($ret), new Project() + json_decode($ret), + new Project() ); return $prj; @@ -128,7 +131,8 @@ public function getProjectType($key) $this->log->info('Result='.$ret); $type = $this->json_mapper->map( - json_decode($ret, false), new ProjectType() + json_decode($ret, false), + new ProjectType() ); return $type; @@ -149,7 +153,8 @@ public function getAccessibleProjectType($key) $this->log->info('Result='.$ret); $type = $this->json_mapper->map( - json_decode($ret, false), new ProjectType() + json_decode($ret, false), + new ProjectType() ); return $type; @@ -187,7 +192,9 @@ public function getVersionsPagenated($projectIdOrKey, $queryParam = []) $json = json_decode($ret); $versions = $this->json_mapper->mapArray( - $json->values, new \ArrayObject(), '\JiraRestApi\Issue\Version' + $json->values, + new \ArrayObject(), + '\JiraRestApi\Issue\Version' ); return $versions; @@ -209,7 +216,9 @@ public function getVersions($projectIdOrKey) $this->log->info('Result='.$ret); $versions = $this->json_mapper->mapArray( - json_decode($ret, false), new \ArrayObject(), '\JiraRestApi\Issue\Version' + json_decode($ret, false), + new \ArrayObject(), + '\JiraRestApi\Issue\Version' ); return $versions; @@ -232,7 +241,9 @@ public function getVersion($projectIdOrKey, $versionName) $this->log->info('Result='.$ret); $versions = $this->json_mapper->mapArray( - json_decode($ret, false), new \ArrayObject(), '\JiraRestApi\Issue\Version' + json_decode($ret, false), + new \ArrayObject(), + '\JiraRestApi\Issue\Version' ); foreach ($versions as $v) { @@ -262,7 +273,8 @@ public function createProject($project) $this->log->info('createProject Result='.$ret); return $this->json_mapper->map( - json_decode($ret), new Project() + json_decode($ret), + new Project() ); } @@ -288,7 +300,8 @@ public function updateProject($project, $projectIdOrKey) $this->log->info('updateProject Result='.$ret); return $this->json_mapper->map( - json_decode($ret), new Project() + json_decode($ret), + new Project() ); } diff --git a/src/Sprint/SprintService.php b/src/Sprint/SprintService.php index 80785c80..ffaad706 100644 --- a/src/Sprint/SprintService.php +++ b/src/Sprint/SprintService.php @@ -28,7 +28,8 @@ public function __construct(ConfigurationInterface $configuration = null, Logger public function getSprintFromJSON($json) { $sprint = $this->json_mapper->map( - $json, new Sprint() + $json, + new Sprint() ); return $sprint; @@ -51,7 +52,8 @@ public function getSprint($sprintId) $this->log->info("Result=\n".$ret); return $sprint = $this->json_mapper->map( - json_decode($ret), new Sprint() + json_decode($ret), + new Sprint() ); } diff --git a/src/User/UserService.php b/src/User/UserService.php index 6592105b..4608a27d 100644 --- a/src/User/UserService.php +++ b/src/User/UserService.php @@ -32,7 +32,8 @@ public function create($user) $ret = $this->exec($this->uri, $data, 'POST'); return $this->json_mapper->map( - json_decode($ret), new User() + json_decode($ret), + new User() ); } @@ -56,7 +57,8 @@ public function get($paramArray) $this->log->info("Result=\n".$ret); return $this->json_mapper->map( - json_decode($ret), new User() + json_decode($ret), + new User() ); } @@ -83,7 +85,8 @@ public function findUsers($paramArray) foreach ($userData as $user) { $users[] = $this->json_mapper->map( - $user, new User() + $user, + new User() ); } @@ -149,7 +152,8 @@ public function findUsersByQuery($paramArray) foreach ($userData->values as $user) { $users[] = $this->json_mapper->map( - $user, new User() + $user, + new User() ); } @@ -186,7 +190,8 @@ public function getMyself() $ret = $this->exec('myself', null); $user = $this->json_mapper->map( - json_decode($ret), new Reporter() + json_decode($ret), + new Reporter() ); return $user;