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

Use PHP 7.4 syntax #330

Merged
merged 4 commits into from
Sep 16, 2021
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
40 changes: 40 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
### UPGRADE FROM 1.0.0 TO 1.0.1

1. The return types of `Sylius\RefundPlugin\Entity\CustomerBillingDataInterface` method has been changed:

```diff
+ public function getFirstName(): ?string;
- public function getFirstName(): string;
+ public function getLastName(): ?string;
- public function getLastName(): string;
+ public function getStreet(): ?string;
- public function getStreet(): string;
+ public function getPostcode(): ?string;
- public function getPostcode(): string;
+ public function getCountryCode(): ?string;
- public function getCountryCode(): string;
+ public function getCity(): ?string;
- public function getCity(): string;
```

1. The return types of `Sylius\RefundPlugin\Entity\CreditMemoInterface` method has been changed:

```diff
+ public function getNumber(): ?string;
- public function getNumber(): string;
+ public function getOrder(): ?OrderInterface;
- public function getOrder(): OrderInterface;
+ public function getCurrencyCode(): ?string;
- public function getCurrencyCode(): string;
+ public function getLocaleCode(): ?string;
- public function getLocaleCode(): string;
+ public function getChannel(): ?ChannelInterface;
- public function getChannel(): ChannelInterface;
+ public function getComment(): ?string;
- public function getComment(): string;
+ public function getIssuedAt(): ?\DateTimeImmutable;
- public function getIssuedAt(): \DateTimeImmutable;
+ public function getFrom(): ?CustomerBillingDataInterface;
- public function getFrom(): CustomerBillingDataInterface;
```

### UPGRADE FROM 1.0.0-RC.11 TO 1.0.0

1. `orderNumber` field on `Sylius\RefundPlugin\Entity\Refund` and `Sylius\RefundPlugin\Entity\RefundPayment` has been removed
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"phpspec/phpspec": "^7.0",
"phpstan/phpstan": "0.12.84",
"phpstan/phpstan": "0.12.96",
"phpstan/phpstan-webmozart-assert": "0.12.12",
"phpunit/phpunit": "^9.5",
"sylius-labs/coding-standard": "^4.0",
"sylius-labs/coding-standard": "~4.0.0",
"symfony/browser-kit": "^4.4 || ^5.2",
"symfony/debug-bundle": "^4.4 || ^5.2",
"symfony/dotenv": "^4.4 || ^5.2",
Expand Down
6 changes: 2 additions & 4 deletions src/Action/Admin/DownloadCreditMemoAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

