Skip to content

Commit cf3906e

Browse files
Merge pull request #78 from jdrieghe/master
Mark reference and shasum of dist correctly as nullable
2 parents 233caf6 + ca44317 commit cf3906e

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

Diff for: spec/Packagist/Api/Result/Package/DistSpec.php

+24
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,28 @@ public function it_gets_shasum()
4343
{
4444
$this->getShasum()->shouldReturn('cb0a489db41707d5df078f1f35e028e04ffd9e8e');
4545
}
46+
47+
public function it_can_deal_with_nullable_reference()
48+
{
49+
$this->fromArray([
50+
'type' => 'git',
51+
'url' => 'https://github.com/Sylius/Sylius.git',
52+
'reference' => null,
53+
'shasum' => 'cb0a489db41707d5df078f1f35e028e04ffd9e8e',
54+
]);
55+
56+
$this->getReference()->shouldReturn(null);
57+
}
58+
59+
public function it_can_deal_with_nullable_shasum()
60+
{
61+
$this->fromArray([
62+
'type' => 'git',
63+
'url' => 'https://github.com/Sylius/Sylius.git',
64+
'reference' => 'cb0a489db41707d5df078f1f35e028e04ffd9e8e',
65+
'shasum' => null,
66+
]);
67+
68+
$this->getShasum()->shouldReturn(null);
69+
}
4670
}

Diff for: src/Packagist/Api/Result/Package/Dist.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44

55
namespace Packagist\Api\Result\Package;
66

7-
class Dist extends Source
7+
use Packagist\Api\Result\AbstractResult;
8+
9+
class Dist extends AbstractResult
810
{
9-
protected string $shasum;
11+
protected ?string $shasum;
1012

1113
protected string $type;
1214

1315
protected string $url;
1416

15-
protected string $reference;
17+
protected ?string $reference;
1618

17-
public function getShasum(): string
19+
public function getShasum(): ?string
1820
{
1921
return $this->shasum;
2022
}
@@ -29,7 +31,7 @@ public function getUrl(): string
2931
return $this->url;
3032
}
3133

32-
public function getReference(): string
34+
public function getReference(): ?string
3335
{
3436
return $this->reference;
3537
}

0 commit comments

Comments
 (0)