Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Jan 13, 2021
1 parent 590a54b commit a3e2a6c
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions easy-coding-standard.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
imports:
- { resource: 'vendor/sylius-labs/coding-standard/easy-coding-standard.yml' }

parameters:
skip:
SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff.MissingVariable: ~
2 changes: 1 addition & 1 deletion src/Entity/ShipmentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Sylius\RefundPlugin\Entity;

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

/**
* @internal
Expand Down
3 changes: 3 additions & 0 deletions src/Entity/ShipmentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Doctrine\Common\Collections\Collection;
use Sylius\Component\Order\Model\AdjustmentInterface as BaseAdjustmentInterface;
use Webmozart\Assert\Assert;

/**
* @internal
Expand Down Expand Up @@ -64,6 +65,8 @@ public function getAdjustments(?string $type = null): Collection
public function addAdjustment(BaseAdjustmentInterface $adjustment): void
{
/** @var AdjustmentInterface $adjustment */
Assert::isInstanceOf($adjustment, AdjustmentInterface::class);

if ($this->hasAdjustment($adjustment)) {
return;
}
Expand Down
7 changes: 5 additions & 2 deletions src/Migrations/Version20201208105207.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function down(Schema $schema): void
$this->setDefaultAdjustmentData();
}

private function getShippingMethodName(?string $shippingMethodCode)
private function getShippingMethodName(?string $shippingMethodCode): ?string
{
if ($shippingMethodCode === null) {
return $shippingMethodCode;
Expand All @@ -76,7 +76,10 @@ private function getParsedDetails(array $details): string
}
}

return json_encode($parsedDetails);
/** @var string $encodedDetails */
$encodedDetails = json_encode($parsedDetails);

return $encodedDetails;
}

private function setDefaultAdjustmentData(): void
Expand Down
3 changes: 1 addition & 2 deletions src/OrderProcessor/OrderTaxesProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,14 @@ private function getTaxZone(OrderInterface $order): ?ZoneInterface
return $zone ?: $this->defaultTaxZoneProvider->getZone($order);
}

private function clearTaxes(BaseOrderInterface $order): void
private function clearTaxes(OrderInterface $order): void
{
$order->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT);

foreach ($order->getItems() as $item) {
$item->removeAdjustmentsRecursively(AdjustmentInterface::TAX_ADJUSTMENT);
}

/** @var OrderInterface $order */
/** @var ShipmentInterface $shipment */
foreach ($order->getShipments() as $shipment) {
$shipment->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT);
Expand Down
3 changes: 3 additions & 0 deletions src/OrderProcessor/ShippingChargesProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Sylius\Component\Shipping\Calculator\DelegatingCalculatorInterface;
use Sylius\Component\Shipping\Calculator\UndefinedShippingMethodException;
use Sylius\RefundPlugin\Entity\AdjustmentInterface;
use Sylius\RefundPlugin\Entity\ShipmentInterface;
use Webmozart\Assert\Assert;

/**
Expand Down Expand Up @@ -52,12 +53,14 @@ public function process(BaseOrderInterface $order): void
// Remove all shipping adjustments, we recalculate everything from scratch.
$order->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT);

/** @var ShipmentInterface $shipment */
foreach ($order->getShipments() as $shipment) {
$shipment->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT);

try {
$shippingCharge = $this->shippingChargesCalculator->calculate($shipment);
$shippingMethod = $shipment->getMethod();
Assert::notNull($shippingMethod);

/** @var AdjustmentInterface $adjustment */
$adjustment = $this->adjustmentFactory->createNew();
Expand Down
1 change: 1 addition & 0 deletions src/TaxesApplicator/OrderItemUnitsTaxesApplicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function apply(OrderInterface $order, ZoneInterface $zone): void
continue;
}

/** @var OrderItemUnitInterface $unit */
foreach ($item->getUnits() as $unit) {
$taxAmount = $this->calculator->calculate($unit->getTotal(), $taxRate);
if (0.00 === $taxAmount) {
Expand Down
1 change: 1 addition & 0 deletions src/TaxesApplicator/OrderItemsTaxesApplicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function apply(OrderInterface $order, ZoneInterface $zone): void
$splitTaxes = $this->distributor->distribute($totalTaxAmount, $quantity);

$i = 0;
/** @var OrderItemUnitInterface $unit */
foreach ($item->getUnits() as $unit) {
if (0 === $splitTaxes[$i]) {
continue;
Expand Down

0 comments on commit a3e2a6c

Please sign in to comment.