diff --git a/spec/Packagist/Api/Result/Package/DistSpec.php b/spec/Packagist/Api/Result/Package/DistSpec.php index d09f83e..d55ac25 100644 --- a/spec/Packagist/Api/Result/Package/DistSpec.php +++ b/spec/Packagist/Api/Result/Package/DistSpec.php @@ -43,4 +43,28 @@ public function it_gets_shasum() { $this->getShasum()->shouldReturn('cb0a489db41707d5df078f1f35e028e04ffd9e8e'); } + + public function it_can_deal_with_nullable_reference() + { + $this->fromArray([ + 'type' => 'git', + 'url' => 'https://github.com/Sylius/Sylius.git', + 'reference' => null, + 'shasum' => 'cb0a489db41707d5df078f1f35e028e04ffd9e8e', + ]); + + $this->getReference()->shouldReturn(null); + } + + public function it_can_deal_with_nullable_shasum() + { + $this->fromArray([ + 'type' => 'git', + 'url' => 'https://github.com/Sylius/Sylius.git', + 'reference' => 'cb0a489db41707d5df078f1f35e028e04ffd9e8e', + 'shasum' => null, + ]); + + $this->getShasum()->shouldReturn(null); + } } diff --git a/src/Packagist/Api/Result/Package/Dist.php b/src/Packagist/Api/Result/Package/Dist.php index c85a5c4..2f9cd96 100644 --- a/src/Packagist/Api/Result/Package/Dist.php +++ b/src/Packagist/Api/Result/Package/Dist.php @@ -4,17 +4,19 @@ namespace Packagist\Api\Result\Package; -class Dist extends Source +use Packagist\Api\Result\AbstractResult; + +class Dist extends AbstractResult { - protected string $shasum; + protected ?string $shasum; protected string $type; protected string $url; - protected string $reference; + protected ?string $reference; - public function getShasum(): string + public function getShasum(): ?string { return $this->shasum; } @@ -29,7 +31,7 @@ public function getUrl(): string return $this->url; } - public function getReference(): string + public function getReference(): ?string { return $this->reference; }