Skip to content

Commit

Permalink
Fix getId/id return type for entities
Browse files Browse the repository at this point in the history
  • Loading branch information
diimpp committed Sep 27, 2021
1 parent db6c77d commit a4fbe03
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 18 deletions.
6 changes: 6 additions & 0 deletions spec/Entity/BillingDataSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ function let(): void
);
}

function it_has_no_id_by_default(): void
{
$this->getId()->shouldReturn(null);
$this->id()->shouldReturn(null);
}

function it_implements_billing_data_interface(): void
{
$this->shouldImplement(BillingDataInterface::class);
Expand Down
5 changes: 5 additions & 0 deletions spec/Entity/InvoiceShopBillingDataSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ function it_implements_resource_interface(): void
$this->shouldImplement(ResourceInterface::class);
}

function it_has_no_id_by_default(): void
{
$this->getId()->shouldReturn(null);
}

function its_company_is_mutable(): void
{
$this->setCompany('Ragnarok');
Expand Down
6 changes: 6 additions & 0 deletions spec/Entity/LineItemSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ function let(): void
);
}

function it_has_no_id_by_default(): void
{
$this->getId()->shouldReturn(null);
$this->id()->shouldReturn(null);
}

function it_implements_line_item_interface(): void
{
$this->shouldImplement(LineItemInterface::class);
Expand Down
6 changes: 6 additions & 0 deletions spec/Entity/TaxItemSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ function it_implements_resource_interface(): void
$this->shouldImplement(ResourceInterface::class);
}

function it_has_no_id_by_default(): void
{
$this->getId()->shouldReturn(null);
$this->id()->shouldReturn(null);
}

function it_has_proper_tax_item_data(): void
{
$this->label()->shouldReturn('VAT (23%)');
Expand Down
6 changes: 3 additions & 3 deletions src/Entity/BillingData.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/** @final */
class BillingData implements BillingDataInterface, ResourceInterface
{
protected int $id;
protected ?int $id;

protected string $firstName;

Expand Down Expand Up @@ -60,12 +60,12 @@ public function __construct(
$this->company = $company;
}

public function getId(): int
public function getId(): ?int
{
return $this->id();
}

public function id(): int
public function id(): ?int
{
return $this->id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/BillingDataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

interface BillingDataInterface
{
public function id(): int;
public function id(): ?int;

public function firstName(): string;

Expand Down
5 changes: 2 additions & 3 deletions src/Entity/InvoiceShopBillingData.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
/** @final */
class InvoiceShopBillingData implements InvoiceShopBillingDataInterface, ResourceInterface
{
/** @var mixed */
protected $id;
protected ?int $id;

protected ?string $company = null;

Expand All @@ -35,7 +34,7 @@ class InvoiceShopBillingData implements InvoiceShopBillingDataInterface, Resourc

protected ?string $representative = null;

public function getId()
public function getId(): ?int
{
return $this->id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/InvoiceShopBillingDataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

interface InvoiceShopBillingDataInterface
{
public function getId();
public function getId(): ?int;

public function getCompany(): ?string;

Expand Down
7 changes: 3 additions & 4 deletions src/Entity/LineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
/** @final */
class LineItem implements LineItemInterface, ResourceInterface
{
/** @var mixed */
protected $id;
protected ?int $id;

protected InvoiceInterface $invoice;

Expand Down Expand Up @@ -64,12 +63,12 @@ public function __construct(
$this->taxRate = $taxRate;
}

public function getId()
public function getId(): ?int
{
return $this->id();
}

public function id()
public function id(): ?int
{
return $this->id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/LineItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

interface LineItemInterface
{
public function id();
public function id(): ?int;

public function invoice(): InvoiceInterface;

Expand Down
7 changes: 3 additions & 4 deletions src/Entity/TaxItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
/** @final */
class TaxItem implements TaxItemInterface, ResourceInterface
{
/** @var mixed */
protected $id;
protected ?int $id;

protected ?InvoiceInterface $invoice = null;

Expand All @@ -33,12 +32,12 @@ public function __construct(string $label, int $amount)
$this->amount = $amount;
}

public function getId()
public function getId(): ?int
{
return $this->id();
}

public function id()
public function id(): ?int
{
return $this->id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/TaxItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

interface TaxItemInterface
{
public function id();
public function id(): ?int;

public function invoice(): ?InvoiceInterface;

Expand Down

0 comments on commit a4fbe03

Please sign in to comment.