PHP 8 syntax in bundles vol.3

This commit is contained in:
Mateusz Zalewski 2022-01-31 16:03:07 +01:00
parent bf579b4497
commit b21b626e67
No known key found for this signature in database
GPG key ID: 9BECA0BB71612E52
159 changed files with 617 additions and 1322 deletions

View file

@ -4,6 +4,7 @@ use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
use SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\CodingStandard\Fixer\Spacing\StandaloneLinePromotedPropertyFixer;
use Symplify\EasyCodingStandard\ValueObject\Option;
return static function (ContainerConfigurator $containerConfigurator): void {
@ -20,6 +21,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
//file that was distributed with this source code.',
// ]);
$containerConfigurator->services()->set(StandaloneLinePromotedPropertyFixer::class);
$containerConfigurator->parameters()->set(Option::SKIP, [
InlineDocCommentDeclarationSniff::class . '.MissingVariable',
InlineDocCommentDeclarationSniff::class . '.NoAssignment',

View file

@ -34,92 +34,50 @@ use Twig\Environment as TwigEnvironment;
*/
final class SwaggerUiAction
{
private ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory;
private ResourceMetadataFactoryInterface $resourceMetadataFactory;
private NormalizerInterface $normalizer;
private TwigEnvironment $twig;
private UrlGeneratorInterface $urlGenerator;
private string $title;
private string $description;
private string $version;
private bool $showWebby;
private ?array $formats;
private $oauthEnabled;
private $oauthClientId;
private $oauthClientSecret;
private $oauthType;
private $oauthFlow;
private $oauthTokenUrl;
private $oauthAuthorizationUrl;
private $oauthScopes;
private $formatsProvider;
private bool $swaggerUiEnabled;
private bool $reDocEnabled;
private bool $graphqlEnabled;
private bool $graphiQlEnabled;
private bool $graphQlPlaygroundEnabled;
private array $swaggerVersions;
/**
* @param int[] $swaggerVersions
*/
public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, NormalizerInterface $normalizer, TwigEnvironment $twig, UrlGeneratorInterface $urlGenerator, string $title = '', string $description = '', string $version = '', $formats = [], $oauthEnabled = false, $oauthClientId = '', $oauthClientSecret = '', $oauthType = '', $oauthFlow = '', $oauthTokenUrl = '', $oauthAuthorizationUrl = '', $oauthScopes = [], bool $showWebby = true, bool $swaggerUiEnabled = false, bool $reDocEnabled = false, bool $graphqlEnabled = false, bool $graphiQlEnabled = false, bool $graphQlPlaygroundEnabled = false, array $swaggerVersions = [2, 3])
{
$this->resourceNameCollectionFactory = $resourceNameCollectionFactory;
$this->resourceMetadataFactory = $resourceMetadataFactory;
$this->normalizer = $normalizer;
$this->twig = $twig;
$this->urlGenerator = $urlGenerator;
$this->title = $title;
$this->showWebby = $showWebby;
$this->description = $description;
$this->version = $version;
$this->oauthEnabled = $oauthEnabled;
$this->oauthClientId = $oauthClientId;
$this->oauthClientSecret = $oauthClientSecret;
$this->oauthType = $oauthType;
$this->oauthFlow = $oauthFlow;
$this->oauthTokenUrl = $oauthTokenUrl;
$this->oauthAuthorizationUrl = $oauthAuthorizationUrl;
$this->oauthScopes = $oauthScopes;
$this->swaggerUiEnabled = $swaggerUiEnabled;
$this->reDocEnabled = $reDocEnabled;
$this->graphqlEnabled = $graphqlEnabled;
$this->graphiQlEnabled = $graphiQlEnabled;
$this->graphQlPlaygroundEnabled = $graphQlPlaygroundEnabled;
$this->swaggerVersions = $swaggerVersions;
public function __construct(
private ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory,
private ResourceMetadataFactoryInterface $resourceMetadataFactory,
private NormalizerInterface $normalizer,
private TwigEnvironment $twig,
private UrlGeneratorInterface $urlGenerator,
private string $title = '',
private string $description = '',
private string $version = '',
$formats = [],
private $oauthEnabled = false,
private $oauthClientId = '',
private $oauthClientSecret = '',
private $oauthType = '',
private $oauthFlow = '',
private $oauthTokenUrl = '',
private $oauthAuthorizationUrl = '',
private $oauthScopes = [],
private bool $showWebby = true,
private bool $swaggerUiEnabled = false,
private bool $reDocEnabled = false,
private bool $graphqlEnabled = false,
private bool $graphiQlEnabled = false,
private bool $graphQlPlaygroundEnabled = false,
private array $swaggerVersions = [2, 3]
) {
if (\is_array($formats)) {
$this->formats = $formats;
return;
}
@trigger_error(sprintf('Passing an array or an instance of "%s" as 5th parameter of the constructor of "%s" is deprecated since API Platform 2.5, pass an array instead', FormatsProviderInterface::class, __CLASS__), \E_USER_DEPRECATED);
@trigger_error(sprintf(
'Passing an array or an instance of "%s" as 5th parameter of the constructor of "%s" is deprecated since API Platform 2.5, pass an array instead',
FormatsProviderInterface::class,
__CLASS__
), \E_USER_DEPRECATED);
$this->formatsProvider = $formats;
}

View file

@ -27,18 +27,12 @@ final class CachedRouteNameResolver implements RouteNameResolverInterface
{
use CachedTrait;
private RouteNameResolverInterface $decorated;
private PathPrefixProviderInterface $pathPrefixProvider;
public function __construct(
CacheItemPoolInterface $cacheItemPool,
RouteNameResolverInterface $decorated,
PathPrefixProviderInterface $pathPrefixProvider
private RouteNameResolverInterface $decorated,
private PathPrefixProviderInterface $pathPrefixProvider
) {
$this->cacheItemPool = $cacheItemPool;
$this->decorated = $decorated;
$this->pathPrefixProvider = $pathPrefixProvider;
}
public function getRouteName(string $resourceClass, $operationType /*, array $context = []*/): string

View file

@ -26,14 +26,10 @@ use Symfony\Component\Routing\RouterInterface;
*/
final class RouteNameResolver implements RouteNameResolverInterface
{
private RouterInterface $router;
private PathPrefixProviderInterface $pathPrefixProvider;
public function __construct(RouterInterface $router, PathPrefixProviderInterface $pathPrefixProvider)
{
$this->router = $router;
$this->pathPrefixProvider = $pathPrefixProvider;
public function __construct(
private RouterInterface $router,
private PathPrefixProviderInterface $pathPrefixProvider
) {
}
public function getRouteName(string $resourceClass, $operationType /*, array $context = [] */): string

View file

@ -25,15 +25,6 @@ use Sylius\Bundle\ApiBundle\ApiPlatform\ResourceMetadataPropertyValueResolver;
*/
final class MergingExtractorResourceMetadataFactory implements ResourceMetadataFactoryInterface
{
/** @var ExtractorInterface */
private $extractor;
/** @var ResourceMetadataFactoryInterface */
private $decorated;
/** @var ResourceMetadataPropertyValueResolver */
private $resourceMetadataPropertyValueResolver;
/** @var array */
private $defaults;
@ -41,19 +32,16 @@ final class MergingExtractorResourceMetadataFactory implements ResourceMetadataF
private const RESOURCES = ['shortName', 'description', 'iri', 'itemOperations', 'collectionOperations', 'subresourceOperations', 'graphql', 'attributes'];
public function __construct(
ExtractorInterface $extractor,
ResourceMetadataFactoryInterface $decorated,
ResourceMetadataPropertyValueResolver $resourceMetadataPropertyValueResolver,
private ExtractorInterface $extractor,
private ResourceMetadataFactoryInterface $decorated,
private ResourceMetadataPropertyValueResolver $resourceMetadataPropertyValueResolver,
array $defaults = []
) {
$this->extractor = $extractor;
$this->decorated = $decorated;
$this->resourceMetadataPropertyValueResolver = $resourceMetadataPropertyValueResolver;
$this->defaults = $defaults + ['attributes' => []];
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function create(string $resourceClass): ResourceMetadata
{
@ -61,7 +49,7 @@ final class MergingExtractorResourceMetadataFactory implements ResourceMetadataF
if ($this->decorated) {
try {
$parentResourceMetadata = $this->decorated->create($resourceClass);
} catch (ResourceClassNotFoundException $resourceNotFoundException) {
} catch (ResourceClassNotFoundException) {
// Ignore not found exception from decorated factories
}
}

View file

@ -18,12 +18,8 @@ use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;
/** @experimental */
final class ResourceMetadataPropertyValueResolver implements ResourceMetadataPropertyValueResolverInteface
{
/** @var ApiResourceConfigurationMergerInterface */
private $apiResourceConfigurationMerger;
public function __construct(ApiResourceConfigurationMergerInterface $apiResourceConfigurationMerger)
public function __construct(private ApiResourceConfigurationMergerInterface $apiResourceConfigurationMerger)
{
$this->apiResourceConfigurationMerger = $apiResourceConfigurationMerger;
}
/**

View file

@ -20,11 +20,8 @@ use Sylius\Component\Order\OrderTransitions;
/** @experimental */
final class OrderStateMachineTransitionApplicator implements OrderStateMachineTransitionApplicatorInterface
{
private StateMachineFactoryInterface $stateMachineFactory;
public function __construct(StateMachineFactoryInterface $stateMachineFactory)
public function __construct(private StateMachineFactoryInterface $stateMachineFactory)
{
$this->stateMachineFactory = $stateMachineFactory;
}
public function cancel(OrderInterface $data): OrderInterface

View file

@ -20,11 +20,8 @@ use Sylius\Component\Payment\PaymentTransitions;
/** @experimental */
final class PaymentStateMachineTransitionApplicator implements PaymentStateMachineTransitionApplicatorInterface
{
private StateMachineFactoryInterface $stateMachineFactory;
public function __construct(StateMachineFactoryInterface $stateMachineFactory)
public function __construct(private StateMachineFactoryInterface $stateMachineFactory)
{
$this->stateMachineFactory = $stateMachineFactory;
}
public function complete(PaymentInterface $data): PaymentInterface

View file

@ -20,11 +20,8 @@ use Sylius\Component\Review\Model\ReviewInterface;
/** @experimental */
final class ProductReviewStateMachineTransitionApplicator implements ProductReviewStateMachineTransitionApplicatorInterface
{
private StateMachineFactoryInterface $stateMachineFactory;
public function __construct(StateMachineFactoryInterface $stateMachineFactory)
public function __construct(private StateMachineFactoryInterface $stateMachineFactory)
{
$this->stateMachineFactory = $stateMachineFactory;
}
public function accept(ReviewInterface $data): ReviewInterface

View file

@ -21,16 +21,10 @@ use Webmozart\Assert\Assert;
final class OrderPromoCodeAssigner implements OrderPromoCodeAssignerInterface
{
private PromotionCouponRepositoryInterface $promotionCouponRepository;
private OrderProcessorInterface $orderProcessor;
public function __construct(
PromotionCouponRepositoryInterface $promotionCouponRepository,
OrderProcessorInterface $orderProcessor
private PromotionCouponRepositoryInterface $promotionCouponRepository,
private OrderProcessorInterface $orderProcessor
) {
$this->promotionCouponRepository = $promotionCouponRepository;
$this->orderProcessor = $orderProcessor;
}
public function assign(OrderInterface $cart, ?string $couponCode = null): OrderInterface

View file

@ -26,11 +26,8 @@ use Behat\Testwork\Tester\Setup\Teardown;
/** @experimental */
final class ApiScenarioEventDispatchingScenarioTester implements ScenarioTester
{
private ScenarioTester $baseTester;
public function __construct(ScenarioTester $baseTester)
public function __construct(private ScenarioTester $baseTester)
{
$this->baseTester = $baseTester;
}
public function setUp(Environment $env, FeatureNode $feature, Scenario $scenario, $skip): Setup
@ -39,7 +36,7 @@ final class ApiScenarioEventDispatchingScenarioTester implements ScenarioTester
if ($env->getSuite()->getSetting('javascript')) {
return $this->baseTester->setUp($env, $feature, $scenario, $skip);
}
} catch (ParameterNotFoundException $exception) {
} catch (ParameterNotFoundException) {
return $this->baseTester->setUp($env, $feature, $scenario, $skip);
}

View file

@ -23,16 +23,10 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class PaymentMethodChanger implements PaymentMethodChangerInterface
{
private PaymentRepositoryInterface $paymentRepository;
private PaymentMethodRepositoryInterface $paymentMethodRepository;
public function __construct(
PaymentRepositoryInterface $paymentRepository,
PaymentMethodRepositoryInterface $paymentMethodRepository
private PaymentRepositoryInterface $paymentRepository,
private PaymentMethodRepositoryInterface $paymentMethodRepository
) {
$this->paymentRepository = $paymentRepository;
$this->paymentMethodRepository = $paymentMethodRepository;
}
public function changePaymentMethod(

View file

@ -21,18 +21,10 @@ use Sylius\Component\Promotion\Checker\Eligibility\PromotionEligibilityCheckerIn
final class AppliedCouponEligibilityChecker implements AppliedCouponEligibilityCheckerInterface
{
/** @var PromotionEligibilityCheckerInterface */
private $promotionChecker;
/** @var PromotionCouponEligibilityCheckerInterface */
private $promotionCouponChecker;
public function __construct(
PromotionEligibilityCheckerInterface $promotionChecker,
PromotionCouponEligibilityCheckerInterface $promotionCouponChecker
private PromotionEligibilityCheckerInterface $promotionChecker,
private PromotionCouponEligibilityCheckerInterface $promotionCouponChecker
) {
$this->promotionChecker = $promotionChecker;
$this->promotionCouponChecker = $promotionCouponChecker;
}
public function isEligible(?PromotionCouponInterface $promotionCoupon, OrderInterface $cart): bool

View file

@ -23,16 +23,10 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class ChangePaymentMethodHandler implements MessageHandlerInterface
{
private PaymentMethodChangerInterface $paymentMethodChanger;
private OrderRepositoryInterface $orderRepository;
public function __construct(
PaymentMethodChangerInterface $commandPaymentMethodChanger,
OrderRepositoryInterface $orderRepository
private PaymentMethodChangerInterface $paymentMethodChanger,
private OrderRepositoryInterface $orderRepository
) {
$this->paymentMethodChanger = $commandPaymentMethodChanger;
$this->orderRepository = $orderRepository;
}
public function __invoke(ChangePaymentMethod $changePaymentMethod): OrderInterface

View file

@ -23,14 +23,10 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class ChangeShopUserPasswordHandler implements MessageHandlerInterface
{
private PasswordUpdaterInterface $passwordUpdater;
private UserRepositoryInterface $userRepository;
public function __construct(PasswordUpdaterInterface $passwordUpdater, UserRepositoryInterface $userRepository)
{
$this->passwordUpdater = $passwordUpdater;
$this->userRepository = $userRepository;
public function __construct(
private PasswordUpdaterInterface $passwordUpdater,
private UserRepositoryInterface $userRepository
) {
}
public function __invoke(ChangeShopUserPassword $changeShopUserPassword): void

View file

@ -14,9 +14,9 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\CommandHandler\Account;
use Doctrine\Persistence\ObjectManager;
use Sylius\Bundle\ApiBundle\Command\Account\RegisterShopUser;
use Sylius\Bundle\ApiBundle\Command\Account\SendAccountRegistrationEmail;
use Sylius\Bundle\ApiBundle\Command\Account\SendAccountVerificationEmail;
use Sylius\Bundle\ApiBundle\Command\Account\RegisterShopUser;
use Sylius\Bundle\ApiBundle\Provider\CustomerProviderInterface;
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Sylius\Component\Core\Model\ChannelInterface;
@ -30,32 +30,14 @@ use Symfony\Component\Messenger\Stamp\DispatchAfterCurrentBusStamp;
/** @experimental */
final class RegisterShopUserHandler implements MessageHandlerInterface
{
private FactoryInterface $shopUserFactory;
private ObjectManager $shopUserManager;
private CustomerProviderInterface $customerProvider;
private ChannelRepositoryInterface $channelRepository;
private GeneratorInterface $tokenGenerator;
private MessageBusInterface $commandBus;
public function __construct(
FactoryInterface $shopUserFactory,
ObjectManager $shopUserManager,
CustomerProviderInterface $customerProvider,
ChannelRepositoryInterface $channelRepository,
GeneratorInterface $tokenGenerator,
MessageBusInterface $commandBus
private FactoryInterface $shopUserFactory,
private ObjectManager $shopUserManager,
private CustomerProviderInterface $customerProvider,
private ChannelRepositoryInterface $channelRepository,
private GeneratorInterface $tokenGenerator,
private MessageBusInterface $commandBus
) {
$this->shopUserFactory = $shopUserFactory;
$this->shopUserManager = $shopUserManager;
$this->customerProvider = $customerProvider;
$this->channelRepository = $channelRepository;
$this->tokenGenerator = $tokenGenerator;
$this->commandBus = $commandBus;
}
public function __invoke(RegisterShopUser $command): ShopUserInterface

View file

@ -25,20 +25,11 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class RequestResetPasswordTokenHandler implements MessageHandlerInterface
{
private UserRepositoryInterface $userRepository;
private MessageBusInterface $commandBus;
private GeneratorInterface $generator;
public function __construct(
UserRepositoryInterface $userRepository,
MessageBusInterface $eventBus,
GeneratorInterface $generator
private UserRepositoryInterface $userRepository,
private MessageBusInterface $commandBus,
private GeneratorInterface $generator
) {
$this->userRepository = $userRepository;
$this->commandBus = $eventBus;
$this->generator = $generator;
}
public function __invoke(RequestResetPasswordToken $command): void

View file

@ -17,7 +17,6 @@ use Sylius\Bundle\ApiBundle\Command\Account\ResendVerificationEmail;
use Sylius\Bundle\ApiBundle\Command\Account\SendAccountVerificationEmail;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Core\Model\ShopUserInterface;
use Sylius\Component\User\Model\UserInterface;
use Sylius\Component\User\Repository\UserRepositoryInterface;
use Sylius\Component\User\Security\Generator\GeneratorInterface;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
@ -28,20 +27,11 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class ResendVerificationEmailHandler implements MessageHandlerInterface
{
private UserRepositoryInterface $shopUserRepository;
private GeneratorInterface $tokenGenerator;
private MessageBusInterface $commandBus;
public function __construct(
UserRepositoryInterface $shopUserRepository,
GeneratorInterface $tokenGenerator,
MessageBusInterface $commandBus
private UserRepositoryInterface $shopUserRepository,
private GeneratorInterface $tokenGenerator,
private MessageBusInterface $commandBus
) {
$this->shopUserRepository = $shopUserRepository;
$this->tokenGenerator = $tokenGenerator;
$this->commandBus = $commandBus;
}
public function __invoke(ResendVerificationEmail $command): void

View file

@ -24,20 +24,11 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class ResetPasswordHandler implements MessageHandlerInterface
{
private UserRepositoryInterface $userRepository;
private MetadataInterface $metadata;
private PasswordUpdaterInterface $passwordUpdater;
public function __construct(
UserRepositoryInterface $userRepository,
MetadataInterface $metadata,
PasswordUpdaterInterface $passwordUpdater
private UserRepositoryInterface $userRepository,
private MetadataInterface $metadata,
private PasswordUpdaterInterface $passwordUpdater
) {
$this->userRepository = $userRepository;
$this->metadata = $metadata;
$this->passwordUpdater = $passwordUpdater;
}
public function __invoke(ResetPassword $command): void

View file

@ -24,20 +24,11 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
/** @experimental */
final class SendAccountRegistrationEmailHandler implements MessageHandlerInterface
{
private UserRepositoryInterface $shopUserRepository;
private ChannelRepositoryInterface $channelRepository;
private SenderInterface $emailSender;
public function __construct(
UserRepositoryInterface $shopUserRepository,
ChannelRepositoryInterface $channelRepository,
SenderInterface $emailSender
private UserRepositoryInterface $shopUserRepository,
private ChannelRepositoryInterface $channelRepository,
private SenderInterface $emailSender
) {
$this->shopUserRepository = $shopUserRepository;
$this->channelRepository = $channelRepository;
$this->emailSender = $emailSender;
}
public function __invoke(SendAccountRegistrationEmail $command): void

View file

@ -24,20 +24,11 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
/** @experimental */
final class SendAccountVerificationEmailHandler implements MessageHandlerInterface
{
private UserRepositoryInterface $shopUserRepository;
private ChannelRepositoryInterface $channelRepository;
private SenderInterface $emailSender;
public function __construct(
UserRepositoryInterface $shopUserRepository,
ChannelRepositoryInterface $channelRepository,
SenderInterface $emailSender
private UserRepositoryInterface $shopUserRepository,
private ChannelRepositoryInterface $channelRepository,
private SenderInterface $emailSender
) {
$this->shopUserRepository = $shopUserRepository;
$this->channelRepository = $channelRepository;
$this->emailSender = $emailSender;
}
public function __invoke(SendAccountVerificationEmail $command): void

View file

@ -23,20 +23,11 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
/** @experimental */
final class SendResetPasswordEmailHandler implements MessageHandlerInterface
{
private SenderInterface $emailSender;
private ChannelRepositoryInterface $channelRepository;
private UserRepositoryInterface $userRepository;
public function __construct(
SenderInterface $emailSender,
ChannelRepositoryInterface $channelRepository,
UserRepositoryInterface $userRepository
private SenderInterface $emailSender,
private ChannelRepositoryInterface $channelRepository,
private UserRepositoryInterface $userRepository
) {
$this->emailSender = $emailSender;
$this->channelRepository = $channelRepository;
$this->userRepository = $userRepository;
}
public function __invoke(SendResetPasswordEmail $command)

View file

@ -23,11 +23,9 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
/** @experimental */
final class VerifyCustomerAccountHandler implements MessageHandlerInterface
{
private RepositoryInterface $shopUserRepository;
public function __construct(RepositoryInterface $shopUserRepository)
{
$this->shopUserRepository = $shopUserRepository;
public function __construct(
private RepositoryInterface $shopUserRepository
) {
}
public function __invoke(VerifyCustomerAccount $command): JsonResponse

View file

@ -28,28 +28,13 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class AddItemToCartHandler implements MessageHandlerInterface
{
private OrderRepositoryInterface $orderRepository;
private ProductVariantRepositoryInterface $productVariantRepository;
private OrderModifierInterface $orderModifier;
private CartItemFactoryInterface $cartItemFactory;
private OrderItemQuantityModifierInterface $orderItemQuantityModifier;
public function __construct(
OrderRepositoryInterface $orderRepository,
ProductVariantRepositoryInterface $productVariantRepository,
OrderModifierInterface $orderModifier,
CartItemFactoryInterface $cartItemFactory,
OrderItemQuantityModifierInterface $orderItemQuantityModifier
private OrderRepositoryInterface $orderRepository,
private ProductVariantRepositoryInterface $productVariantRepository,
private OrderModifierInterface $orderModifier,
private CartItemFactoryInterface $cartItemFactory,
private OrderItemQuantityModifierInterface $orderItemQuantityModifier
) {
$this->orderRepository = $orderRepository;
$this->productVariantRepository = $productVariantRepository;
$this->orderModifier = $orderModifier;
$this->cartItemFactory = $cartItemFactory;
$this->orderItemQuantityModifier = $orderItemQuantityModifier;
}
public function __invoke(AddItemToCart $addItemToCart): OrderInterface

View file

@ -23,20 +23,11 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
final class BlameCartHandler implements MessageHandlerInterface
{
private UserRepositoryInterface $shopUserRepository;
private OrderRepositoryInterface $orderRepository;
private OrderProcessorInterface $orderProcessor;
public function __construct(
UserRepositoryInterface $shopUserRepository,
OrderRepositoryInterface $orderRepository,
OrderProcessorInterface $orderProcessor
private UserRepositoryInterface $shopUserRepository,
private OrderRepositoryInterface $orderRepository,
private OrderProcessorInterface $orderProcessor
) {
$this->shopUserRepository = $shopUserRepository;
$this->orderRepository = $orderRepository;
$this->orderProcessor = $orderProcessor;
}
public function __invoke(BlameCart $blameCart): void

View file

@ -25,20 +25,11 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class ChangeItemQuantityInCartHandler implements MessageHandlerInterface
{
private OrderItemRepositoryInterface $orderItemRepository;
private OrderItemQuantityModifierInterface $orderItemQuantityModifier;
private OrderProcessorInterface $orderProcessor;
public function __construct(
OrderItemRepositoryInterface $orderItemRepository,
OrderItemQuantityModifierInterface $orderItemQuantityModifier,
OrderProcessorInterface $orderProcessor
private OrderItemRepositoryInterface $orderItemRepository,
private OrderItemQuantityModifierInterface $orderItemQuantityModifier,
private OrderProcessorInterface $orderProcessor
) {
$this->orderItemRepository = $orderItemRepository;
$this->orderItemQuantityModifier = $orderItemQuantityModifier;
$this->orderProcessor = $orderProcessor;
}
public function __invoke(ChangeItemQuantityInCart $command): OrderInterface

View file

@ -30,33 +30,14 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
/** @experimental */
final class PickupCartHandler implements MessageHandlerInterface
{
private FactoryInterface $cartFactory;
private OrderRepositoryInterface $cartRepository;
private ChannelRepositoryInterface $channelRepository;
private ObjectManager $orderManager;
private RandomnessGeneratorInterface $generator;
/** @var CustomerRepositoryInterface */
private $customerRepository;
public function __construct(
FactoryInterface $cartFactory,
OrderRepositoryInterface $cartRepository,
ChannelRepositoryInterface $channelRepository,
ObjectManager $orderManager,
RandomnessGeneratorInterface $generator,
CustomerRepositoryInterface $customerRepository
private FactoryInterface $cartFactory,
private OrderRepositoryInterface $cartRepository,
private ChannelRepositoryInterface $channelRepository,
private ObjectManager $orderManager,
private RandomnessGeneratorInterface $generator,
private CustomerRepositoryInterface $customerRepository
) {
$this->cartFactory = $cartFactory;
$this->cartRepository = $cartRepository;
$this->channelRepository = $channelRepository;
$this->orderManager = $orderManager;
$this->generator = $generator;
$this->customerRepository = $customerRepository;
}
public function __invoke(PickupCart $pickupCart)

View file

@ -24,16 +24,10 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class RemoveItemFromCartHandler implements MessageHandlerInterface
{
private OrderItemRepositoryInterface $orderItemRepository;
private OrderModifierInterface $orderModifier;
public function __construct(
OrderItemRepositoryInterface $orderItemRepository,
OrderModifierInterface $orderModifier
private OrderItemRepositoryInterface $orderItemRepository,
private OrderModifierInterface $orderModifier
) {
$this->orderItemRepository = $orderItemRepository;
$this->orderModifier = $orderModifier;
}
public function __invoke(RemoveItemFromCart $removeItemFromCart): OrderInterface

View file

@ -26,24 +26,12 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
/** @experimental */
final class AddProductReviewHandler implements MessageHandlerInterface
{
private FactoryInterface $productReviewFactory;
private RepositoryInterface $productReviewRepository;
private ProductRepositoryInterface $productRepository;
private CustomerProviderInterface $customerProvider;
public function __construct(
FactoryInterface $productReviewFactory,
RepositoryInterface $productReviewRepository,
ProductRepositoryInterface $productRepository,
CustomerProviderInterface $customerProvider
private FactoryInterface $productReviewFactory,
private RepositoryInterface $productReviewRepository,
private ProductRepositoryInterface $productRepository,
private CustomerProviderInterface $customerProvider
) {
$this->productReviewFactory = $productReviewFactory;
$this->productReviewRepository = $productReviewRepository;
$this->productRepository = $productRepository;
$this->customerProvider = $customerProvider;
}
public function __invoke(AddProductReview $addProductReview): ReviewInterface

View file

@ -28,28 +28,13 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class ChoosePaymentMethodHandler implements MessageHandlerInterface
{
private OrderRepositoryInterface $orderRepository;
private PaymentMethodRepositoryInterface $paymentMethodRepository;
private PaymentRepositoryInterface $paymentRepository;
private FactoryInterface $stateMachineFactory;
private PaymentMethodChangerInterface $paymentMethodChanger;
public function __construct(
OrderRepositoryInterface $orderRepository,
PaymentMethodRepositoryInterface $paymentMethodRepository,
PaymentRepositoryInterface $paymentRepository,
FactoryInterface $stateMachineFactory,
PaymentMethodChangerInterface $paymentMethodChanger
private OrderRepositoryInterface $orderRepository,
private PaymentMethodRepositoryInterface $paymentMethodRepository,
private PaymentRepositoryInterface $paymentRepository,
private FactoryInterface $stateMachineFactory,
private PaymentMethodChangerInterface $paymentMethodChanger
) {
$this->orderRepository = $orderRepository;
$this->paymentMethodRepository = $paymentMethodRepository;
$this->paymentRepository = $paymentRepository;
$this->stateMachineFactory = $stateMachineFactory;
$this->paymentMethodChanger = $paymentMethodChanger;
}
public function __invoke(ChoosePaymentMethod $choosePaymentMethod): OrderInterface

View file

@ -28,28 +28,13 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class ChooseShippingMethodHandler implements MessageHandlerInterface
{
private OrderRepositoryInterface $orderRepository;
private ShippingMethodRepositoryInterface $shippingMethodRepository;
private ShipmentRepositoryInterface $shipmentRepository;
private ShippingMethodEligibilityCheckerInterface $eligibilityChecker;
private FactoryInterface $stateMachineFactory;
public function __construct(
OrderRepositoryInterface $orderRepository,
ShippingMethodRepositoryInterface $shippingMethodRepository,
ShipmentRepositoryInterface $shipmentRepository,
ShippingMethodEligibilityCheckerInterface $eligibilityChecker,
FactoryInterface $stateMachineFactory
private OrderRepositoryInterface $orderRepository,
private ShippingMethodRepositoryInterface $shippingMethodRepository,
private ShipmentRepositoryInterface $shipmentRepository,
private ShippingMethodEligibilityCheckerInterface $eligibilityChecker,
private FactoryInterface $stateMachineFactory
) {
$this->orderRepository = $orderRepository;
$this->shippingMethodRepository = $shippingMethodRepository;
$this->shipmentRepository = $shipmentRepository;
$this->eligibilityChecker = $eligibilityChecker;
$this->stateMachineFactory = $stateMachineFactory;
}
public function __invoke(ChooseShippingMethod $chooseShippingMethod): OrderInterface

View file

@ -27,20 +27,11 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class CompleteOrderHandler implements MessageHandlerInterface
{
private OrderRepositoryInterface $orderRepository;
private FactoryInterface $stateMachineFactory;
private MessageBusInterface $eventBus;
public function __construct(
OrderRepositoryInterface $orderRepository,
FactoryInterface $stateMachineFactory,
MessageBusInterface $eventBus
private OrderRepositoryInterface $orderRepository,
private FactoryInterface $stateMachineFactory,
private MessageBusInterface $eventBus
) {
$this->orderRepository = $orderRepository;
$this->stateMachineFactory = $stateMachineFactory;
$this->eventBus = $eventBus;
}
public function __invoke(CompleteOrder $completeOrder): OrderInterface

View file

@ -23,14 +23,10 @@ use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
/** @experimental */
final class SendOrderConfirmationHandler implements MessageHandlerInterface
{
private SenderInterface $emailSender;
private OrderRepositoryInterface $orderRepository;
public function __construct(SenderInterface $emailSender, OrderRepositoryInterface $orderRepository)
{
$this->emailSender = $emailSender;
$this->orderRepository = $orderRepository;
public function __construct(
private SenderInterface $emailSender,
private OrderRepositoryInterface $orderRepository
) {
}
public function __invoke(SendOrderConfirmation $sendOrderConfirmation): void

View file

@ -24,14 +24,10 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class SendShipmentConfirmationEmailHandler implements MessageHandlerInterface
{
private SenderInterface $emailSender;
private ShipmentRepositoryInterface $shipmentRepository;
public function __construct(SenderInterface $emailSender, ShipmentRepositoryInterface $shipmentRepository)
{
$this->emailSender = $emailSender;
$this->shipmentRepository = $shipmentRepository;
public function __construct(
private SenderInterface $emailSender,
private ShipmentRepositoryInterface $shipmentRepository
) {
}
public function __invoke(SendShipmentConfirmationEmail $sendShipmentConfirmationEmail): void

View file

@ -27,20 +27,11 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class ShipShipmentHandler implements MessageHandlerInterface
{
private ShipmentRepositoryInterface $shipmentRepository;
private FactoryInterface $stateMachineFactory;
private MessageBusInterface $eventBus;
public function __construct(
ShipmentRepositoryInterface $shipmentRepository,
FactoryInterface $stateMachineFactory,
MessageBusInterface $eventBus
private ShipmentRepositoryInterface $shipmentRepository,
private FactoryInterface $stateMachineFactory,
private MessageBusInterface $eventBus
) {
$this->shipmentRepository = $shipmentRepository;
$this->stateMachineFactory = $stateMachineFactory;
$this->eventBus = $eventBus;
}
public function __invoke(ShipShipment $shipShipment): ShipmentInterface

View file

@ -25,24 +25,12 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class UpdateCartHandler implements MessageHandlerInterface
{
private OrderRepositoryInterface $orderRepository;
private OrderAddressModifierInterface $orderAddressModifier;
private OrderPromoCodeAssignerInterface $orderPromoCodeAssigner;
private CustomerProviderInterface $customerProvider;
public function __construct(
OrderRepositoryInterface $orderRepository,
OrderAddressModifierInterface $orderAddressModifier,
OrderPromoCodeAssignerInterface $orderPromoCodeAssigner,
CustomerProviderInterface $customerProvider
private OrderRepositoryInterface $orderRepository,
private OrderAddressModifierInterface $orderAddressModifier,
private OrderPromoCodeAssignerInterface $orderPromoCodeAssigner,
private CustomerProviderInterface $customerProvider
) {
$this->orderRepository = $orderRepository;
$this->orderAddressModifier = $orderAddressModifier;
$this->orderPromoCodeAssigner = $orderPromoCodeAssigner;
$this->customerProvider = $customerProvider;
}
public function __invoke(UpdateCart $updateCart): OrderInterface
@ -57,7 +45,7 @@ final class UpdateCartHandler implements MessageHandlerInterface
$order->setCustomer($this->customerProvider->provide($updateCart->getEmail()));
}
if($updateCart->getBillingAddress()) {
if ($updateCart->getBillingAddress()) {
$order = $this->orderAddressModifier->modify(
$order,
$updateCart->getBillingAddress(),

View file

@ -19,11 +19,9 @@ use Symfony\Component\Security\Core\User\UserInterface;
/** @experimental */
final class TokenBasedUserContext implements UserContextInterface
{
private TokenStorageInterface $tokenStorage;
public function __construct(TokenStorageInterface $tokenStorage)
{
$this->tokenStorage = $tokenStorage;
public function __construct(
private TokenStorageInterface $tokenStorage
) {
}
public function getUser(): ?UserInterface

View file

@ -23,20 +23,11 @@ use Symfony\Component\HttpFoundation\RequestStack;
/** @experimental */
final class TokenValueBasedCartContext implements CartContextInterface
{
private RequestStack $requestStack;
private OrderRepositoryInterface $orderRepository;
private string $newApiRoute;
public function __construct(
RequestStack $requestStack,
OrderRepositoryInterface $orderRepository,
string $newApiRoute
private RequestStack $requestStack,
private OrderRepositoryInterface $orderRepository,
private string $newApiRoute
) {
$this->requestStack = $requestStack;
$this->orderRepository = $orderRepository;
$this->newApiRoute = $newApiRoute;
}
public function getCart(): OrderInterface
@ -73,7 +64,7 @@ final class TokenValueBasedCartContext implements CartContextInterface
private function checkApiRequest(Request $request): void
{
if (strpos($request->getRequestUri(), $this->newApiRoute) === false) {
if (!str_contains($request->getRequestUri(), $this->newApiRoute)) {
throw new CartNotFoundException('The main request is not an API request.');
}
}

View file

@ -21,11 +21,9 @@ use Symfony\Component\Messenger\MessageBusInterface;
final class DeleteOrderItemAction
{
private MessageBusInterface $commandBus;
public function __construct(MessageBusInterface $commandBus)
{
$this->commandBus = $commandBus;
public function __construct(
private MessageBusInterface $commandBus
) {
}
public function __invoke(Request $request): Response

View file

@ -24,24 +24,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
final class GetProductBySlugAction
{
private ChannelContextInterface $channelContext;
private LocaleContextInterface $localeContext;
private ProductRepositoryInterface $productRepository;
private IriConverterInterface $iriConverter;
private RequestStack $requestStack;
public function __construct(
ChannelContextInterface $channelContext,
LocaleContextInterface $localeContext,
ProductRepositoryInterface $productRepository,
IriConverterInterface $iriConverter,
RequestStack $requestStack
private ChannelContextInterface $channelContext,
private LocaleContextInterface $localeContext,
private ProductRepositoryInterface $productRepository,
private IriConverterInterface $iriConverter,
private RequestStack $requestStack
) {
$this->channelContext = $channelContext;
$this->localeContext = $localeContext;
$this->productRepository = $productRepository;
$this->iriConverter = $iriConverter;
$this->requestStack = $requestStack;
}
public function __invoke(string $slug): RedirectResponse

View file

@ -23,16 +23,10 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class GetPaymentConfiguration
{
private PaymentRepositoryInterface $paymentRepository;
private CompositePaymentConfigurationProviderInterface $compositePaymentConfigurationProvider;
public function __construct(
PaymentRepositoryInterface $paymentRepository,
CompositePaymentConfigurationProviderInterface $compositePaymentConfigurationProvider
private PaymentRepositoryInterface $paymentRepository,
private CompositePaymentConfigurationProviderInterface $compositePaymentConfigurationProvider
) {
$this->paymentRepository = $paymentRepository;
$this->compositePaymentConfigurationProvider = $compositePaymentConfigurationProvider;
}
public function __invoke(Request $request): JsonResponse

View file

@ -27,24 +27,12 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class UploadAvatarImageAction
{
private FactoryInterface $avatarImageFactory;
private AvatarImageRepositoryInterface $avatarImageRepository;
private ImageUploaderInterface $imageUploader;
private IriConverterInterface $iriConverter;
public function __construct(
FactoryInterface $avatarImageFactory,
AvatarImageRepositoryInterface $avatarImageRepository,
ImageUploaderInterface $imageUploader,
IriConverterInterface $iriConverter
private FactoryInterface $avatarImageFactory,
private AvatarImageRepositoryInterface $avatarImageRepository,
private ImageUploaderInterface $imageUploader,
private IriConverterInterface $iriConverter
) {
$this->avatarImageFactory = $avatarImageFactory;
$this->avatarImageRepository = $avatarImageRepository;
$this->imageUploader = $imageUploader;
$this->iriConverter = $iriConverter;
}
public function __invoke(Request $request): ImageInterface

View file

@ -31,11 +31,10 @@ final class IriToIdentifierConverter implements IriToIdentifierConverterInterfac
{
use OperationDataProviderTrait;
private RouterInterface $router;
public function __construct(RouterInterface $router, IdentifierConverterInterface $identifierConverter)
{
$this->router = $router;
public function __construct(
private RouterInterface $router,
IdentifierConverterInterface $identifierConverter
) {
$this->identifierConverter = $identifierConverter;
}
@ -82,7 +81,7 @@ final class IriToIdentifierConverter implements IriToIdentifierConverterInterfac
try {
$this->router->match($fieldValue);
} catch (RoutingExceptionInterface $e) {
} catch (RoutingExceptionInterface) {
return false;
}

View file

@ -23,16 +23,10 @@ use Sylius\Component\Core\Model\ShopUserInterface;
/** @experimental */
final class AddressDataPersister implements ContextAwareDataPersisterInterface
{
private ContextAwareDataPersisterInterface $decoratedDataPersister;
private UserContextInterface $userContext;
public function __construct(
ContextAwareDataPersisterInterface $decoratedDataPersister,
UserContextInterface $userContext
private ContextAwareDataPersisterInterface $decoratedDataPersister,
private UserContextInterface $userContext
) {
$this->decoratedDataPersister = $decoratedDataPersister;
$this->userContext = $userContext;
}
public function supports($data, array $context = []): bool

View file

@ -23,20 +23,11 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
/** @experimental */
final class AdminUserDataPersister implements ContextAwareDataPersisterInterface
{
private ContextAwareDataPersisterInterface $decoratedDataPersister;
private TokenStorageInterface $tokenStorage;
private PasswordUpdaterInterface $passwordUpdater;
public function __construct(
ContextAwareDataPersisterInterface $decoratedDataPersister,
TokenStorageInterface $tokenStorage,
PasswordUpdaterInterface $passwordUpdater
private ContextAwareDataPersisterInterface $decoratedDataPersister,
private TokenStorageInterface $tokenStorage,
private PasswordUpdaterInterface $passwordUpdater
) {
$this->decoratedDataPersister = $decoratedDataPersister;
$this->tokenStorage = $tokenStorage;
$this->passwordUpdater = $passwordUpdater;
}
public function supports($data, array $context = []): bool

View file

@ -21,11 +21,9 @@ use Sylius\Component\Core\Model\ShippingMethodInterface;
/** @experimental */
final class ShippingMethodDataPersister implements ContextAwareDataPersisterInterface
{
private ContextAwareDataPersisterInterface $decoratedDataPersister;
public function __construct(ContextAwareDataPersisterInterface $decoratedDataPersister)
{
$this->decoratedDataPersister = $decoratedDataPersister;
public function __construct(
private ContextAwareDataPersisterInterface $decoratedDataPersister
) {
}
public function supports($data, array $context = []): bool
@ -42,7 +40,7 @@ final class ShippingMethodDataPersister implements ContextAwareDataPersisterInte
{
try {
return $this->decoratedDataPersister->remove($data, $context);
} catch (ForeignKeyConstraintViolationException $constraintViolationException) {
} catch (ForeignKeyConstraintViolationException) {
throw new ShippingMethodCannotBeRemoved();
}
}

View file

@ -26,20 +26,11 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class CartPaymentMethodsSubresourceDataProvider implements RestrictedDataProviderInterface, SubresourceDataProviderInterface
{
private OrderRepositoryInterface $orderRepository;
private PaymentRepositoryInterface $paymentRepository;
private PaymentMethodsResolverInterface $paymentMethodsResolver;
public function __construct(
OrderRepositoryInterface $orderRepository,
PaymentRepositoryInterface $paymentRepository,
PaymentMethodsResolverInterface $paymentMethodsResolver
private OrderRepositoryInterface $orderRepository,
private PaymentRepositoryInterface $paymentRepository,
private PaymentMethodsResolverInterface $paymentMethodsResolver
) {
$this->orderRepository = $orderRepository;
$this->paymentRepository = $paymentRepository;
$this->paymentMethodsResolver = $paymentMethodsResolver;
}
public function supports(string $resourceClass, string $operationName = null, array $context = []): bool

View file

@ -26,20 +26,11 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class CartShippingMethodsSubresourceDataProvider implements RestrictedDataProviderInterface, SubresourceDataProviderInterface
{
private OrderRepositoryInterface $orderRepository;
private ShipmentRepositoryInterface $shipmentRepository;
private ShippingMethodsResolverInterface $shippingMethodsResolver;
public function __construct(
OrderRepositoryInterface $orderRepository,
ShipmentRepositoryInterface $shipmentRepository,
ShippingMethodsResolverInterface $shippingMethodsResolver
private OrderRepositoryInterface $orderRepository,
private ShipmentRepositoryInterface $shipmentRepository,
private ShippingMethodsResolverInterface $shippingMethodsResolver
) {
$this->orderRepository = $orderRepository;
$this->shipmentRepository = $shipmentRepository;
$this->shippingMethodsResolver = $shippingMethodsResolver;
}
public function getSubresource(string $resourceClass, array $identifiers, array $context, string $operationName = null)

View file

@ -21,14 +21,10 @@ use Sylius\Component\Channel\Context\ChannelNotFoundException;
/** @experimental */
final class ChannelAwareItemDataProvider implements ItemDataProviderInterface
{
private ItemDataProviderInterface $itemDataProvider;
private ChannelContextInterface $channelContext;
public function __construct(ItemDataProviderInterface $itemDataProvider, ChannelContextInterface $channelContext)
{
$this->itemDataProvider = $itemDataProvider;
$this->channelContext = $channelContext;
public function __construct(
private ItemDataProviderInterface $itemDataProvider,
private ChannelContextInterface $channelContext
) {
}
public function getItem(string $resourceClass, $id, string $operationName = null, array $context = []): ?object
@ -44,7 +40,7 @@ final class ChannelAwareItemDataProvider implements ItemDataProviderInterface
try {
$context[ContextKeys::CHANNEL] = $this->channelContext->getChannel();
} catch (ChannelNotFoundException $exception) {
} catch (ChannelNotFoundException) {
}
return $context;

View file

@ -24,14 +24,10 @@ use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
/** @experimental */
final class CustomerItemDataProvider implements RestrictedDataProviderInterface, ItemDataProviderInterface
{
private UserContextInterface $userContext;
private CustomerRepositoryInterface $customerRepository;
public function __construct(UserContextInterface $userContext, CustomerRepositoryInterface $customerRepository)
{
$this->userContext = $userContext;
$this->customerRepository = $customerRepository;
public function __construct(
private UserContextInterface $userContext,
private CustomerRepositoryInterface $customerRepository
) {
}
public function getItem(string $resourceClass, $id, string $operationName = null, array $context = [])

View file

@ -23,11 +23,9 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class OrderAdjustmentsSubresourceDataProvider implements RestrictedDataProviderInterface, SubresourceDataProviderInterface
{
private OrderRepositoryInterface $orderRepository;
public function __construct(OrderRepositoryInterface $orderRepository)
{
$this->orderRepository = $orderRepository;
public function __construct(
private OrderRepositoryInterface $orderRepository
) {
}
public function supports(string $resourceClass, string $operationName = null, array $context = []): bool

View file

@ -23,11 +23,9 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class OrderItemAdjustmentsSubresourceDataProvider implements RestrictedDataProviderInterface, SubresourceDataProviderInterface
{
private OrderItemRepositoryInterface $orderItemRepository;
public function __construct(OrderItemRepositoryInterface $orderItemRepository)
{
$this->orderItemRepository = $orderItemRepository;
public function __construct(
private OrderItemRepositoryInterface $orderItemRepository
) {
}
public function supports(string $resourceClass, string $operationName = null, array $context = []): bool

View file

@ -25,14 +25,10 @@ use Sylius\Component\Core\Repository\OrderItemRepositoryInterface;
/** @experimental */
final class OrderItemItemDataProvider implements ItemDataProviderInterface, RestrictedDataProviderInterface
{
private OrderItemRepositoryInterface $orderItemRepository;
private UserContextInterface $userContext;
public function __construct(OrderItemRepositoryInterface $orderItemRepository, UserContextInterface $userContext)
{
$this->orderItemRepository = $orderItemRepository;
$this->userContext = $userContext;
public function __construct(
private OrderItemRepositoryInterface $orderItemRepository,
private UserContextInterface $userContext
) {
}
public function supports(string $resourceClass, string $operationName = null, array $context = []): bool

View file

@ -25,16 +25,10 @@ use Sylius\Component\Core\Repository\OrderItemUnitRepositoryInterface;
/** @experimental */
final class OrderItemUnitItemDataProvider implements ItemDataProviderInterface, RestrictedDataProviderInterface
{
private OrderItemUnitRepositoryInterface $orderItemUnitRepository;
private UserContextInterface $userContext;
public function __construct(
OrderItemUnitRepositoryInterface $orderItemUnitRepository,
UserContextInterface $userContext
private OrderItemUnitRepositoryInterface $orderItemUnitRepository,
private UserContextInterface $userContext
) {
$this->orderItemUnitRepository = $orderItemUnitRepository;
$this->userContext = $userContext;
}
public function supports(string $resourceClass, string $operationName = null, array $context = []): bool

View file

@ -25,14 +25,10 @@ use Sylius\Component\Core\Repository\PaymentRepositoryInterface;
/** @experimental */
final class PaymentItemDataProvider implements ItemDataProviderInterface, RestrictedDataProviderInterface
{
private PaymentRepositoryInterface $paymentRepository;
private UserContextInterface $userContext;
public function __construct(PaymentRepositoryInterface $paymentRepository, UserContextInterface $userContext)
{
$this->paymentRepository = $paymentRepository;
$this->userContext = $userContext;
public function __construct(
private PaymentRepositoryInterface $paymentRepository,
private UserContextInterface $userContext
) {
}
public function supports(string $resourceClass, string $operationName = null, array $context = []): bool

View file

@ -26,14 +26,10 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class ProductItemDataProvider implements RestrictedDataProviderInterface, ItemDataProviderInterface
{
private ProductRepositoryInterface $productRepository;
private UserContextInterface $userContext;
public function __construct(ProductRepositoryInterface $productRepository, UserContextInterface $userContext)
{
$this->productRepository = $productRepository;
$this->userContext = $userContext;
public function __construct(
private ProductRepositoryInterface $productRepository,
private UserContextInterface $userContext
) {
}
public function getItem(string $resourceClass, $id, string $operationName = null, array $context = [])

View file

@ -25,14 +25,10 @@ use Sylius\Component\Core\Repository\ShipmentRepositoryInterface;
/** @experimental */
final class ShipmentItemDataProvider implements ItemDataProviderInterface, RestrictedDataProviderInterface
{
private ShipmentRepositoryInterface $shipmentRepository;
private UserContextInterface $userContext;
public function __construct(ShipmentRepositoryInterface $shipmentRepository, UserContextInterface $userContext)
{
$this->shipmentRepository = $shipmentRepository;
$this->userContext = $userContext;
public function __construct(
private ShipmentRepositoryInterface $shipmentRepository,
private UserContextInterface $userContext
) {
}
public function supports(string $resourceClass, string $operationName = null, array $context = []): bool

View file

@ -19,11 +19,9 @@ use Sylius\Component\Channel\Context\ChannelContextInterface;
/** @experimental */
final class ChannelCodeAwareInputCommandDataTransformer implements CommandDataTransformerInterface
{
private ChannelContextInterface $channelContext;
public function __construct(ChannelContextInterface $channelContext)
{
$this->channelContext = $channelContext;
public function __construct(
private ChannelContextInterface $channelContext
) {
}
public function transform($object, string $to, array $context = [])

View file

@ -19,11 +19,9 @@ use Sylius\Component\Locale\Context\LocaleContextInterface;
/** @experimental */
final class LocaleCodeAwareInputCommandDataTransformer implements CommandDataTransformerInterface
{
private LocaleContextInterface $localeContext;
public function __construct(LocaleContextInterface $localeContext)
{
$this->localeContext = $localeContext;
public function __construct(
private LocaleContextInterface $localeContext
) {
}
public function transform($object, string $to, array $context = [])

View file

@ -13,7 +13,6 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\DataTransformer;
use Sylius\Bundle\ApiBundle\Command\Catalog\AddProductReview;
use Sylius\Bundle\ApiBundle\Command\CustomerEmailAwareInterface;
use Sylius\Bundle\ApiBundle\Context\UserContextInterface;
use Sylius\Component\Core\Model\CustomerInterface;
@ -24,11 +23,9 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class LoggedInCustomerEmailAwareCommandDataTransformer implements CommandDataTransformerInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function transform($object, string $to, array $context = [])

View file

@ -21,11 +21,9 @@ use Sylius\Component\User\Model\UserInterface;
/** @experimental */
final class LoggedInShopUserIdAwareCommandDataTransformer implements CommandDataTransformerInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
/**

View file

@ -20,11 +20,9 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class SubresourceIdAwareCommandDataTransformer implements CommandDataTransformerInterface
{
private RequestStack $requestStack;
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
public function __construct(
private RequestStack $requestStack
) {
}
public function transform($object, string $to, array $context = [])

View file

@ -37,7 +37,7 @@ final class ReflectionExtractorHotfixPass implements CompilerPassInterface
try {
/** @psalm-suppress MissingDependency */
$container->findDefinition('property_info.reflection_extractor')->setClass(ReflectionExtractor::class);
} catch (ServiceNotFoundException $exception) {
} catch (ServiceNotFoundException) {
return;
}
}

View file

@ -21,11 +21,9 @@ use Sylius\Component\Review\Model\ReviewInterface;
/** @experimental */
final class AcceptedProductReviewsExtension implements ContextAwareQueryCollectionExtensionInterface
{
private string $productReviewClass;
public function __construct(string $productReviewClass)
{
$this->productReviewClass = $productReviewClass;
public function __construct(
private string $productReviewClass
) {
}
public function applyToCollection(

View file

@ -26,11 +26,9 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/** @experimental */
final class AddressesExtension implements ContextAwareQueryCollectionExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToCollection(

View file

@ -25,11 +25,9 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class CountryCollectionExtension implements ContextAwareQueryCollectionExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToCollection(
@ -56,7 +54,7 @@ final class CountryCollectionExtension implements ContextAwareQueryCollectionExt
if ($channel->getCountries()->count() > 0) {
$rootAlias = $queryBuilder->getRootAliases()[0];
$queryBuilder
->andWhere(sprintf('%s.id in (:%s)',$rootAlias, $countriesParameterName))
->andWhere(sprintf('%s.id in (:%s)', $rootAlias, $countriesParameterName))
->setParameter($countriesParameterName, $channel->getCountries())
;
}

View file

@ -25,11 +25,9 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class CurrencyCollectionExtension implements ContextAwareQueryCollectionExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToCollection(
@ -56,7 +54,7 @@ final class CurrencyCollectionExtension implements ContextAwareQueryCollectionEx
if ($channel->getCurrencies()->count() > 0) {
$rootAlias = $queryBuilder->getRootAliases()[0];
$queryBuilder
->andWhere(sprintf('%s.id in (:%s)',$rootAlias, $currenciesParameterName))
->andWhere(sprintf('%s.id in (:%s)', $rootAlias, $currenciesParameterName))
->setParameter($currenciesParameterName, $channel->getCurrencies());
}
}

View file

@ -20,11 +20,9 @@ use Doctrine\ORM\QueryBuilder;
/** @experimental */
final class HideArchivedShippingMethodExtension implements ContextAwareQueryCollectionExtensionInterface
{
private string $shippingMethodClass;
public function __construct(string $shippingMethodClass)
{
$this->shippingMethodClass = $shippingMethodClass;
public function __construct(
private string $shippingMethodClass
) {
}
public function applyToCollection(

View file

@ -25,11 +25,9 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class LocaleCollectionExtension implements ContextAwareQueryCollectionExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToCollection(

View file

@ -26,11 +26,9 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
/** @experimental */
final class OrdersByLoggedInUserExtension implements ContextAwareQueryCollectionExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToCollection(

View file

@ -24,11 +24,9 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class ProductsByChannelAndLocaleCodeExtension implements ContextAwareQueryCollectionExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToCollection(

View file

@ -22,11 +22,9 @@ use Sylius\Component\Core\Model\ProductInterface;
/** @experimental */
final class ProductsWithEnableFlagExtension implements ContextAwareQueryCollectionExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToCollection(

View file

@ -25,11 +25,9 @@ use Webmozart\Assert\Assert;
/** @experimental */
final class TaxonCollectionExtension implements ContextAwareQueryCollectionExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToCollection(
@ -58,9 +56,9 @@ final class TaxonCollectionExtension implements ContextAwareQueryCollectionExten
$queryBuilder
->addSelect('child')
->innerJoin(sprintf('%s.parent', $rootAlias), 'parent')
->leftJoin(sprintf('%s.children',$rootAlias), 'child')
->andWhere(sprintf('%s.enabled = :%s',$rootAlias, $enabledParameterName))
->andWhere(sprintf('parent.code = :%s',$parentCodeParameterName))
->leftJoin(sprintf('%s.children', $rootAlias), 'child')
->andWhere(sprintf('%s.enabled = :%s', $rootAlias, $enabledParameterName))
->andWhere(sprintf('parent.code = :%s', $parentCodeParameterName))
->addOrderBy(sprintf('%s.position', $rootAlias))
->setParameter($parentCodeParameterName, ($channelMenuTaxon !== null) ? $channelMenuTaxon->getCode() : 'category')
->setParameter($enabledParameterName, true);

View file

@ -28,11 +28,9 @@ use Symfony\Component\Security\Core\User\UserInterface;
/** @experimental */
final class AddressItemExtension implements QueryItemExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToItem(
@ -75,8 +73,8 @@ final class AddressItemExtension implements QueryItemExtensionInterface
$customerParameterName = $queryNameGenerator->generateParameterName('customer');
$queryBuilder
->innerJoin($rootAlias.'.customer', 'customer')
->andWhere(sprintf('customer = :%s',$customerParameterName))
->innerJoin($rootAlias . '.customer', 'customer')
->andWhere(sprintf('customer = :%s', $customerParameterName))
->setParameter($customerParameterName, $customer);
return;

View file

@ -28,11 +28,9 @@ use Symfony\Component\Security\Core\User\UserInterface;
/** @experimental */
final class OrderGetMethodItemExtension implements QueryItemExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToItem(

View file

@ -27,11 +27,9 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/** @experimental */
final class OrderMethodsItemExtension implements QueryItemExtensionInterface
{
private UserContextInterface $userContext;
public function __construct(UserContextInterface $userContext)
{
$this->userContext = $userContext;
public function __construct(
private UserContextInterface $userContext
) {
}
public function applyToItem(

View file

@ -15,12 +15,9 @@ namespace Sylius\Bundle\ApiBundle\Event;
class OrderCompleted
{
/** @var string */
public $orderToken;
public function __construct(string $orderToken)
{
$this->orderToken = $orderToken;
public function __construct(
public string $orderToken
) {
}
public function orderToken(): string

View file

@ -20,11 +20,9 @@ use Symfony\Component\Messenger\MessageBusInterface;
/** @experimental */
final class OrderCompletedHandler
{
private MessageBusInterface $commandBus;
public function __construct(MessageBusInterface $commandBus)
{
$this->commandBus = $commandBus;
public function __construct(
private MessageBusInterface $commandBus
) {
}
public function __invoke(OrderCompleted $orderCompleted): void

View file

@ -26,20 +26,11 @@ use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
final class ApiCartBlamerListener
{
private CartContextInterface $cartContext;
private SectionProviderInterface $uriBasedSectionContext;
private MessageBusInterface $commandBus;
public function __construct(
CartContextInterface $cartContext,
SectionProviderInterface $uriBasedSectionContext,
MessageBusInterface $commandBus
private CartContextInterface $cartContext,
private SectionProviderInterface $uriBasedSectionContext,
private MessageBusInterface $commandBus
) {
$this->cartContext = $cartContext;
$this->uriBasedSectionContext = $uriBasedSectionContext;
$this->commandBus = $commandBus;
}
public function onInteractiveLogin(InteractiveLoginEvent $interactiveLoginEvent): void
@ -68,7 +59,7 @@ final class ApiCartBlamerListener
{
try {
$cart = $this->cartContext->getCart();
} catch (CartNotFoundException $exception) {
} catch (CartNotFoundException) {
return null;
}

View file

@ -20,11 +20,9 @@ use Sylius\Component\Core\Model\ShopUserInterface;
final class AuthenticationSuccessListener
{
private IriConverterInterface $iriConverter;
public function __construct(IriConverterInterface $iriConverter)
{
$this->iriConverter = $iriConverter;
public function __construct(
private IriConverterInterface $iriConverter
) {
}
public function onAuthenticationSuccessResponse(AuthenticationSuccessEvent $event): void

View file

@ -23,11 +23,9 @@ use Symfony\Component\HttpKernel\KernelEvents;
final class CatalogPromotionEventSubscriber implements EventSubscriberInterface
{
private CatalogPromotionAnnouncerInterface $catalogPromotionAnnouncer;
public function __construct(CatalogPromotionAnnouncerInterface $catalogPromotionAnnouncer)
{
$this->catalogPromotionAnnouncer = $catalogPromotionAnnouncer;
public function __construct(
private CatalogPromotionAnnouncerInterface $catalogPromotionAnnouncer
) {
}
public static function getSubscribedEvents(): array

View file

@ -22,14 +22,10 @@ use Symfony\Component\HttpKernel\KernelEvents;
/** @experimental */
final class KernelRequestEventSubscriber implements EventSubscriberInterface
{
private bool $apiEnabled;
private string $apiRoute;
public function __construct(bool $apiEnabled, string $apiRoute)
{
$this->apiEnabled = $apiEnabled;
$this->apiRoute = $apiRoute;
public function __construct(
private bool $apiEnabled,
private string $apiRoute
) {
}
public static function getSubscribedEvents()
@ -43,7 +39,7 @@ final class KernelRequestEventSubscriber implements EventSubscriberInterface
{
$pathInfo = $event->getRequest()->getPathInfo();
if ($this->apiEnabled === false && strpos($pathInfo, $this->apiRoute) !== false) {
if ($this->apiEnabled === false && str_contains($pathInfo, $this->apiRoute)) {
throw new NotFoundHttpException('Route not found');
}
}

View file

@ -25,11 +25,9 @@ use Symfony\Component\HttpKernel\KernelEvents;
/** @experimental */
final class ProductSlugEventSubscriber implements EventSubscriberInterface
{
private SlugGeneratorInterface $slugGenerator;
public function __construct(SlugGeneratorInterface $slugGenerator)
{
$this->slugGenerator = $slugGenerator;
public function __construct(
private SlugGeneratorInterface $slugGenerator
) {
}
public static function getSubscribedEvents(): array

View file

@ -24,11 +24,9 @@ use Symfony\Component\Messenger\MessageBusInterface;
final class ProductVariantEventSubscriber implements EventSubscriberInterface
{
private MessageBusInterface $eventBus;
public function __construct(MessageBusInterface $eventBus)
{
$this->eventBus = $eventBus;
public function __construct(
private MessageBusInterface $eventBus
) {
}
public static function getSubscribedEvents(): array

View file

@ -78,7 +78,7 @@ final class ProductPriceOrderFilter extends AbstractContextAwareFilter
strtolower(OrderFilterInterface::DIRECTION_DESC),
],
],
]
],
];
}
}

View file

@ -25,10 +25,8 @@ use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
/** @experimental */
final class ProductVariantOptionValueFilter extends AbstractContextAwareFilter
{
private IriConverterInterface $iriConverter;
public function __construct(
IriConverterInterface $iriConverter,
private IriConverterInterface $iriConverter,
ManagerRegistry $managerRegistry,
?RequestStack $requestStack = null,
LoggerInterface $logger = null,
@ -36,8 +34,6 @@ final class ProductVariantOptionValueFilter extends AbstractContextAwareFilter
NameConverterInterface $nameConverter = null
) {
parent::__construct($managerRegistry, $requestStack, $logger, $properties, $nameConverter);
$this->iriConverter = $iriConverter;
}
protected function filterProperty(

View file

@ -22,13 +22,11 @@ use Sylius\Component\Taxonomy\Model\TaxonInterface;
final class TaxonFilter extends AbstractContextAwareFilter
{
private IriConverterInterface $iriConverter;
public function __construct(ManagerRegistry $managerRegistry, IriConverterInterface $iriConverter)
{
public function __construct(
ManagerRegistry $managerRegistry,
private IriConverterInterface $iriConverter
) {
parent::__construct($managerRegistry);
$this->iriConverter = $iriConverter;
}
public function filterProperty(

View file

@ -22,16 +22,10 @@ use Webmozart\Assert\Assert;
final class OrderAddressModifier implements OrderAddressModifierInterface
{
private StateMachineFactoryInterface $stateMachineFactory;
private AddressMapperInterface $addressMapper;
public function __construct(
StateMachineFactoryInterface $stateMachineFactory,
AddressMapperInterface $addressMapper
private StateMachineFactoryInterface $stateMachineFactory,
private AddressMapperInterface $addressMapper
) {
$this->stateMachineFactory = $stateMachineFactory;
$this->addressMapper = $addressMapper;
}
public function modify(OrderInterface $order, AddressInterface $billingAddress, ?AddressInterface $shippingAddress = null): OrderInterface

View file

@ -75,12 +75,8 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
private array $arrayMutatorPrefixes;
private bool $enableConstructorExtraction;
private int $methodReflectionFlags;
private int $magicMethodsFlags;
private int $propertyReflectionFlags;
private InflectorInterface $inflector;
@ -94,15 +90,20 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
* @param string[]|null $accessorPrefixes
* @param string[]|null $arrayMutatorPrefixes
*/
public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null, bool $enableConstructorExtraction = true, int $accessFlags = self::ALLOW_PUBLIC, InflectorInterface $inflector = null, int $magicMethodsFlags = self::ALLOW_MAGIC_GET | self::ALLOW_MAGIC_SET)
{
public function __construct(
array $mutatorPrefixes = null,
array $accessorPrefixes = null,
array $arrayMutatorPrefixes = null,
private bool $enableConstructorExtraction = true,
int $accessFlags = self::ALLOW_PUBLIC,
InflectorInterface $inflector = null,
private int $magicMethodsFlags = self::ALLOW_MAGIC_GET | self::ALLOW_MAGIC_SET
) {
$this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : self::$defaultMutatorPrefixes;
$this->accessorPrefixes = null !== $accessorPrefixes ? $accessorPrefixes : self::$defaultAccessorPrefixes;
$this->arrayMutatorPrefixes = null !== $arrayMutatorPrefixes ? $arrayMutatorPrefixes : self::$defaultArrayMutatorPrefixes;
$this->enableConstructorExtraction = $enableConstructorExtraction;
$this->methodReflectionFlags = $this->getMethodsFlags($accessFlags);
$this->propertyReflectionFlags = $this->getPropertyFlags($accessFlags);
$this->magicMethodsFlags = $magicMethodsFlags;
$this->inflector = $inflector ?? new EnglishInflector();
$this->arrayMutatorPrefixesFirst = array_merge($this->arrayMutatorPrefixes, array_diff($this->mutatorPrefixes, $this->arrayMutatorPrefixes));
@ -110,13 +111,13 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function getProperties(string $class, array $context = []): ?array
{
try {
$reflectionClass = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
return null;
}
@ -148,7 +149,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function getTypes(string $class, string $property, array $context = []): ?array
{
@ -178,7 +179,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
if (null !== $type) {
return $this->extractFromReflectionType($type, $reflectionProperty->getDeclaringClass());
}
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
// noop
}
}
@ -187,13 +188,13 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function getTypesFromConstructor(string $class, string $property): ?array
{
try {
$reflection = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
return null;
}
if (!$reflectionConstructor = $reflection->getConstructor()) {
@ -225,7 +226,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function isReadable(string $class, string $property, array $context = []): ?bool
{
@ -237,7 +238,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function isWritable(string $class, string $property, array $context = []): ?bool
{
@ -251,13 +252,13 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function isInitializable(string $class, string $property, array $context = []): ?bool
{
try {
$reflectionClass = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
return null;
}
@ -279,13 +280,13 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function getReadInfo(string $class, string $property, array $context = []): ?PropertyReadInfo
{
try {
$reflClass = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
return null;
}
@ -338,13 +339,13 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
}
/**
* {@inheritdoc}
* @inheritdoc
*/
public function getWriteInfo(string $class, string $property, array $context = []): ?PropertyWriteInfo
{
try {
$reflClass = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
return null;
}
@ -516,7 +517,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
{
try {
$reflectionClass = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
return null;
}
@ -546,7 +547,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
{
try {
$reflectionClass = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
return null;
}
@ -605,7 +606,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
$reflectionProperty = new \ReflectionProperty($class, $property);
return (bool) ($reflectionProperty->getModifiers() & $this->propertyReflectionFlags);
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
// Return false if the property doesn't exist
}
@ -632,7 +633,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
if (0 === $reflectionMethod->getNumberOfRequiredParameters()) {
return [$reflectionMethod, $prefix];
}
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
// Return null if the property doesn't exist
}
}
@ -668,7 +669,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
if ($reflectionMethod->getNumberOfParameters() >= 1) {
return [$reflectionMethod, $prefix];
}
} catch (\ReflectionException $e) {
} catch (\ReflectionException) {
// Try the next prefix if the method doesn't exist
}
}

View file

@ -13,19 +13,15 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Provider;
use Sylius\Bundle\ApiBundle\Payment\PaymentConfigurationProviderInterface;
use Sylius\Component\Core\Model\PaymentInterface;
use Sylius\Component\Core\Model\PaymentMethodInterface;
/** @experimental */
final class CompositePaymentConfigurationProvider implements CompositePaymentConfigurationProviderInterface
{
/** @var iterable<PaymentConfigurationProviderInterface> */
private iterable $apiPaymentMethodHandlers;
public function __construct(iterable $apiPaymentMethodHandlers)
{
$this->apiPaymentMethodHandlers = $apiPaymentMethodHandlers;
public function __construct(
private iterable $apiPaymentMethodHandlers
) {
}
public function provide(PaymentInterface $payment): array

View file

@ -21,20 +21,11 @@ use Sylius\Component\User\Canonicalizer\CanonicalizerInterface;
/** @experimental */
final class CustomerProvider implements CustomerProviderInterface
{
private CanonicalizerInterface $canonicalizer;
private FactoryInterface $customerFactory;
private CustomerRepositoryInterface $customerRepository;
public function __construct(
CanonicalizerInterface $canonicalizer,
FactoryInterface $customerFactory,
CustomerRepositoryInterface $customerRepository
private CanonicalizerInterface $canonicalizer,
private FactoryInterface $customerFactory,
private CustomerRepositoryInterface $customerRepository
) {
$this->canonicalizer = $canonicalizer;
$this->customerFactory = $customerFactory;
$this->customerRepository = $customerRepository;
}
public function provide(string $email): CustomerInterface

View file

@ -13,8 +13,6 @@ declare(strict_types=1);
namespace Sylius\Bundle\ApiBundle\Provider;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
/** @experimental */
class LiipProductImageFilterProvider implements ProductImageFilterProviderInterface
{
@ -37,7 +35,8 @@ class LiipProductImageFilterProvider implements ProductImageFilterProviderInterf
return $this->removeAdminFilters($filters);
}
private function removeAdminFilters(array $filters): array {
private function removeAdminFilters(array $filters): array
{
/** @var string $filter */
foreach ($filters as $key => $filter) {
if (str_contains($key, 'admin')) {

View file

@ -21,14 +21,10 @@ use Symfony\Component\Security\Core\User\UserInterface;
/** @experimental */
final class PathPrefixProvider implements PathPrefixProviderInterface
{
private UserContextInterface $userContext;
private string $apiRoute;
public function __construct(UserContextInterface $userContext, string $apiRoute)
{
$this->userContext = $userContext;
$this->apiRoute = $apiRoute;
public function __construct(
private UserContextInterface $userContext,
private string $apiRoute
) {
}
public function getPathPrefix(string $path): ?string

View file

@ -19,16 +19,14 @@ use Sylius\Bundle\CoreBundle\SectionResolver\UriBasedSectionResolverInterface;
final class AdminApiUriBasedSectionResolver implements UriBasedSectionResolverInterface
{
private string $adminApiUriBeginning;
public function __construct(string $adminApiUriBeginning)
{
$this->adminApiUriBeginning = $adminApiUriBeginning;
public function __construct(
private string $adminApiUriBeginning
) {
}
public function getSection(string $uri): SectionInterface
{
if (0 === strpos($uri, $this->adminApiUriBeginning)) {
if (str_starts_with($uri, $this->adminApiUriBeginning)) {
return new AdminApiSection();
}

View file

@ -19,19 +19,15 @@ use Sylius\Bundle\CoreBundle\SectionResolver\UriBasedSectionResolverInterface;
final class ShopApiUriBasedSectionResolver implements UriBasedSectionResolverInterface
{
private string $shopApiUriBeginning;
private string $shopApiOrdersResourceUri;
public function __construct(string $shopApiUriBeginning, string $shopApiOrdersResourceUri)
{
$this->shopApiUriBeginning = $shopApiUriBeginning;
$this->shopApiOrdersResourceUri = $shopApiOrdersResourceUri;
public function __construct(
private string $shopApiUriBeginning,
private string $shopApiOrdersResourceUri
) {
}
public function getSection(string $uri): SectionInterface
{
if (0 !== strpos($uri, $this->shopApiUriBeginning)) {
if (!str_starts_with($uri, $this->shopApiUriBeginning)) {
throw new SectionCannotBeResolvedException();
}

View file

@ -19,20 +19,11 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
/** @experimental */
final class AddressDenormalizer implements ContextAwareDenormalizerInterface
{
private DenormalizerInterface $objectNormalizer;
private string $classType;
private string $interfaceType;
public function __construct(
DenormalizerInterface $objectNormalizer,
string $classType,
string $interfaceType
private DenormalizerInterface $objectNormalizer,
private string $classType,
private string $interfaceType
) {
$this->objectNormalizer = $objectNormalizer;
$this->classType = $classType;
$this->interfaceType = $interfaceType;
}
public function denormalize($data, $type, $format = null, array $context = [])

View file

@ -22,20 +22,11 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
/** @experimental */
final class CommandArgumentsDenormalizer implements ContextAwareDenormalizerInterface
{
private DenormalizerInterface $objectNormalizer;
private IriToIdentifierConverterInterface $iriToIdentifierConverter;
private DataTransformerInterface $commandAwareInputDataTransformer;
public function __construct(
DenormalizerInterface $objectNormalizer,
IriToIdentifierConverterInterface $iriToIdentifierConverter,
DataTransformerInterface $commandAwareInputDataTransformer
private DenormalizerInterface $objectNormalizer,
private IriToIdentifierConverterInterface $iriToIdentifierConverter,
private DataTransformerInterface $commandAwareInputDataTransformer
) {
$this->objectNormalizer = $objectNormalizer;
$this->iriToIdentifierConverter = $iriToIdentifierConverter;
$this->commandAwareInputDataTransformer = $commandAwareInputDataTransformer;
}
public function supportsDenormalization($data, $type, $format = null, array $context = [])

View file

@ -24,11 +24,9 @@ final class CommandDenormalizer implements ContextAwareDenormalizerInterface
{
private const OBJECT_TO_POPULATE = 'object_to_populate';
private DenormalizerInterface $itemNormalizer;
public function __construct(DenormalizerInterface $itemNormalizer)
{
$this->itemNormalizer = $itemNormalizer;
public function __construct(
private DenormalizerInterface $itemNormalizer
) {
}
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool

View file

@ -24,11 +24,9 @@ final class CommandNormalizer implements ContextAwareNormalizerInterface
{
private const ALREADY_CALLED = 'sylius_command_normalizer_already_called';
private NormalizerInterface $objectNormalizer;
public function __construct(NormalizerInterface $objectNormalizer)
{
$this->objectNormalizer = $objectNormalizer;
public function __construct(
private NormalizerInterface $objectNormalizer
) {
}
public function supportsNormalization($data, $format = null, $context = []): bool

View file

@ -32,16 +32,10 @@ final class OrderItemNormalizer implements ContextAwareNormalizerInterface, Norm
private const ALREADY_CALLED = 'sylius_order_item_normalizer_already_called';
/** @var ChannelContextInterface */
private $channelContext;
/** @var SectionProviderInterface */
private $uriBasedSectionContext;
public function __construct(ChannelContextInterface $channelContext, SectionProviderInterface $uriBasedSectionContext)
{
$this->channelContext = $channelContext;
$this->uriBasedSectionContext = $uriBasedSectionContext;
public function __construct(
private ChannelContextInterface $channelContext,
private SectionProviderInterface $uriBasedSectionContext
) {
}
public function normalize($object, $format = null, array $context = [])

Some files were not shown because too many files have changed in this diff Show more