diff --git a/composer.json b/composer.json index 4266b02..ad6eee7 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,6 @@ "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.5", "psalm/plugin-phpunit": "^0.17", - "psalm/plugin-symfony": "^3.1", "setono/code-quality-pack": "^2.2", "sylius/admin-api-bundle": "^1.11", "sylius/sylius": "~1.10.14", @@ -75,12 +74,8 @@ "sort-packages": true }, "scripts": { - "analyse": [ - "@ensure-test-container-exists", - "psalm" - ], + "analyse": "psalm", "check-style": "ecs check", - "ensure-test-container-exists": "[[ -f tests/Application/var/cache/test/Tests_Setono_SyliusAbandonedCartPlugin_Application_KernelTestDebugContainer.xml ]] || tests/Application/bin/console cache:warmup --env=test", "fix-style": "ecs check --fix", "phpunit": "phpunit" } diff --git a/psalm.xml b/psalm.xml index 9ce6c58..b4015f3 100644 --- a/psalm.xml +++ b/psalm.xml @@ -15,13 +15,6 @@ - - - tests/Application/var/cache/test/ApplicationTests_Setono_SyliusAbandonedCartPlugin_Application_KernelTestDebugContainer.xml - - - tests/Application/var/cache/test/Tests_Setono_SyliusAbandonedCartPlugin_Application_KernelTestDebugContainer.xml - diff --git a/src/Controller/Action/UnsubscribeCustomerAction.php b/src/Controller/Action/UnsubscribeCustomerAction.php index eb5deed..c461850 100644 --- a/src/Controller/Action/UnsubscribeCustomerAction.php +++ b/src/Controller/Action/UnsubscribeCustomerAction.php @@ -26,7 +26,7 @@ public function __construct( EmailHasherInterface $emailHasher, UnsubscribedCustomerRepositoryInterface $unsubscribedCustomerRepository, UnsubscribedCustomerFactoryInterface $unsubscribedCustomerFactory, - Environment $twig + Environment $twig, ) { $this->emailHasher = $emailHasher; $this->unsubscribedCustomerRepository = $unsubscribedCustomerRepository; @@ -50,7 +50,7 @@ public function __invoke(Request $request): Response Assert::false( $this->unsubscribedCustomerRepository->isUnsubscribed($email), - 'setono_sylius_abandoned_cart.ui.email_already_unsubscribed' + 'setono_sylius_abandoned_cart.ui.email_already_unsubscribed', ); $this->unsubscribedCustomerRepository->add($this->unsubscribedCustomerFactory->createWithEmail($email)); diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 5f0f795..712404c 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -23,6 +23,7 @@ public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('setono_sylius_abandoned_cart'); + /** @var ArrayNodeDefinition $rootNode */ $rootNode = $treeBuilder->getRootNode(); /** @psalm-suppress MixedMethodCall,PossiblyNullReference,PossiblyUndefinedMethod */ diff --git a/src/Dispatcher/NotificationDispatcher.php b/src/Dispatcher/NotificationDispatcher.php index bc69cf0..b68bb0a 100644 --- a/src/Dispatcher/NotificationDispatcher.php +++ b/src/Dispatcher/NotificationDispatcher.php @@ -39,7 +39,7 @@ public function __construct( MessageBusInterface $commandBus, NotificationRepositoryInterface $notificationRepository, Registry $workflowRegistry, - int $idleThresholdInMinutes + int $idleThresholdInMinutes, ) { $this->managerRegistry = $managerRegistry; $this->logger = new NullLogger(); @@ -52,12 +52,12 @@ public function __construct( public function dispatch(): void { $notifications = $this->notificationRepository->findNew( - new DateInterval(sprintf('PT%dM', $this->idleThresholdInMinutes)) + new DateInterval(sprintf('PT%dM', $this->idleThresholdInMinutes)), ); $this->logger->debug(sprintf( 'Notifications with associated orders that have not been updated for %d minutes will be notified', - $this->idleThresholdInMinutes + $this->idleThresholdInMinutes, )); $dispatchCount = 0; @@ -68,7 +68,7 @@ public function dispatch(): void $this->logger->warning(sprintf( 'The notification with id %d could not take the transition "%s"', (int) $notification->getId(), - NotificationWorkflow::TRANSITION_START + NotificationWorkflow::TRANSITION_START, )); continue; diff --git a/src/EventListener/Doctrine/CreateNotificationOnOrderPersistenceListener.php b/src/EventListener/Doctrine/CreateNotificationOnOrderPersistenceListener.php index 37286c4..8b0a8a7 100644 --- a/src/EventListener/Doctrine/CreateNotificationOnOrderPersistenceListener.php +++ b/src/EventListener/Doctrine/CreateNotificationOnOrderPersistenceListener.php @@ -18,7 +18,7 @@ final class CreateNotificationOnOrderPersistenceListener public function __construct( NotificationFactoryInterface $notificationFactory, - ManagerRegistry $managerRegistry + ManagerRegistry $managerRegistry, ) { $this->notificationFactory = $notificationFactory; $this->managerRegistry = $managerRegistry; diff --git a/src/EventSubscriber/Workflow/ResetProcessingErrorsSubscriber.php b/src/EventSubscriber/Workflow/ResetProcessingErrorsSubscriber.php index 92b38e0..38822b4 100644 --- a/src/EventSubscriber/Workflow/ResetProcessingErrorsSubscriber.php +++ b/src/EventSubscriber/Workflow/ResetProcessingErrorsSubscriber.php @@ -17,7 +17,7 @@ public static function getSubscribedEvents(): array $event = sprintf( 'workflow.%s.transition.%s', NotificationWorkflow::NAME, - NotificationWorkflow::TRANSITION_START + NotificationWorkflow::TRANSITION_START, ); return [ diff --git a/src/Factory/OrderFactory.php b/src/Factory/OrderFactory.php index dd40feb..9eb3ca1 100644 --- a/src/Factory/OrderFactory.php +++ b/src/Factory/OrderFactory.php @@ -20,7 +20,7 @@ final class OrderFactory implements FactoryInterface public function __construct( FactoryInterface $decorated, - OrderTokenAssignerInterface $orderTokenAssigner + OrderTokenAssignerInterface $orderTokenAssigner, ) { $this->decorated = $decorated; $this->orderTokenAssigner = $orderTokenAssigner; diff --git a/src/Mailer/EmailManager.php b/src/Mailer/EmailManager.php index 5a3051d..0c715cd 100644 --- a/src/Mailer/EmailManager.php +++ b/src/Mailer/EmailManager.php @@ -21,7 +21,7 @@ final class EmailManager implements EmailManagerInterface public function __construct( SenderInterface $emailSender, CartRecoveryUrlGeneratorInterface $cartRecoveryUrlGenerator, - UnsubscribeUrlGeneratorInterface $unsubscribeUrlGenerator + UnsubscribeUrlGeneratorInterface $unsubscribeUrlGenerator, ) { $this->emailSender = $emailSender; $this->cartRecoveryUrlGenerator = $cartRecoveryUrlGenerator; diff --git a/src/Message/Handler/ProcessNotificationHandler.php b/src/Message/Handler/ProcessNotificationHandler.php index d6f5283..c64e703 100644 --- a/src/Message/Handler/ProcessNotificationHandler.php +++ b/src/Message/Handler/ProcessNotificationHandler.php @@ -21,7 +21,7 @@ final class ProcessNotificationHandler implements MessageHandlerInterface public function __construct( NotificationRepositoryInterface $notificationRepository, - NotificationProcessorInterface $notificationProcessor + NotificationProcessorInterface $notificationProcessor, ) { $this->notificationRepository = $notificationRepository; $this->notificationProcessor = $notificationProcessor; @@ -36,7 +36,7 @@ public function __invoke(ProcessNotification $message): void if (null === $notification) { throw new UnrecoverableMessageHandlingException(sprintf( 'Could not find notification with id %d', - $message->notificationId + $message->notificationId, )); } diff --git a/src/Processor/NotificationProcessor.php b/src/Processor/NotificationProcessor.php index 490eb33..c22d5c6 100644 --- a/src/Processor/NotificationProcessor.php +++ b/src/Processor/NotificationProcessor.php @@ -32,7 +32,7 @@ public function __construct( ManagerRegistry $managerRegistry, EmailManagerInterface $emailManager, Registry $workflowRegistry, - NotificationEligibilityCheckerInterface $notificationEligibilityChecker + NotificationEligibilityCheckerInterface $notificationEligibilityChecker, ) { $this->managerRegistry = $managerRegistry; $this->emailManager = $emailManager; @@ -62,7 +62,7 @@ function (NotificationInterface $notification) { Assert::notNull($order); $this->emailManager->sendNotification($notification); - } + }, ); } catch (Throwable $e) { $message = sprintf( @@ -99,7 +99,7 @@ private function tryTransition(NotificationInterface $notification, string $tran $notification->addProcessingError(sprintf( 'Could not take transition "%s". The state when trying to take the transition was: "%s"', $transition, - $notification->getState() + $notification->getState(), )); $this->tryTransition($notification, NotificationWorkflow::TRANSITION_FAIL); diff --git a/src/Pruner/Pruner.php b/src/Pruner/Pruner.php index c93622b..a1932e7 100644 --- a/src/Pruner/Pruner.php +++ b/src/Pruner/Pruner.php @@ -22,7 +22,7 @@ public function __construct(NotificationRepositoryInterface $notificationReposit public function prune(): void { $this->notificationRepository->removeOlderThan( - new DateTimeImmutable(sprintf('-%d minutes', $this->pruneOlderThan)) + new DateTimeImmutable(sprintf('-%d minutes', $this->pruneOlderThan)), ); } } diff --git a/src/UrlGenerator/CartRecoveryUrlGenerator.php b/src/UrlGenerator/CartRecoveryUrlGenerator.php index 697462a..b734074 100644 --- a/src/UrlGenerator/CartRecoveryUrlGenerator.php +++ b/src/UrlGenerator/CartRecoveryUrlGenerator.php @@ -23,7 +23,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator, string $route) public function generate( OrderInterface $order, - array $parameters = [] + array $parameters = [], ): string { $channel = $order->getChannel(); Assert::notNull($channel); @@ -48,7 +48,7 @@ public function generate( '%s://%s%s', $this->urlGenerator->getContext()->getScheme(), (string) $channel->getHostname(), - $path + $path, ); } } diff --git a/src/UrlGenerator/CartRecoveryUrlGeneratorInterface.php b/src/UrlGenerator/CartRecoveryUrlGeneratorInterface.php index d6f2fab..ca9033c 100644 --- a/src/UrlGenerator/CartRecoveryUrlGeneratorInterface.php +++ b/src/UrlGenerator/CartRecoveryUrlGeneratorInterface.php @@ -13,6 +13,6 @@ interface CartRecoveryUrlGeneratorInterface */ public function generate( OrderInterface $order, - array $parameters = [] + array $parameters = [], ): string; } diff --git a/src/UrlGenerator/UnsubscribeUrlGenerator.php b/src/UrlGenerator/UnsubscribeUrlGenerator.php index e9456df..7598831 100644 --- a/src/UrlGenerator/UnsubscribeUrlGenerator.php +++ b/src/UrlGenerator/UnsubscribeUrlGenerator.php @@ -28,7 +28,7 @@ public function generate( ChannelInterface $channel, string $email, string $locale, - array $parameters = [] + array $parameters = [], ): string { $parameters = array_merge([ 'email' => $email, @@ -51,7 +51,7 @@ public function generate( '%s://%s%s', $this->urlGenerator->getContext()->getScheme(), (string) $channel->getHostname(), - $path + $path, ); } } diff --git a/src/UrlGenerator/UnsubscribeUrlGeneratorInterface.php b/src/UrlGenerator/UnsubscribeUrlGeneratorInterface.php index 1ea0898..5b075b7 100644 --- a/src/UrlGenerator/UnsubscribeUrlGeneratorInterface.php +++ b/src/UrlGenerator/UnsubscribeUrlGeneratorInterface.php @@ -15,6 +15,6 @@ public function generate( ChannelInterface $channel, string $email, string $locale, - array $parameters = [] + array $parameters = [], ): string; } diff --git a/tests/Factory/OrderFactoryTest.php b/tests/Factory/OrderFactoryTest.php index 14f1779..356356b 100644 --- a/tests/Factory/OrderFactoryTest.php +++ b/tests/Factory/OrderFactoryTest.php @@ -30,7 +30,7 @@ public function it_creates_notification_when_creating_order(): void $factory = new OrderFactory( new Factory(Order::class), - $orderTokenAssigner->reveal() + $orderTokenAssigner->reveal(), ); $factory->createNew(); } diff --git a/tests/UrlGenerator/UnsubscribeUrlGeneratorTest.php b/tests/UrlGenerator/UnsubscribeUrlGeneratorTest.php index 5bf2c88..105b3ed 100644 --- a/tests/UrlGenerator/UnsubscribeUrlGeneratorTest.php +++ b/tests/UrlGenerator/UnsubscribeUrlGeneratorTest.php @@ -30,7 +30,7 @@ public function it_generates_url(): void $urlGenerator = new UnsubscribeUrlGenerator( $this->urlGenerator, new EmailHasher('salt'), - 'setono_sylius_abandoned_cart_shop_unsubscribe_customer' + 'setono_sylius_abandoned_cart_shop_unsubscribe_customer', ); $channel = new Channel(); @@ -38,7 +38,7 @@ public function it_generates_url(): void self::assertSame( 'https://example.com/abandoned-cart/unsubscribe?email=johndoe@example.com&hash=2ac21379842b5445001475a596caab5843ecbc6be46c27f882cb6c0bd75fb9f9&utm_source=sylius&utm_medium=email&utm_campaign=Abandoned%20Cart%20Unsubscribe&_locale=en_US', - $urlGenerator->generate($channel, 'johndoe@example.com', 'en_US') + $urlGenerator->generate($channel, 'johndoe@example.com', 'en_US'), ); } @@ -50,7 +50,7 @@ public function it_allows_to_overwrite_parameters(): void $urlGenerator = new UnsubscribeUrlGenerator( $this->urlGenerator, new EmailHasher('salt'), - 'setono_sylius_abandoned_cart_shop_unsubscribe_customer' + 'setono_sylius_abandoned_cart_shop_unsubscribe_customer', ); $channel = new Channel(); @@ -61,7 +61,7 @@ public function it_allows_to_overwrite_parameters(): void $urlGenerator->generate($channel, 'johndoe@example.com', 'en_US', [ 'utm_campaign' => 'Abandoned Cart Unsubscribe #2', 'utm_content' => 'Number two', - ]) + ]), ); } }