Skip to content

Commit

Permalink
DES-2 Update code to PHP 8 capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslavtyc committed Feb 8, 2025
1 parent 1641744 commit af63d04
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 96 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"phpstan/phpstan-webmozart-assert": "^1.2.0",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"rector/rector": "^0.18.12",
"rector/rector": "^1.2",
"sylius-labs/coding-standard": "^4.2",
"symfony/browser-kit": "^5.4",
"symfony/debug-bundle": "^5.4",
Expand Down
54 changes: 9 additions & 45 deletions src/Controller/ShipmentExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,59 +26,23 @@

class ShipmentExportController
{
/** @var ParameterBagInterface */
private $parameterBag;

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

/** @var EntityManager */
private $entityManager;

/** @var FlashBagInterface */
private $flashBag;

/** @var FactoryInterface */
private $stateMachineFatory;

/** @var EventDispatcherInterface */
private $eventDispatcher;

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

/** @var ShipmentExporterInterface */
private $shipmentExporter;

/** @var ShipmentRepositoryInterface&EntityRepository<ShipmentInterface> */
private $shipmentRepository;

/** @var TranslatorInterface */
private $translator;

public function __construct(
Environment $templatingEngine,
EntityManager $entityManager,
FlashBagInterface $flashBag,
FactoryInterface $stateMachineFatory,
EventDispatcherInterface $eventDispatcher,
RouterInterface $router,
ShipmentExporterInterface $shipmentExporter,
ParameterBagInterface $parameterBag,
private Environment $templatingEngine,
private EntityManager $entityManager,
private FlashBagInterface $flashBag,
private FactoryInterface $stateMachineFatory,
private EventDispatcherInterface $eventDispatcher,
private RouterInterface $router,
private ShipmentExporterInterface $shipmentExporter,
private ParameterBagInterface $parameterBag,
ShipmentRepositoryInterface $shipmentRepository,
TranslatorInterface $translator,
private TranslatorInterface $translator,
) {
$this->templatingEngine = $templatingEngine;
$this->entityManager = $entityManager;
$this->flashBag = $flashBag;
$this->stateMachineFatory = $stateMachineFatory;
$this->eventDispatcher = $eventDispatcher;
$this->router = $router;
$this->shipmentExporter = $shipmentExporter;
$this->parameterBag = $parameterBag;
assert($shipmentRepository instanceof EntityRepository);
$this->shipmentRepository = $shipmentRepository;
$this->translator = $translator;
}

public function showAllUnshipShipments(string $exporterName): Response
Expand Down
14 changes: 2 additions & 12 deletions src/Factory/ShipmentExportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,8 @@

class ShipmentExportFactory
{
/** @var RequestStack */
private $requestStack;

/** @var ServiceRegistryInterface */
private $serviceRegistry;

public function __construct(
RequestStack $requestStack,
ServiceRegistryInterface $serviceRegistry,
) {
$this->requestStack = $requestStack;
$this->serviceRegistry = $serviceRegistry;
public function __construct(private RequestStack $requestStack, private ServiceRegistryInterface $serviceRegistry)
{
}

/**
Expand Down
9 changes: 2 additions & 7 deletions src/Menu/ShipmentExportMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@

final class ShipmentExportMenuBuilder
{
/** @var ParameterBagInterface */
private $parameterBag;

public function __construct(
ParameterBagInterface $parameterBag,
) {
$this->parameterBag = $parameterBag;
public function __construct(private ParameterBagInterface $parameterBag)
{
}

public function buildMenu(MenuBuilderEvent $event): void
Expand Down
9 changes: 2 additions & 7 deletions src/Model/CeskaPostaShipmentExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@

class CeskaPostaShipmentExporter implements ShipmentExporterInterface
{
/** @var CurrencyConverter */
private $currencyConverter;

public function __construct(
CurrencyConverter $currencyConverter,
) {
$this->currencyConverter = $currencyConverter;
public function __construct(private CurrencyConverter $currencyConverter)
{
}

private function convert(int $amount, string $sourceCurrencyCode, string $targetCurrencyCode): int
Expand Down
9 changes: 2 additions & 7 deletions src/Model/GeisShipmentExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@

class GeisShipmentExporter implements ShipmentExporterInterface
{
/** @var CurrencyConverter */
private $currencyConverter;

public function __construct(
CurrencyConverter $currencyConverter,
) {
$this->currencyConverter = $currencyConverter;
public function __construct(private CurrencyConverter $currencyConverter)
{
}

private function convert(int $amount, string $sourceCurrencyCode, string $targetCurrencyCode): int
Expand Down
18 changes: 1 addition & 17 deletions src/Model/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,8 @@

class Question implements QuestionInterface
{
/** @var string */
private $code;

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

/** @var string|null */
private $defaultValue;

/** @var string|null */
private $regex;

public function __construct(string $code, string $label, ?string $defaultValue, ?string $regex)
public function __construct(private string $code, private string $label, private ?string $defaultValue, private ?string $regex)
{
$this->code = $code;
$this->label = $label;
$this->defaultValue = $defaultValue;
$this->regex = $regex;
}

public function getCode(): string
Expand Down

0 comments on commit af63d04

Please sign in to comment.