-
-
Notifications
You must be signed in to change notification settings - Fork 85
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 type for entities #208
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Sylius\InvoicingPlugin\Entity; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Sylius\InvoicingPlugin\Entity\InvoiceSequenceInterface; | ||
|
||
final class InvoiceSequenceSpec extends ObjectBehavior | ||
{ | ||
function it_implements_invoice_sequence_interface(): void | ||
{ | ||
$this->shouldImplement(InvoiceSequenceInterface::class); | ||
} | ||
|
||
function it_has_zero_index_after_initialized(): void | ||
{ | ||
$this->getIndex()->shouldReturn(0); | ||
} | ||
|
||
function it_increments_index(): void | ||
{ | ||
$this->incrementIndex(); | ||
$this->getIndex()->shouldReturn(1); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Sylius\InvoicingPlugin\Entity; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Resource\Model\ResourceInterface; | ||
use Sylius\InvoicingPlugin\Entity\InvoiceShopBillingDataInterface; | ||
|
||
final class InvoiceShopBillingDataSpec extends ObjectBehavior | ||
{ | ||
function it_implements_tax_item_interface(): void | ||
{ | ||
$this->shouldImplement(InvoiceShopBillingDataInterface::class); | ||
} | ||
|
||
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'); | ||
$this->getCompany()->shouldReturn('Ragnarok'); | ||
} | ||
|
||
function its_tax_id_is_mutable(): void | ||
{ | ||
$this->setTaxId('1100110011'); | ||
$this->getTaxId()->shouldReturn('1100110011'); | ||
} | ||
|
||
function its_country_code_is_mutable(): void | ||
{ | ||
$this->setCountryCode('US'); | ||
$this->getCountryCode()->shouldReturn('US'); | ||
} | ||
|
||
function its_street_is_mutable(): void | ||
{ | ||
$this->setStreet('Blue Street'); | ||
$this->getStreet()->shouldReturn('Blue Street'); | ||
} | ||
|
||
function its_city_is_mutable(): void | ||
{ | ||
$this->setCity('New York'); | ||
$this->getCity()->shouldReturn('New York'); | ||
} | ||
|
||
function its_postcode_is_mutable(): void | ||
{ | ||
$this->setPostcode('94111'); | ||
$this->getPostcode()->shouldReturn('94111'); | ||
} | ||
|
||
function its_representative_is_mutable(): void | ||
{ | ||
$this->setRepresentative('Billie Jackson'); | ||
$this->getRepresentative()->shouldReturn('Billie Jackson'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,7 @@ | |
/** @final */ | ||
class LineItem implements LineItemInterface, ResourceInterface | ||
{ | ||
/** @var mixed */ | ||
protected $id; | ||
protected ?int $id; | ||
|
||
protected InvoiceInterface $invoice; | ||
|
||
|
@@ -64,12 +63,12 @@ public function __construct( | |
$this->taxRate = $taxRate; | ||
} | ||
|
||
public function getId() | ||
public function getId(): ?int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would be for leaving it as it was before, without return type to keep id more customizable and consistent with all Sylius resources. I know that our mapping is configured for using integers, but it is relatively easy to change the strategy to use for example UUIDs instead of integers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would agree that Though this is concrete implementation that you're marking final. In such case it's totally alright to make it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you see, that BillingData id is already There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should |
||
{ | ||
return $this->id(); | ||
} | ||
|
||
public function id() | ||
public function id(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Methods re-arranged in order of class variables declaration/doctrine entities declaration