Skip to content

Commit

Permalink
Add constructor property promotion and change service definitions to …
Browse files Browse the repository at this point in the history
…xml for behat services
  • Loading branch information
marekrzytki committed Jun 4, 2024
1 parent 14a5d5a commit 6732c8b
Show file tree
Hide file tree
Showing 64 changed files with 473 additions and 943 deletions.
36 changes: 6 additions & 30 deletions src/Controller/Action/Admin/ImportDataAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,14 @@

final class ImportDataAction
{
/** @var ImportProcessorInterface */
private $importProcessor;

/** @var FormFactoryInterface */
private $formFactory;

/** @var RequestStack */
private $requestStack;

/** @var FormErrorsFlashHelperInterface */
private $formErrorsFlashHelper;

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

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

public function __construct(
ImportProcessorInterface $importProcessor,
FormFactoryInterface $formFactory,
RequestStack $requestStack,
FormErrorsFlashHelperInterface $formErrorsFlashHelper,
TranslatorInterface $translator,
Environment $twig,
private ImportProcessorInterface $importProcessor,
private FormFactoryInterface $formFactory,
private RequestStack $requestStack,
private FormErrorsFlashHelperInterface $formErrorsFlashHelper,
private TranslatorInterface $translator,
private Environment $twig,
) {
$this->importProcessor = $importProcessor;
$this->formFactory = $formFactory;
$this->requestStack = $requestStack;
$this->formErrorsFlashHelper = $formErrorsFlashHelper;
$this->translator = $translator;
$this->twig = $twig;
}

public function __invoke(Request $request): Response
Expand Down
18 changes: 3 additions & 15 deletions src/Controller/Action/Admin/ProductSearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,11 @@

final class ProductSearchAction
{
/** @var ProductRepositoryInterface */
private $productRepository;

/** @var LocaleContextInterface */
private $localeContext;

/** @var ViewHandler */
private $viewHandler;

public function __construct(
ProductRepositoryInterface $productRepository,
LocaleContextInterface $localeContext,
ViewHandler $viewHandler,
private ProductRepositoryInterface $productRepository,
private LocaleContextInterface $localeContext,
private ViewHandler $viewHandler,
) {
$this->productRepository = $productRepository;
$this->localeContext = $localeContext;
$this->viewHandler = $viewHandler;
}

public function __invoke(Request $request): Response
Expand Down
18 changes: 3 additions & 15 deletions src/Controller/Action/Admin/TaxonSearchAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,11 @@

final class TaxonSearchAction
{
/** @var TaxonRepositoryInterface */
private $taxonRepository;

/** @var LocaleContextInterface */
private $localeContext;

/** @var ViewHandler */
private $viewHandler;

public function __construct(
TaxonRepositoryInterface $taxonRepository,
LocaleContextInterface $localeContext,
ViewHandler $viewHandler,
private TaxonRepositoryInterface $taxonRepository,
private LocaleContextInterface $localeContext,
private ViewHandler $viewHandler,
) {
$this->taxonRepository = $taxonRepository;
$this->localeContext = $localeContext;
$this->viewHandler = $viewHandler;
}

public function __invoke(Request $request): Response
Expand Down
18 changes: 3 additions & 15 deletions src/Controller/Action/Admin/UploadEditorImageAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,11 @@

final class UploadEditorImageAction
{
/** @var MediaProviderResolverInterface */
private $mediaProviderResolver;

/** @var MediaRepositoryInterface */
private $mediaRepository;

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

public function __construct(
MediaProviderResolverInterface $mediaProviderResolver,
MediaRepositoryInterface $mediaRepository,
FactoryInterface $mediaFactory,
private MediaProviderResolverInterface $mediaProviderResolver,
private MediaRepositoryInterface $mediaRepository,
private FactoryInterface $mediaFactory,
) {
$this->mediaProviderResolver = $mediaProviderResolver;
$this->mediaRepository = $mediaRepository;
$this->mediaFactory = $mediaFactory;
}

public function __invoke(Request $request): Response
Expand Down
14 changes: 4 additions & 10 deletions src/Controller/Helper/FormErrorsFlashHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@

final class FormErrorsFlashHelper implements FormErrorsFlashHelperInterface
{
/** @var RequestStack */
private $requestStack;

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

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

public function addFlashErrors(FormInterface $form): void
Expand Down
6 changes: 1 addition & 5 deletions src/Controller/PageSlugController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@

final class PageSlugController
{
/** @var SlugGeneratorInterface */
private $slugGenerator;

public function __construct(SlugGeneratorInterface $slugGenerator)
public function __construct(private SlugGeneratorInterface $slugGenerator)
{
$this->slugGenerator = $slugGenerator;
}

public function generateAction(Request $request): JsonResponse
Expand Down
6 changes: 4 additions & 2 deletions src/EventListener/ResourceDeleteSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

final class ResourceDeleteSubscriber implements EventSubscriberInterface
{
public function __construct(private UrlGeneratorInterface $router, private RequestStack $requestStack)
{
public function __construct(
private UrlGeneratorInterface $router,
private RequestStack $requestStack
) {
}

public static function getSubscribedEvents(): array
Expand Down
6 changes: 1 addition & 5 deletions src/Form/Type/WysiwygType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@

final class WysiwygType extends AbstractType
{
/** @var UrlGeneratorInterface */
private $urlGenerator;

public function __construct(UrlGeneratorInterface $urlGenerator)
public function __construct(private UrlGeneratorInterface $urlGenerator)
{
$this->urlGenerator = $urlGenerator;
}

public function configureOptions(OptionsResolver $resolver): void
Expand Down
10 changes: 2 additions & 8 deletions tests/Behat/Context/Api/BlockContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@

final class BlockContext implements Context
{
private ApiClientInterface $apiClient;

private ResponseCheckerInterface $responseChecker;

public function __construct(
ApiClientInterface $apiClient,
ResponseCheckerInterface $responseChecker,
private ApiClientInterface $apiClient,
private ResponseCheckerInterface $responseChecker
) {
$this->apiClient = $apiClient;
$this->responseChecker = $responseChecker;
}

/**
Expand Down
10 changes: 2 additions & 8 deletions tests/Behat/Context/Api/FrequentlyAskedQuestionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@

final class FrequentlyAskedQuestionContext implements Context
{
private ApiClientInterface $apiClient;

private ResponseCheckerInterface $responseChecker;

public function __construct(
ApiClientInterface $apiClient,
ResponseCheckerInterface $responseChecker,
private ApiClientInterface $apiClient,
private ResponseCheckerInterface $responseChecker,
) {
$this->apiClient = $apiClient;
$this->responseChecker = $responseChecker;
}

/**
Expand Down
10 changes: 2 additions & 8 deletions tests/Behat/Context/Api/MediaContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@

final class MediaContext implements Context
{
private ApiClientInterface $apiClient;

private ResponseCheckerInterface $responseChecker;

public function __construct(
ApiClientInterface $apiClient,
ResponseCheckerInterface $responseChecker,
private ApiClientInterface $apiClient,
private ResponseCheckerInterface $responseChecker,
) {
$this->apiClient = $apiClient;
$this->responseChecker = $responseChecker;
}

/**
Expand Down
10 changes: 2 additions & 8 deletions tests/Behat/Context/Api/PageContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@

final class PageContext implements Context
{
private ApiClientInterface $apiClient;

private ResponseCheckerInterface $responseChecker;

public function __construct(
ApiClientInterface $apiClient,
ResponseCheckerInterface $responseChecker,
private ApiClientInterface $apiClient,
private ResponseCheckerInterface $responseChecker,
) {
$this->apiClient = $apiClient;
$this->responseChecker = $responseChecker;
}

/**
Expand Down
10 changes: 2 additions & 8 deletions tests/Behat/Context/Api/SectionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@

final class SectionContext implements Context
{
private ApiClientInterface $apiClient;

private ResponseCheckerInterface $responseChecker;

public function __construct(
ApiClientInterface $apiClient,
ResponseCheckerInterface $responseChecker,
private ApiClientInterface $apiClient,
private ResponseCheckerInterface $responseChecker,
) {
$this->apiClient = $apiClient;
$this->responseChecker = $responseChecker;
}

/**
Expand Down
24 changes: 4 additions & 20 deletions tests/Behat/Context/Setup/BlockContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,12 @@

final class BlockContext implements Context
{
/** @var SharedStorageInterface */
private $sharedStorage;

/** @var RandomStringGeneratorInterface */
private $randomStringGenerator;

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

/** @var BlockRepositoryInterface */
private $blockRepository;

public function __construct(
SharedStorageInterface $sharedStorage,
RandomStringGeneratorInterface $randomStringGenerator,
FactoryInterface $blockFactory,
BlockRepositoryInterface $blockRepository,
private SharedStorageInterface $sharedStorage,
private RandomStringGeneratorInterface $randomStringGenerator,
private FactoryInterface $blockFactory,
private BlockRepositoryInterface $blockRepository,
) {
$this->sharedStorage = $sharedStorage;
$this->randomStringGenerator = $randomStringGenerator;
$this->blockFactory = $blockFactory;
$this->blockRepository = $blockRepository;
}

/**
Expand Down
24 changes: 4 additions & 20 deletions tests/Behat/Context/Setup/FrequentlyAskedQuestionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,14 @@

final class FrequentlyAskedQuestionContext implements Context
{
/** @var SharedStorageInterface */
private $sharedStorage;

/** @var RandomStringGeneratorInterface */
private $randomStringGenerator;

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

public function __construct(
SharedStorageInterface $sharedStorage,
RandomStringGeneratorInterface $randomStringGenerator,
FactoryInterface $frequentlyAskedQuestionFactory,
FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository,
private SharedStorageInterface $sharedStorage,
private RandomStringGeneratorInterface $randomStringGenerator,
private FactoryInterface $frequentlyAskedQuestionFactory,
private FrequentlyAskedQuestionRepositoryInterface $frequentlyAskedQuestionRepository,
) {
$this->sharedStorage = $sharedStorage;
$this->randomStringGenerator = $randomStringGenerator;
$this->frequentlyAskedQuestionFactory = $frequentlyAskedQuestionFactory;
$this->frequentlyAskedQuestionRepository = $frequentlyAskedQuestionRepository;
}

/** @var FrequentlyAskedQuestionRepositoryInterface */
private $frequentlyAskedQuestionRepository;

/**
* @Given the store has a frequently asked question
*/
Expand Down
Loading

0 comments on commit 6732c8b

Please sign in to comment.