final class DownloadCreditMemoAction
{
/** @var CreditMemoPdfFileGeneratorInterface */
private $creditMemoPdfFileGenerator;
private CreditMemoPdfFileGeneratorInterface $creditMemoPdfFileGenerator;

/** @var CreditMemoFileResponseBuilderInterface */
private $creditMemoFileResponseBuilder;
private CreditMemoFileResponseBuilderInterface $creditMemoFileResponseBuilder;

public function __construct(
CreditMemoPdfFileGeneratorInterface $creditMemoPdfFileGenerator,
Expand Down
18 changes: 6 additions & 12 deletions src/Action/Admin/OrderRefundsListAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,17 @@

final class OrderRefundsListAction
{
/** @var OrderRepositoryInterface */
private $orderRepository;
private OrderRepositoryInterface $orderRepository;

/** @var OrderRefundingAvailabilityCheckerInterface */
private $orderRefundsListAvailabilityChecker;
private OrderRefundingAvailabilityCheckerInterface $orderRefundsListAvailabilityChecker;

/** @var RefundPaymentMethodsProviderInterface */
private $refundPaymentMethodsProvider;
private RefundPaymentMethodsProviderInterface $refundPaymentMethodsProvider;

/** @var Environment */
private $twig;
private Environment $twig;

/** @var Session */
private $session;
private Session $session;

/** @var UrlGeneratorInterface */
private $router;
private UrlGeneratorInterface $router;

public function __construct(
OrderRepositoryInterface $orderRepository,
Expand Down
15 changes: 5 additions & 10 deletions src/Action/Admin/RefundUnitsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,15 @@

final class RefundUnitsAction
{
/** @var MessageBusInterface */
private $commandBus;
private MessageBusInterface $commandBus;

/** @var Session */
private $session;
private Session $session;

/** @var UrlGeneratorInterface */
private $router;
private UrlGeneratorInterface $router;

/** @var RefundUnitsCommandCreatorInterface */
private $commandCreator;
private RefundUnitsCommandCreatorInterface $commandCreator;

/** @var LoggerInterface */
private $logger;
private LoggerInterface $logger;

public function __construct(
MessageBusInterface $commandBus,
Expand Down
18 changes: 9 additions & 9 deletions src/Action/Admin/SendCreditMemoAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,17 @@
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Webmozart\Assert\Assert;

final class SendCreditMemoAction
{
/** @var MessageBusInterface */
private $commandBus;
private MessageBusInterface $commandBus;

/** @var RepositoryInterface */
private $creditMemoRepository;
private RepositoryInterface $creditMemoRepository;

/** @var Session */
private $session;
private Session $session;

/** @var UrlGeneratorInterface */
private $router;
private UrlGeneratorInterface $router;

public function __construct(
MessageBusInterface $commandBus,
Expand All @@ -55,7 +52,10 @@ public function __invoke(Request $request): Response
$creditMemo = $this->creditMemoRepository->find($request->get('id'));

if ($creditMemo !== null) {
$this->commandBus->dispatch(new SendCreditMemo($creditMemo->getNumber()));
$number = $creditMemo->getNumber();
Assert::notNull($number);

$this->commandBus->dispatch(new SendCreditMemo($number));

return $this->addFlashAndRedirect('success', 'sylius_refund.resend_credit_memo_success');
}
Expand Down
15 changes: 5 additions & 10 deletions src/Action/CompleteRefundPaymentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,15 @@

final class CompleteRefundPaymentAction
{
/** @var Session */
private $session;
private Session $session;

/** @var ObjectRepository */
private $refundPaymentRepository;
private ObjectRepository $refundPaymentRepository;

/** @var RefundPaymentCompletedStateApplierInterface */
private $refundPaymentCompletedStateApplier;
private RefundPaymentCompletedStateApplierInterface $refundPaymentCompletedStateApplier;

/** @var RouterInterface */
private $router;
private RouterInterface $router;

/** @var OrderRepositoryInterface */
private $orderRepository;
private OrderRepositoryInterface $orderRepository;

public function __construct(
Session $session,
Expand Down
9 changes: 3 additions & 6 deletions src/Action/Shop/DownloadCreditMemoAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@

final class DownloadCreditMemoAction
{
/** @var CreditMemoPdfFileGeneratorInterface */
private $creditMemoPdfFileGenerator;
private CreditMemoPdfFileGeneratorInterface $creditMemoPdfFileGenerator;

/** @var CreditMemoCustomerRelationCheckerInterface */
private $creditMemoCustomerRelationChecker;
private CreditMemoCustomerRelationCheckerInterface $creditMemoCustomerRelationChecker;

/** @var CreditMemoFileResponseBuilderInterface */
private $creditMemoFileResponseBuilder;
private CreditMemoFileResponseBuilderInterface $creditMemoFileResponseBuilder;

public function __construct(
CreditMemoPdfFileGeneratorInterface $creditMemoPdfFileGenerator,
Expand Down
3 changes: 1 addition & 2 deletions src/Calculator/UnitRefundTotalCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

final class UnitRefundTotalCalculator implements UnitRefundTotalCalculatorInterface
{
/** @var RemainingTotalProviderInterface */
private $remainingTotalProvider;
private RemainingTotalProviderInterface $remainingTotalProvider;

public function __construct(RemainingTotalProviderInterface $remainingTotalProvider)
{
Expand Down
9 changes: 5 additions & 4 deletions src/Checker/CreditMemoCustomerRelationChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@
namespace Sylius\RefundPlugin\Checker;

use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Customer\Context\CustomerContextInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Sylius\RefundPlugin\Entity\CreditMemoInterface;
use Sylius\RefundPlugin\Exception\CreditMemoNotAccessible;

final class CreditMemoCustomerRelationChecker implements CreditMemoCustomerRelationCheckerInterface
{
/** @var CustomerContextInterface */
private $customerContext;
private CustomerContextInterface $customerContext;

/** @var RepositoryInterface */
private $creditMemoRepository;
private RepositoryInterface $creditMemoRepository;

public function __construct(
CustomerContextInterface $customerContext,
Expand All @@ -39,6 +38,8 @@ public function check(string $creditMemoId): void
{
/** @var CreditMemoInterface $creditMemo */
$creditMemo = $this->creditMemoRepository->find($creditMemoId);

/** @var OrderInterface $order */
$order = $creditMemo->getOrder();

/** @var CustomerInterface $orderCustomer */
Expand Down
3 changes: 1 addition & 2 deletions src/Checker/OrderFullyRefundedTotalChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

final class OrderFullyRefundedTotalChecker implements OrderFullyRefundedTotalCheckerInterface
{
/** @var OrderRefundedTotalProviderInterface */
private $orderRefundedTotalProvider;
private OrderRefundedTotalProviderInterface $orderRefundedTotalProvider;

public function __construct(OrderRefundedTotalProviderInterface $orderRefundedTotalProvider)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Checker/OrderRefundingAvailabilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

final class OrderRefundingAvailabilityChecker implements OrderRefundingAvailabilityCheckerInterface
{
/** @var OrderRepositoryInterface */
private $orderRepository;
private OrderRepositoryInterface $orderRepository;

public function __construct(OrderRepositoryInterface $orderRepository)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Checker/OrderRefundsListAvailabilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

final class OrderRefundsListAvailabilityChecker implements OrderRefundingAvailabilityCheckerInterface
{
/** @var OrderRepositoryInterface */
private $orderRepository;
private OrderRepositoryInterface $orderRepository;

public function __construct(OrderRepositoryInterface $orderRepository)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Checker/UnitRefundingAvailabilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

final class UnitRefundingAvailabilityChecker implements UnitRefundingAvailabilityCheckerInterface
{
/** @var RemainingTotalProviderInterface */
private $remainingTotalProvider;
private RemainingTotalProviderInterface $remainingTotalProvider;

public function __construct(RemainingTotalProviderInterface $remainingTotalProvider)
{
Expand Down
13 changes: 5 additions & 8 deletions src/Command/GenerateCreditMemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@

class GenerateCreditMemo
{
/** @var string */
private $orderNumber;
private string $orderNumber;

/** @var int */
private $total;
private int $total;

/** @var array|OrderItemUnitRefund[] */
private $units;
private array $units;

/** @var array|ShipmentRefund[] */
private $shipments;
private array $shipments;

/** @var string */
private $comment;
private string $comment;

public function __construct(string $orderNumber, int $total, array $units, array $shipments, string $comment)
{
Expand Down
13 changes: 5 additions & 8 deletions src/Command/RefundUnits.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@

class RefundUnits
{
/** @var string */
private $orderNumber;
private string $orderNumber;

/** @var array|OrderItemUnitRefund[] */
private $units;
private array $units;

/** @var array|ShipmentRefund[] */
private $shipments;
private array $shipments;

/** @var int */
private $paymentMethodId;
private int $paymentMethodId;

/** @var string */
private $comment;
private string $comment;

public function __construct(string $orderNumber, array $units, array $shipments, int $paymentMethodId, string $comment)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Command/SendCreditMemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

class SendCreditMemo
{
/** @var string */
private $number;
private string $number;

public function __construct(string $number)
{
Expand Down
18 changes: 9 additions & 9 deletions src/CommandHandler/GenerateCreditMemoHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,17 @@
use Sylius\RefundPlugin\Event\CreditMemoGenerated;
use Sylius\RefundPlugin\Generator\CreditMemoGeneratorInterface;
use Symfony\Component\Messenger\MessageBusInterface;
use Webmozart\Assert\Assert;

final class GenerateCreditMemoHandler
{
/** @var CreditMemoGeneratorInterface */
private $creditMemoGenerator;
private CreditMemoGeneratorInterface $creditMemoGenerator;

/** @var ObjectManager */
private $creditMemoManager;
private ObjectManager $creditMemoManager;

/** @var MessageBusInterface */
private $eventBus;
private MessageBusInterface $eventBus;

/** @var OrderRepositoryInterface */
private $orderRepository;
private OrderRepositoryInterface $orderRepository;

public function __construct(
CreditMemoGeneratorInterface $creditMemoGenerator,
Expand Down Expand Up @@ -64,6 +61,9 @@ public function __invoke(GenerateCreditMemo $command): void
$this->creditMemoManager->persist($creditMemo);
$this->creditMemoManager->flush();

$this->eventBus->dispatch(new CreditMemoGenerated($creditMemo->getNumber(), $orderNumber));
$number = $creditMemo->getNumber();
Assert::notNull($number);

$this->eventBus->dispatch(new CreditMemoGenerated($number, $orderNumber));
}
}
Loading