Skip to content

Commit

Permalink
[Shipment] Improve interface inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Jan 20, 2021
1 parent e23ab6f commit af901b6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Entity/AdjustmentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Sylius\RefundPlugin\Entity;

use Sylius\Component\Core\Model\AdjustmentInterface as BaseAdjustmentInterface;
use Sylius\Component\Core\Model\ShipmentInterface as BaseShipmentInterface;

/**
* @internal
Expand All @@ -27,7 +28,7 @@ public function getDetails(): array;

public function setDetails(array $details): void;

public function getShipment(): ?ShipmentInterface;
public function getShipment(): ?BaseShipmentInterface;

public function setShipment(?ShipmentInterface $shipment): void;
public function setShipment(?BaseShipmentInterface $shipment): void;
}
7 changes: 5 additions & 2 deletions src/Entity/AdjustmentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Sylius\RefundPlugin\Entity;

use Sylius\Component\Order\Model\AdjustableInterface;
use Sylius\Component\Core\Model\ShipmentInterface as BaseShipmentInterface;

/**
* @internal
*
Expand Down Expand Up @@ -44,12 +47,12 @@ public function setDetails(array $details): void
$this->details = $details;
}

public function getShipment(): ?ShipmentInterface
public function getShipment(): ?BaseShipmentInterface
{
return $this->shipment;
}

public function setShipment(?ShipmentInterface $shipment): void
public function setShipment(?BaseShipmentInterface $shipment): void
{
if ($this->shipment === $shipment) {
return;
Expand Down
10 changes: 8 additions & 2 deletions src/Entity/ShipmentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
* This class is not covered by the backward compatibility promise and it will be removed after update Sylius to 1.9.
* It is a duplication of a logic from Sylius to provide proper adjustments handling.
*/
interface ShipmentInterface extends BaseShipmentInterface, AdjustableInterface
{
if (is_a(BaseShipmentInterface::class, AdjustableInterface::class, true)) {
interface ShipmentInterface extends BaseShipmentInterface
{
}
} else {
interface ShipmentInterface extends BaseShipmentInterface, AdjustableInterface
{
}
}

0 comments on commit af901b6

Please sign in to comment.