Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getId/id return typehints for entities #199

Merged
merged 2 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions spec/Entity/CreditMemoSequenceSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ function it_implements_sequence_interface(): void
$this->shouldImplement(SequenceInterface::class);
}

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

function it_has_incrementable_index(): void
{
$this->getIndex()->shouldReturn(0);
Expand Down
5 changes: 5 additions & 0 deletions spec/Entity/CustomerBillingDataSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ function it_implements_customer_billing_data_interface(): void
$this->shouldImplement(CustomerBillingDataInterface::class);
}

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

function it_has_customer_name(): void
{
$this->customerName()->shouldReturn('Rick Sanchez');
Expand Down
6 changes: 6 additions & 0 deletions spec/Entity/LineItemSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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_line_item_data(): void
{
$this->name()->shouldReturn('Mjolnir');
Expand Down
5 changes: 5 additions & 0 deletions spec/Entity/RefundPaymentSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ function it_implements_refund_payment_interface(): void
$this->shouldImplement(RefundPaymentInterface::class);
}

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

function it_has_order_number(): void
{
$this->getOrderNumber()->shouldReturn('000002');
Expand Down
5 changes: 5 additions & 0 deletions spec/Entity/RefundSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ function it_implements_refund_interface(): void
$this->shouldImplement(RefundInterface::class);
}

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

function it_has_order_number(): void
{
$this->getOrderNumber()->shouldReturn('000666');
Expand Down
5 changes: 5 additions & 0 deletions spec/Entity/ShopBillingDataSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ function it_implements_shop_billing_data_interface(): void
$this->shouldImplement(ShopBillingDataInterface::class);
}

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

function it_has_company(): void
{
$this->company()->shouldReturn('Needful Things');
Expand Down
6 changes: 6 additions & 0 deletions spec/Entity/TaxItemSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ function it_implements_tax_item_interface(): void
$this->shouldImplement(TaxItemInterface::class);
}

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

function it_has_a_label(): void
{
$this->label()->shouldReturn('VAT');
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/CreditMemoSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/** @final */
class CreditMemoSequence implements SequenceInterface
{
/** @var int */
/** @var int|null */
protected $id;

/** @var int */
Expand All @@ -16,7 +16,7 @@ class CreditMemoSequence implements SequenceInterface
/** @var int */
protected $version = 1;

public function getId(): int
public function getId(): ?int
{
return $this->id;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/CustomerBillingData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/** @final */
class CustomerBillingData implements CustomerBillingDataInterface
{
/** @var int */
/** @var int|null */
protected $id;

/** @var string */
Expand Down Expand Up @@ -54,7 +54,7 @@ public function __construct(
$this->provinceCode = $provinceCode;
}

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

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

public function customerName(): string;

Expand Down
6 changes: 3 additions & 3 deletions src/Entity/LineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/** @final */
class LineItem implements LineItemInterface
{
/** @var int */
/** @var int|null */
protected $id;

/** @var string */
Expand Down Expand Up @@ -56,12 +56,12 @@ public function __construct(
$this->taxRate = $taxRate;
}

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/LineItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

public function name(): string;

Expand Down
12 changes: 6 additions & 6 deletions src/Entity/RefundPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/** @final */
class RefundPayment implements RefundPaymentInterface
{
/** @var int */
/** @var int|null */
protected $id;

/** @var string */
Expand Down Expand Up @@ -41,6 +41,11 @@ public function __construct(
$this->paymentMethod = $paymentMethod;
}

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

public function getOrderNumber(): string
{
return $this->orderNumber;
Expand All @@ -66,11 +71,6 @@ public function setState(string $state): void
$this->state = $state;
}

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

public function getPaymentMethod(): PaymentMethodInterface
{
return $this->paymentMethod;
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/SequenceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

public function getIndex(): int;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/ShopBillingData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/** final */
class ShopBillingData implements ShopBillingDataInterface
{
/** @var int */
/** @var int|null */
protected $id;

/** @var string|null */
Expand Down Expand Up @@ -44,7 +44,7 @@ public function __construct(
$this->postcode = $postcode;
}

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

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

public function company(): ?string;

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

/** @var string */
Expand All @@ -22,12 +22,12 @@ public function __construct(string $label, int $amount)
$this->amount = $amount;
}

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/TaxItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

public function label(): string;

Expand Down
10 changes: 5 additions & 5 deletions src/Resources/config/doctrine/CreditMemo.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<mapped-superclass name="Sylius\RefundPlugin\Entity\CreditMemo" table="sylius_refund_credit_memo">
<id name="id" column="id" type="string" />

<field name="number" />
<field name="total" type="integer" />
<field name="currencyCode" column="currency_code" />
<field name="localeCode" column="locale_code" />
<field name="comment" type="text" />
<field name="number" column="number" type="string" />
<field name="total" column="total" type="integer" />
<field name="currencyCode" column="currency_code" type="string" />
<field name="localeCode" column="locale_code" type="string" />
<field name="comment" column="comment" type="text" />
<field name="issuedAt" column="issued_at" type="datetime" nullable="true" />

<many-to-one field="channel" target-entity="Sylius\Component\Core\Model\ChannelInterface">
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/config/doctrine/CreditMemoSequence.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>

<field name="index" column="idx" type="integer" />
<field name="version" type="integer" version="true" />
<field name="version" column="version" type="integer" version="true" />
</entity>
</doctrine-mapping>
16 changes: 8 additions & 8 deletions src/Resources/config/doctrine/CustomerBillingData.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<generator strategy="AUTO" />
</id>

<field name="customerName" column="customer_name"/>
<field name="street" />
<field name="postcode" />
<field name="countryCode" column="country_code"/>
<field name="city" />
<field name="company" nullable="true" />
<field name="provinceName" column="province_name" nullable="true" />
<field name="provinceCode" column="province_code" nullable="true" />
<field name="customerName" column="customer_name" type="string" />
<field name="street" column="street" type="string" />
<field name="postcode" column="postcode" type="string" />
<field name="countryCode" column="country_code" type="string" />
<field name="city" column="city" type="string" />
<field name="company" column="company" type="string" nullable="true" />
<field name="provinceName" column="province_name" type="string" nullable="true" />
<field name="provinceCode" column="province_code" type="string" nullable="true" />
</entity>
</doctrine-mapping>
8 changes: 4 additions & 4 deletions src/Resources/config/doctrine/LineItem.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sylius\RefundPlugin\Entity\LineItem" table="sylius_refund_line_item">
<id name="id" column="id" type="integer">
<generator />
<generator strategy="AUTO" />
</id>

<field name="name" />
<field name="quantity" type="integer" />
<field name="name" column="name" type="string" />
<field name="quantity" column="quantity" type="integer" />
<field name="unitNetPrice" column="unit_net_price" type="integer" />
<field name="unitGrossPrice" column="unit_gross_price" type="integer" />
<field name="netValue" column="net_value" type="integer" />
<field name="grossValue" column="gross_value" type="integer" />
<field name="taxAmount" column="tax_amount" type="integer" />
<field name="taxRate" column="tax_rate" nullable="true" />
<field name="taxRate" column="tax_rate" type="string" nullable="true" />
</mapped-superclass>
</doctrine-mapping>
8 changes: 4 additions & 4 deletions src/Resources/config/doctrine/Refund.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<generator strategy="AUTO" />
</id>

<field name="orderNumber" column="order_number" />
<field name="amount" type="integer" />
<field name="refundedUnitId" type="integer" nullable="true" column="refunded_unit_id"/>
<field name="type" type="sylius_refund_refund_type" />
<field name="orderNumber" column="order_number" type="string" />
<field name="amount" column="amount" type="integer" />
<field name="refundedUnitId" column="refunded_unit_id" type="integer" nullable="true" />
<field name="type" column="type" type="sylius_refund_refund_type" />
</mapped-superclass>
</doctrine-mapping>
8 changes: 4 additions & 4 deletions src/Resources/config/doctrine/RefundPayment.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<generator strategy="AUTO" />
</id>

<field name="orderNumber" column="order_number"/>
<field name="amount" type="integer" />
<field name="currencyCode" column="currency_code"/>
<field name="state" />
<field name="orderNumber" column="order_number" type="string" />
<field name="amount" column="amount" type="integer" />
<field name="currencyCode" column="currency_code" type="string" />
<field name="state" column="state" type="string" />

<many-to-one field="paymentMethod" target-entity="Sylius\Component\Payment\Model\PaymentMethodInterface">
<join-column name="payment_method_id" referenced-column-name="id" nullable="true" />
Expand Down
12 changes: 6 additions & 6 deletions src/Resources/config/doctrine/ShopBillingData.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<generator strategy="AUTO" />
</id>

<field name="company" nullable="true" />
<field name="taxId" column="tax_id" nullable="true" />
<field name="countryCode" column="country_code" nullable="true" />
<field name="street" nullable="true" />
<field name="city" nullable="true" />
<field name="postcode" nullable="true" />
<field name="company" column="company" type="string" nullable="true" />
<field name="taxId" column="tax_id" type="string" nullable="true" />
<field name="countryCode" column="country_code" type="string" nullable="true" />
<field name="street" column="street" type="string" nullable="true" />
<field name="city" column="city" type="string" nullable="true" />
<field name="postcode" column="postcode" type="string" nullable="true" />
</entity>
</doctrine-mapping>
6 changes: 3 additions & 3 deletions src/Resources/config/doctrine/TaxItem.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
>
<mapped-superclass name="Sylius\RefundPlugin\Entity\TaxItem" table="sylius_refund_tax_item">
<id name="id" column="id" type="integer">
<generator />
<generator strategy="AUTO" />
</id>

<field name="label" />
<field name="amount" type="integer" />
<field name="label" column="label" type="string" />
<field name="amount" column="amount" type="integer" />
</mapped-superclass>
</doctrine-mapping>