From b5eb3cab16270a07220c01c8534fc119368d0ab7 Mon Sep 17 00:00:00 2001 From: KwangSeob Jeong Date: Sun, 12 Feb 2023 17:55:56 +0900 Subject: [PATCH] Apply fixes from StyleCI (#501) [ci skip] [skip ci] Co-authored-by: StyleCI Bot --- src/Issue/Version.php | 1 - src/Project/ProjectService.php | 69 +++++++++++++++++----------------- src/User/User.php | 1 - src/User/UserService.php | 54 +++++++++++++------------- 4 files changed, 60 insertions(+), 65 deletions(-) diff --git a/src/Issue/Version.php b/src/Issue/Version.php index 86820f3f..fd33a301 100644 --- a/src/Issue/Version.php +++ b/src/Issue/Version.php @@ -2,7 +2,6 @@ namespace JiraRestApi\Issue; -use DateTime; use DateTimeInterface; class Version implements \JsonSerializable diff --git a/src/Project/ProjectService.php b/src/Project/ProjectService.php index 04fde291..423743b9 100644 --- a/src/Project/ProjectService.php +++ b/src/Project/ProjectService.php @@ -45,7 +45,7 @@ public function getAllProjects($paramArray = []) * * @return Project */ - public function get($projectIdOrKey) : Project + public function get($projectIdOrKey): Project { $ret = $this->exec($this->uri."/$projectIdOrKey", null); @@ -65,11 +65,11 @@ public function get($projectIdOrKey) : Project * * @param int|string $projectIdOrKey Project Key * - * @return Reporter[] *@throws \JiraRestApi\JiraException * + * @return Reporter[] */ - public function getAssignable(int|string $projectIdOrKey) : array + public function getAssignable(int|string $projectIdOrKey): array { $ret = $this->exec("/user/assignable/search?project=$projectIdOrKey", null); $json = json_decode($ret); @@ -83,11 +83,11 @@ public function getAssignable(int|string $projectIdOrKey) : array /** * @param int|string $projectIdOrKey * - * @return IssueType[] *@throws \JiraRestApi\JiraException * + * @return IssueType[] */ - public function getStatuses(int|string $projectIdOrKey) : array + public function getStatuses(int|string $projectIdOrKey): array { $ret = $this->exec($this->uri."/$projectIdOrKey/statuses", null); $json = json_decode($ret); @@ -103,11 +103,11 @@ public function getStatuses(int|string $projectIdOrKey) : array * * @param int|string $projectIdOrKey * - * @return \JiraRestApi\Component\Component[] *@throws \JiraRestApi\JiraException * + * @return \JiraRestApi\Component\Component[] */ - public function getProjectComponents(int|string $projectIdOrKey) : array + public function getProjectComponents(int|string $projectIdOrKey): array { $ret = $this->exec($this->uri."/$projectIdOrKey/components", null); $json = json_decode($ret); @@ -123,12 +123,12 @@ public function getProjectComponents(int|string $projectIdOrKey) : array * * @param int|string $projectIdOrKey * - * @return array - * @return array *@throws JiraException * + * @return array + * @return array */ - public function getProjectTransitionsToArray(int|string $projectIdOrKey) : array + public function getProjectTransitionsToArray(int|string $projectIdOrKey): array { $ret = $this->exec($this->uri."/$projectIdOrKey/statuses", null); $json = json_decode($ret); @@ -157,7 +157,7 @@ public function getProjectTransitionsToArray(int|string $projectIdOrKey) : array * * @return ProjectType[] */ - public function getProjectTypes() : array + public function getProjectTypes(): array { $ret = $this->exec($this->uri.'/type'); @@ -174,12 +174,12 @@ public function getProjectTypes() : array /** * @param int|string $key * - * @return ProjectType *@throws \JsonMapper_Exception - * * @throws \JiraRestApi\JiraException + * + * @return ProjectType */ - public function getProjectType(int|string $key) : ProjectType + public function getProjectType(int|string $key): ProjectType { $ret = $this->exec($this->uri."/type/$key"); @@ -196,12 +196,12 @@ public function getProjectType(int|string $key) : ProjectType /** * @param int|string $key * - * @return ProjectType *@throws \JsonMapper_Exception - * * @throws \JiraRestApi\JiraException + * + * @return ProjectType */ - public function getAccessibleProjectType(int|string $key) : ProjectType + public function getAccessibleProjectType(int|string $key): ProjectType { $ret = $this->exec($this->uri."/type/$key/accessible"); @@ -219,13 +219,13 @@ public function getAccessibleProjectType(int|string $key) : ProjectType * get pagenated Project versions. * * @param int|string $projectIdOrKey - * @param array $queryParam + * @param array $queryParam * - * @return Version[] array of version *@throws \JiraRestApi\JiraException * + * @return Version[] array of version */ - public function getVersionsPagenated(int|string $projectIdOrKey, array $queryParam = []) : array + public function getVersionsPagenated(int|string $projectIdOrKey, array $queryParam = []): array { $default = [ 'startAt' => 0, @@ -277,13 +277,13 @@ public function getVersions(string $projectIdOrKey): \ArrayObject * get specified's project version. * * @param int|string $projectIdOrKey - * @param string $versionName + * @param string $versionName * - * @return Version version *@throws \JiraRestApi\JiraException * + * @return Version version */ - public function getVersion(int|string $projectIdOrKey, string $versionName) : Version + public function getVersion(int|string $projectIdOrKey, string $versionName): Version { $ret = $this->exec($this->uri."/$projectIdOrKey/versions"); @@ -309,12 +309,11 @@ public function getVersion(int|string $projectIdOrKey, string $versionName) : Ve * * @param Project $project * - * @return Project project - * * @throws JiraException * + * @return Project project */ - public function createProject(Project $project) : Project + public function createProject(Project $project): Project { $data = json_encode($project); @@ -336,12 +335,12 @@ public function createProject(Project $project) : Project * * @param Project $project * - * @return Project *@throws \JsonMapper_Exception - * * @throws JiraException + * + * @return Project */ - public function updateProject(Project $project, string|int $projectIdOrKey) : Project + public function updateProject(Project $project, string|int $projectIdOrKey): Project { $data = json_encode($project); @@ -358,16 +357,16 @@ public function updateProject(Project $project, string|int $projectIdOrKey) : Pr /** * @param int|string $projectIdOrKey * + *@throws JiraException + * * @return string response status * * STATUS 401 Returned if the user is not logged in. * STATUS 204 - application/json Returned if the project is successfully deleted. * STATUS 403 - Returned if the currently authenticated user does not have permission to delete the project. * STATUS 404 - Returned if the project does not exist. - *@throws JiraException - * */ - public function deleteProject(int|string $projectIdOrKey) : string + public function deleteProject(int|string $projectIdOrKey): string { $ret = $this->exec($this->uri.'/'.$projectIdOrKey, null, 'DELETE'); @@ -379,6 +378,8 @@ public function deleteProject(int|string $projectIdOrKey) : string * * @param int|string $projectIdOrKey * + *@throws JiraException + * * @return string response status * * STATUS 401 Returned if the user is not logged in. @@ -386,10 +387,8 @@ public function deleteProject(int|string $projectIdOrKey) : string * STATUS 403 - Returned if the currently authenticated user does not have permission to archive the project. * STATUS 404 - Returned if the project does not exist. * STATUS 405 - Method not allowed specified request HTTP method was received and recognized by the server, but is not supported by the target resource. - *@throws JiraException - * */ - public function archiveProject(int|string $projectIdOrKey) : string + public function archiveProject(int|string $projectIdOrKey): string { $ret = $this->exec($this->uri.'/'.$projectIdOrKey.'/archive', null, 'PUT'); diff --git a/src/User/User.php b/src/User/User.php index 6fdb6197..500f1df1 100644 --- a/src/User/User.php +++ b/src/User/User.php @@ -2,7 +2,6 @@ namespace JiraRestApi\User; -use JiraRestApi\ClassSerialize; use JiraRestApi\Issue\Reporter; /** diff --git a/src/User/UserService.php b/src/User/UserService.php index 252f97b6..b5b4a19f 100644 --- a/src/User/UserService.php +++ b/src/User/UserService.php @@ -2,8 +2,6 @@ namespace JiraRestApi\User; -use JiraRestApi\Issue\Reporter; - /** * Class to perform all user related queries. * @@ -18,12 +16,12 @@ class UserService extends \JiraRestApi\JiraClient * * @param array|User $user * - * @return User User class * @throws \JsonMapper_Exception - * * @throws \JiraRestApi\JiraException + * + * @return User User class */ - public function create(array|User $user) : User + public function create(array|User $user): User { $data = json_encode($user); @@ -43,12 +41,12 @@ public function create(array|User $user) : User * @param array $paramArray Possible values for $paramArray 'username', 'key'. * "Either the 'username' or the 'key' query parameters need to be provided". * - * @return User * @throws \JsonMapper_Exception - * * @throws \JiraRestApi\JiraException + * + * @return User */ - public function get(array $paramArray) : User + public function get(array $paramArray): User { $queryParam = '?'.http_build_query($paramArray); @@ -67,12 +65,12 @@ public function get(array $paramArray) : User * * @param array $paramArray * - * @return User[] *@throws \JsonMapper_Exception - * * @throws \JiraRestApi\JiraException + * + * @return User[] */ - public function findUsers(array $paramArray) : array + public function findUsers(array $paramArray): array { $queryParam = '?'.http_build_query($paramArray); @@ -99,14 +97,14 @@ public function findUsers(array $paramArray) : array * * @param array $paramArray * - * @return User[] - * * @throws \JsonMapper_Exception - * * @throws \JiraRestApi\JiraException + * + * @return User[] + * * @see https://docs.atlassian.com/jira/REST/cloud/#api/2/user-findAssignableUsers */ - public function findAssignableUsers(array $paramArray) : array + public function findAssignableUsers(array $paramArray): array { $queryParam = '?'.http_build_query($paramArray); @@ -132,14 +130,14 @@ public function findAssignableUsers(array $paramArray) : array * * @param array $paramArray * - * @return User[] - * * @throws \JsonMapper_Exception - * * @throws \JiraRestApi\JiraException + * + * @return User[] + * * @see https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-user-search-query-get */ - public function findUsersByQuery(array $paramArray) : array + public function findUsersByQuery(array $paramArray): array { $queryParam = '?'.http_build_query($paramArray); @@ -169,7 +167,7 @@ public function findUsersByQuery(array $paramArray) : array * * @return string */ - public function deleteUser(array $paramArray) : string + public function deleteUser(array $paramArray): string { $queryParam = '?'.http_build_query($paramArray); @@ -185,7 +183,7 @@ public function deleteUser(array $paramArray) : string * * @return User */ - public function getMyself() : User + public function getMyself(): User { $ret = $this->exec('myself', null); @@ -200,12 +198,12 @@ public function getMyself() : User /** * @param array $paramArray * - * @return User[] *@throws \JsonMapper_Exception - * * @throws \JiraRestApi\JiraException + * + * @return User[] */ - public function getUsers(array $paramArray) : array + public function getUsers(array $paramArray): array { $queryParam = '?'.http_build_query($paramArray); @@ -226,15 +224,15 @@ public function getUsers(array $paramArray) : array /** * Function to update an existing user. * - * @param array $paramArray + * @param array $paramArray * @param array|User $user * - * @return User * @throws \JsonMapper_Exception - * * @throws \JiraRestApi\JiraException + * + * @return User */ - public function update(array $paramArray, array|User $user) : User + public function update(array $paramArray, array|User $user): User { $queryParam = '?'.http_build_query($paramArray);