1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file has been created by developers from BitBag. |
||
5 | * Feel free to contact us once you face any issues or want to start |
||
6 | * You can find more information about us on https://bitbag.io and write us |
||
7 | * an email on [email protected]. |
||
8 | */ |
||
9 | |||
10 | declare(strict_types=1); |
||
11 | |||
12 | namespace BitBag\SyliusMolliePlugin\Remover\PartialShip; |
||
13 | |||
14 | use BitBag\SyliusMolliePlugin\DTO\PartialShipItems; |
||
15 | use Sylius\Component\Core\Model\OrderInterface; |
||
16 | use Sylius\Component\Core\Model\OrderItemUnitInterface; |
||
17 | use Sylius\Component\Core\Model\ShipmentInterface; |
||
18 | |||
19 | final class OldShipmentItemsRemover implements OldShipmentItemsRemoverInterface |
||
20 | { |
||
21 | public function remove(OrderInterface $order, PartialShipItems $shipItems): OrderInterface |
||
22 | { |
||
23 | /** @var ShipmentInterface $shipment */ |
||
24 | $shipment = $order->getShipments()->first(); |
||
25 | |||
26 | /** @var OrderItemUnitInterface $unit */ |
||
27 | foreach ($shipment->getUnits() as $unit) { |
||
28 | $item = $shipItems->findById($unit->getOrderItem()->getId()); |
||
0 ignored issues
–
show
|
|||
29 | if (null !== $item && $item->getQuantity() > 0) { |
||
30 | /** @var ShipmentInterface $oldShipment */ |
||
31 | $oldShipment = $unit->getShipment(); |
||
32 | |||
33 | $oldShipment->removeUnit($unit); |
||
34 | $item->setQuantity($item->getQuantity() - 1); |
||
35 | } |
||
36 | } |
||
37 | |||
38 | return $order; |
||
39 | } |
||
40 | } |
||
41 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.