Skip to content

Commit a7c85e3

Browse files
committed
- PHP 8.2 support (explicit declaration properties)
- update example
1 parent 59bb62d commit a7c85e3

6 files changed

Lines changed: 84 additions & 56 deletions

File tree

src/Issue/Reporter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class Reporter implements \JsonSerializable
2828

2929
public string $accountId;
3030

31+
public string $locale;
32+
3133
#[\ReturnTypeWillChange]
3234
public function jsonSerialize()
3335
{

src/Project/Project.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ class Project implements \JsonSerializable
105105

106106
public string $simplified;
107107

108+
public string $style;
109+
110+
public bool $isPrivate;
111+
112+
public array $properties;
113+
114+
public string $entityId;
115+
116+
public string $uuid;
117+
108118
#[\ReturnTypeWillChange]
109119
public function jsonSerialize()
110120
{

src/Project/ProjectService.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ public function getAllProjects($paramArray = [])
4343
* @throws \JiraCloud\JiraException
4444
* @throws \JsonMapper_Exception
4545
*
46-
* @return Project
4746
*/
48-
public function get($projectIdOrKey)
47+
public function get(string|int $projectIdOrKey) : Project
4948
{
5049
$ret = $this->exec($this->uri."/$projectIdOrKey", null);
5150

@@ -65,11 +64,11 @@ public function get($projectIdOrKey)
6564
*
6665
* @param string|int $projectIdOrKey Project Key
6766
*
67+
* @return Reporter[]
6868
* @throws \JiraCloud\JiraException
6969
*
70-
* @return Reporter[]
7170
*/
72-
public function getAssignable($projectIdOrKey)
71+
public function getAssignable(string|int $projectIdOrKey) : array
7372
{
7473
$ret = $this->exec("/user/assignable/search?project=$projectIdOrKey", null);
7574
$json = json_decode($ret);

src/Version/VersionService.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function move(Version $version)
5858
*
5959
* @see ProjectService::getVersions()
6060
*/
61-
public function get(string $id)
61+
public function get(string $id) : Version
6262
{
6363
$ret = $this->exec($this->uri.'/'.$id);
6464

@@ -79,7 +79,7 @@ public function get(string $id)
7979
*
8080
* @return Version
8181
*/
82-
public function update(Version $version)
82+
public function update(Version $version) : Version
8383
{
8484
if (!$version->id || !is_numeric($version->id)) {
8585
throw new JiraException($version->id.' is not a valid version id.');
@@ -112,7 +112,7 @@ public function update(Version $version)
112112
*
113113
* @return string
114114
*/
115-
public function delete(Version $version, $moveAffectedIssuesTo = false, $moveFixIssuesTo = false)
115+
public function delete(Version $version, $moveAffectedIssuesTo = false, $moveFixIssuesTo = false) : string
116116
{
117117
if (!$version->id || !is_numeric($version->id)) {
118118
throw new JiraException($version->id.' is not a valid version id.');
@@ -147,7 +147,7 @@ public function merge($ver)
147147
*
148148
* @see https://docs.atlassian.com/jira/REST/server/#api/2/version-getVersionRelatedIssues
149149
*/
150-
public function getRelatedIssues(Version $version)
150+
public function getRelatedIssues(Version $version) : VersionIssueCounts
151151
{
152152
if (!$version->id || !is_numeric($version->id)) {
153153
throw new JiraException($version->id.' is not a valid version id.');
@@ -172,7 +172,7 @@ public function getRelatedIssues(Version $version)
172172
*
173173
* @return VersionUnresolvedCount
174174
*/
175-
public function getUnresolvedIssues(Version $version)
175+
public function getUnresolvedIssues(Version $version) : VersionUnresolvedCount
176176
{
177177
if (!$version->id || !is_numeric($version->id)) {
178178
throw new JiraException($version->id.' is not a valid version id.');

tests/ProjectTest.php

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,59 +16,64 @@ class ProjectTest extends TestCase
1616
* @test
1717
*
1818
*/
19-
public function get_project_info() : void
19+
public function get_project_lists() : string
2020
{
21+
$projKey = 'TEST';
2122
try {
2223
$proj = new ProjectService();
2324

24-
$p = $proj->get('TEST');
25+
$prjs = $proj->getAllProjects();
2526

26-
$this->assertTrue($p instanceof Project);
27-
$this->assertTrue(strlen($p->key) > 0);
28-
$this->assertTrue(!empty($p->id));
29-
$this->assertTrue(strlen($p->name) > 0);
30-
// $this->assertTrue(strlen($p->projectCategory['name']) > 0);
27+
foreach ($prjs as $p) {
28+
$this->assertTrue($p instanceof Project);
29+
$this->assertTrue(strlen($p->key) > 0);
30+
$this->assertTrue(!empty($p->id));
31+
$this->assertTrue(strlen($p->name) > 0);
32+
// $this->assertTrue(strlen($p->projectCategory['name']) > 0);
33+
34+
}
3135
} catch (\Exception $e) {
32-
$this->fail('get_project_info ' . $e->getMessage());
36+
$this->fail('get_project_lists ' . $e->getMessage());
3337
}
34-
}
3538

39+
return $projKey;
40+
}
3641
/**
3742
* @test
38-
* @depends get_project_info
39-
*
43+
* @depends get_project_lists
4044
*/
41-
public function get_project_lists() : void
45+
public function get_project_info(string $projKey) : string
4246
{
4347
try {
4448
$proj = new ProjectService();
4549

46-
$prjs = $proj->getAllProjects();
50+
$p = $proj->get($projKey);
51+
52+
$this->assertTrue($p instanceof Project);
53+
$this->assertTrue(strlen($p->key) > 0);
54+
$this->assertTrue(!empty($p->id));
55+
$this->assertTrue(strlen($p->name) > 0);
56+
// $this->assertTrue(strlen($p->projectCategory['name']) > 0);
4757

48-
foreach ($prjs as $p) {
49-
$this->assertTrue($p instanceof Project);
50-
$this->assertTrue(strlen($p->key) > 0);
51-
$this->assertTrue(!empty($p->id));
52-
$this->assertTrue(strlen($p->name) > 0);
53-
// $this->assertTrue(strlen($p->projectCategory['name']) > 0);
54-
}
5558
} catch (\Exception $e) {
56-
$this->fail('get_project_lists ' . $e->getMessage());
59+
$this->fail('get_project_info ' . $e->getMessage());
5760
}
61+
62+
return $projKey;
5863
}
5964

6065
/**
6166
* @test
62-
* @depends get_project_lists
67+
* @depends get_project_info
6368
*/
64-
public function get_project_types() : void
69+
public function get_project_types(string $projKey) : string
6570
{
6671
try {
6772
$proj = new ProjectService();
6873

69-
$prjtyps = $proj->getProjectTypes();
74+
$projectTypes = $proj->getProjectTypes();
7075

71-
foreach ($prjtyps as $pt) {
76+
foreach ($projectTypes as $pt) {
7277
$this->assertTrue($pt instanceof ProjectType);
7378
$this->assertTrue(strlen($pt->key) > 0);
7479
$this->assertTrue(strlen($pt->formattedKey) > 0);
@@ -79,65 +84,71 @@ public function get_project_types() : void
7984
} catch (\Exception $e) {
8085
$this->fail('get_project_types ' . $e->getMessage());
8186
}
87+
88+
return $projKey;
8289
}
8390

8491
/**
8592
* @test
8693
* @depends get_project_types
8794
*
8895
*/
89-
public function get_project_type() : void
96+
public function get_software_project_types_only(string $projKey) : string
9097
{
9198
try {
9299
$proj = new ProjectService();
93100

94-
$prjtyp = $proj->getProjectType('software');
101+
$projectType = $proj->getProjectType('software');
95102

96-
$this->assertTrue($prjtyp instanceof ProjectType);
97-
$this->assertTrue(strlen($prjtyp->key) > 0);
98-
$this->assertTrue(strlen($prjtyp->formattedKey) > 0);
99-
$this->assertTrue(strlen($prjtyp->descriptionI18nKey) > 0);
100-
$this->assertTrue(strlen($prjtyp->color) > 0);
101-
$this->assertTrue(strlen($prjtyp->icon) > 0);
103+
$this->assertTrue($projectType instanceof ProjectType);
104+
$this->assertTrue(strlen($projectType->key) > 0);
105+
$this->assertTrue(strlen($projectType->formattedKey) > 0);
106+
$this->assertTrue(strlen($projectType->descriptionI18nKey) > 0);
107+
$this->assertTrue(strlen($projectType->color) > 0);
108+
$this->assertTrue(strlen($projectType->icon) > 0);
102109
} catch (\Exception $e) {
103110
$this->fail('get_project_type ' . $e->getMessage());
104111
}
112+
113+
return $projKey;
105114
}
106115

107116

108117
/**
109118
* @test
110-
* @depends get_project_types
119+
* @depends get_software_project_types_only
111120
*
112121
*/
113-
public function get_project_accessible() : void
122+
public function get_project_accessible(string $projKey) : string
114123
{
115124
try {
116125
$proj = new ProjectService();
117126

118-
$prjtyp = $proj->getAccessibleProjectType('business');
127+
$projectType = $proj->getAccessibleProjectType('business');
119128

120-
$this->assertTrue($prjtyp instanceof ProjectType);
121-
$this->assertTrue(strlen($prjtyp->key) > 0);
122-
$this->assertTrue(strlen($prjtyp->formattedKey) > 0);
123-
$this->assertTrue(strlen($prjtyp->descriptionI18nKey) > 0);
124-
$this->assertTrue(strlen($prjtyp->color) > 0);
125-
$this->assertTrue(strlen($prjtyp->icon) > 0);
129+
$this->assertTrue($projectType instanceof ProjectType);
130+
$this->assertTrue(strlen($projectType->key) > 0);
131+
$this->assertTrue(strlen($projectType->formattedKey) > 0);
132+
$this->assertTrue(strlen($projectType->descriptionI18nKey) > 0);
133+
$this->assertTrue(strlen($projectType->color) > 0);
134+
$this->assertTrue(strlen($projectType->icon) > 0);
126135
} catch (\Exception $e) {
127136
$this->fail('get_project_accessible ' . $e->getMessage());
128137
}
138+
139+
return $projKey;
129140
}
130141

131142
/**
132143
* @test
133144
* @depends get_project_accessible
134145
*/
135-
public function get_project_version() : void
146+
public function get_project_version(string $projKey) : string
136147
{
137148
try {
138149
$proj = new ProjectService();
139150

140-
$prjs = $proj->getVersions('TEST');
151+
$prjs = $proj->getVersions($projKey);
141152

142153
$this->assertNull($prjs);
143154
$this->assertTrue($prjs instanceof \ArrayObject);
@@ -146,23 +157,27 @@ public function get_project_version() : void
146157
} catch (\Exception $e) {
147158
$this->fail('get_project_version ' . $e->getMessage());
148159
}
160+
161+
return $projKey;
149162
}
150163

151164
/**
152165
* @test
153166
* @depends get_project_accessible
154167
*
155168
*/
156-
public function get_unknown_project_type_expect_to_JiraException() : void
169+
public function get_unknown_project_type_expect_to_JiraException(string $projKey) : string
157170
{
158171
try {
159172
$proj = new ProjectService();
160173

161174
$this->expectException(JiraException::class);
162175

163-
$prjtyp = $proj->getProjectType('foobar');
176+
$projectType = $proj->getProjectType('foobar');
164177
} catch (\Exception $e) {
165178
$this->fail('get_project_type ' . $e->getMessage());
166179
}
180+
181+
return $projKey;
167182
}
168183
}

tests/VersionTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class VersionTest extends TestCase
2121
*/
2222
public function create_version() :string
2323
{
24-
$versionName = '2.3.4';
24+
$versionName = '2.3.5';
2525
try {
2626
$projectService = new ProjectService();
2727
$project = $projectService->get($this->project);
@@ -44,6 +44,8 @@ public function create_version() :string
4444
} catch (JiraException $e) {
4545
print("Error Occurred! " . $e->getMessage());
4646
}
47+
48+
return $versionName;
4749
}
4850

4951
/**

0 commit comments

Comments
 (0)