From e7df13958b4493f85e56133b9b5931399dcbe5b6 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Fri, 22 Sep 2023 01:12:35 +0200 Subject: [PATCH] [CoreBundle] Move the PaymentFixture class in a proper namespace --- phpstan.neon.dist | 1 + .../Fixture/{Factory => }/PaymentFixture.php | 21 +++++++++++++++++-- .../config/services/fixtures_factories.xml | 4 +++- 3 files changed, 23 insertions(+), 3 deletions(-) rename src/Sylius/Bundle/CoreBundle/Fixture/{Factory => }/PaymentFixture.php (83%) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 30cc0a63e6..de42833874 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -40,3 +40,4 @@ parameters: - '/Method Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface\:\:supportsNormalization\(\) invoked with 3 parameters\, 1\-2 required\./' - '/(Interface|Class) [a-zA-Z\\]+ specifies template type (\w+) of interface [a-zA-Z\\]+ as [a-zA-Z\\]+ (of [a-zA-Z\\]+ )?but it''s already specified as/' # turns off a weird generics check behavior, we are basing on Psalm for generics checks - '/Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::normalize\(\) invoked with 2 parameters, 1 required./' + - '/Class "Sylius\\Bundle\\CoreBundle\\Fixture\\PaymentFixture" not found/' diff --git a/src/Sylius/Bundle/CoreBundle/Fixture/Factory/PaymentFixture.php b/src/Sylius/Bundle/CoreBundle/Fixture/PaymentFixture.php similarity index 83% rename from src/Sylius/Bundle/CoreBundle/Fixture/Factory/PaymentFixture.php rename to src/Sylius/Bundle/CoreBundle/Fixture/PaymentFixture.php index 11767847d9..044609f2a1 100644 --- a/src/Sylius/Bundle/CoreBundle/Fixture/Factory/PaymentFixture.php +++ b/src/Sylius/Bundle/CoreBundle/Fixture/PaymentFixture.php @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Sylius\Bundle\CoreBundle\Fixture\Factory; +namespace Sylius\Bundle\CoreBundle\Fixture; use Doctrine\Persistence\ObjectManager; use Faker\Factory; @@ -24,20 +24,34 @@ use Sylius\Component\Payment\PaymentTransitions; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\OptionsResolver\OptionsResolver; +class_alias(PaymentFixture::class, '\Sylius\Bundle\CoreBundle\Fixture\Factory\PaymentFixture'); + +trigger_deprecation( + 'sylius/core-bundle', + '1.13', + 'The "%s" class is deprecated and will be removed in Sylius 2.0. Use "%s" instead.', + '\Sylius\Bundle\CoreBundle\Fixture\Factory\PaymentFixture', + PaymentFixture::class, +); + class PaymentFixture extends AbstractFixture { private Generator $faker; private OptionsResolver $optionsResolver; + /** + * @param PaymentRepositoryInterface $paymentRepository + */ public function __construct( private PaymentRepositoryInterface $paymentRepository, private StateMachineFactoryInterface $stateMachineFactory, private ObjectManager $paymentManager, ) { + $this->faker = Factory::create(); + $this->optionsResolver = new OptionsResolver(); $this->configureOptions($this->optionsResolver); - $this->faker = Factory::create(); } public function getName(): string @@ -45,6 +59,9 @@ class PaymentFixture extends AbstractFixture return 'payments'; } + /** + * @param string[] $options + */ public function load(array $options): void { $options = $this->optionsResolver->resolve($options); diff --git a/src/Sylius/Bundle/CoreBundle/Resources/config/services/fixtures_factories.xml b/src/Sylius/Bundle/CoreBundle/Resources/config/services/fixtures_factories.xml index 478272058c..1c623b4e6e 100644 --- a/src/Sylius/Bundle/CoreBundle/Resources/config/services/fixtures_factories.xml +++ b/src/Sylius/Bundle/CoreBundle/Resources/config/services/fixtures_factories.xml @@ -182,11 +182,13 @@ - + + +