Skip to content

Commit 25f83be

Browse files
committed
fixed #522 avoiding $emailAddress property accessed before initialization error.
1 parent 35be23f commit 25f83be

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/Issue/Reporter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Reporter implements \JsonSerializable
1616

1717
public ?string $name;
1818

19-
public ?string $emailAddress;
19+
public ?string $emailAddress = null;
2020

2121
public array $avatarUrls;
2222

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"reporter": {
3+
"self": "https://jira.example.com/rest/api/2/user?username=lesstif",
4+
"name": "lesstif",
5+
"key": "lesstif",
6+
"avatarUrls": {
7+
"48x48": "https://secure.gravatar.com/avatar/9f1705ef1d8c977eba04f00556e02922?d=mm&s=48",
8+
"24x24": "https://secure.gravatar.com/avatar/9f1705ef1d8c977eba04f00556e02922?d=mm&s=24",
9+
"16x16": "https://secure.gravatar.com/avatar/9f1705ef1d8c977eba04f00556e02922?d=mm&s=16",
10+
"32x32": "https://secure.gravatar.com/avatar/9f1705ef1d8c977eba04f00556e02922?d=mm&s=32"
11+
},
12+
"displayName": "정광섭",
13+
"active": true,
14+
"timeZone": "Asia/Seoul"
15+
}
16+
}

tests/MapperTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22

33
namespace JiraRestApi\Test;
44

@@ -89,4 +89,17 @@ public function testIssue()
8989

9090
}
9191

92+
public function testReporterField()
93+
{
94+
$ret = file_get_contents('test-data/reporter-no-email-address.json');
95+
96+
$reporter = $this->mapper->map(
97+
json_decode($ret), new Reporter()
98+
);
99+
100+
$this->assertInstanceOf(Reporter::class, $reporter);
101+
102+
$this->assertEquals('[email protected]', $reporter->emailAddress);
103+
}
104+
92105
}

0 commit comments

Comments
 (0)