diff --git a/composer.json b/composer.json index 5c4166c..ca97937 100644 --- a/composer.json +++ b/composer.json @@ -18,12 +18,13 @@ }, "require-dev": { "phpunit/phpunit": "^9", - "ibexa/code-style": "^1.1", + "ibexa/code-style": "~2.3.1", "ibexa/doctrine-schema": "~4.6.x-dev", "phpstan/phpstan": "^2.0", "phpstan/phpstan-phpunit": "^2.0", "phpstan/phpstan-symfony": "^2.0", - "qossmic/deptrac-shim": "^0.24.0 || ^1.0.2" + "qossmic/deptrac-shim": "^0.24.0 || ^1.0.2", + "ibexa/doctrine-migrations": "~4.6.x-dev" }, "autoload": { "psr-4": { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/NotificationsConfigParser.php b/src/bundle/DependencyInjection/Configuration/Parser/NotificationsConfigParser.php index 6ade1dd..9527883 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/NotificationsConfigParser.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/NotificationsConfigParser.php @@ -46,8 +46,11 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void /** * @param array> $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['notifier'])) { return; } @@ -70,8 +73,10 @@ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerIn /** * @param array $config */ - public function postMap(array $config, ContextualizerInterface $contextualizer): void - { + public function postMap( + array $config, + ContextualizerInterface $contextualizer + ): void { foreach (self::MAPPED_SETTINGS as $setting) { $contextualizer->mapConfigArray(sprintf('notifications.%s', $setting), $config); } diff --git a/src/bundle/DependencyInjection/IbexaNotificationsExtension.php b/src/bundle/DependencyInjection/IbexaNotificationsExtension.php index e854c14..54e55c8 100644 --- a/src/bundle/DependencyInjection/IbexaNotificationsExtension.php +++ b/src/bundle/DependencyInjection/IbexaNotificationsExtension.php @@ -21,8 +21,10 @@ final class IbexaNotificationsExtension extends Extension implements PrependExte /** * @param array $configs */ - public function load(array $configs, ContainerBuilder $container): void - { + public function load( + array $configs, + ContainerBuilder $container + ): void { $loader = new YamlFileLoader( $container, new FileLocator(__DIR__ . '/../Resources/config') diff --git a/src/bundle/IbexaNotificationsBundle.php b/src/bundle/IbexaNotificationsBundle.php index 2373924..402deaa 100644 --- a/src/bundle/IbexaNotificationsBundle.php +++ b/src/bundle/IbexaNotificationsBundle.php @@ -8,6 +8,7 @@ namespace Ibexa\Bundle\Notifications; +use Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension; use Ibexa\Bundle\Notifications\DependencyInjection\Configuration\Parser\NotificationsConfigParser; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -16,7 +17,7 @@ final class IbexaNotificationsBundle extends Bundle { public function build(ContainerBuilder $container): void { - /** @var \Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension $core */ + /** @var IbexaCoreExtension $core */ $core = $container->getExtension('ibexa'); $core->addConfigParser(new NotificationsConfigParser()); diff --git a/src/contracts/Service/NotificationServiceInterface.php b/src/contracts/Service/NotificationServiceInterface.php index 5b094c8..9cab38d 100644 --- a/src/contracts/Service/NotificationServiceInterface.php +++ b/src/contracts/Service/NotificationServiceInterface.php @@ -9,11 +9,15 @@ namespace Ibexa\Contracts\Notifications\Service; use Ibexa\Contracts\Notifications\Value\NotificationInterface; +use Ibexa\Contracts\Notifications\Value\RecipientInterface; interface NotificationServiceInterface { /** - * @param array<\Ibexa\Contracts\Notifications\Value\RecipientInterface> $recipients + * @param array $recipients */ - public function send(NotificationInterface $notification, array $recipients = []): void; + public function send( + NotificationInterface $notification, + array $recipients = [] + ): void; } diff --git a/src/contracts/SystemNotification/SystemMessage.php b/src/contracts/SystemNotification/SystemMessage.php index d65c831..c5bfb3d 100644 --- a/src/contracts/SystemNotification/SystemMessage.php +++ b/src/contracts/SystemNotification/SystemMessage.php @@ -28,8 +28,10 @@ final class SystemMessage implements MessageInterface /** * @param array $context */ - public function __construct(UserReference $user, array $context = []) - { + public function __construct( + UserReference $user, + array $context = [] + ) { $this->user = $user; $this->context = $context; } diff --git a/src/contracts/SystemNotification/SystemNotification.php b/src/contracts/SystemNotification/SystemNotification.php index 5793f5c..a9f6e64 100644 --- a/src/contracts/SystemNotification/SystemNotification.php +++ b/src/contracts/SystemNotification/SystemNotification.php @@ -43,8 +43,10 @@ public function setContent(string $content): void $this->content($content); } - public function asSystemNotification(UserRecipientInterface $recipient, ?string $transport = null): SystemMessage - { + public function asSystemNotification( + UserRecipientInterface $recipient, + ?string $transport = null + ): SystemMessage { $context = [ 'subject' => $this->getSubject(), 'content' => $this->getContent(), diff --git a/src/lib/Mapper/NotificationMapperInterface.php b/src/lib/Mapper/NotificationMapperInterface.php index f957424..b522dca 100644 --- a/src/lib/Mapper/NotificationMapperInterface.php +++ b/src/lib/Mapper/NotificationMapperInterface.php @@ -8,6 +8,7 @@ namespace Ibexa\Notifications\Mapper; +use Ibexa\Contracts\Core\Exception\InvalidArgumentException; use Ibexa\Contracts\Notifications\Value\NotificationInterface; use Symfony\Component\Notifier\Notification\Notification; @@ -16,7 +17,7 @@ interface NotificationMapperInterface /** * Produces Symfony Notifier's compatible Notification object. * - * @throws \Ibexa\Contracts\Core\Exception\InvalidArgumentException + * @throws InvalidArgumentException */ public function mapToSymfonyNotification(NotificationInterface $notification): Notification; } diff --git a/src/lib/Mapper/RecipientMapperInterface.php b/src/lib/Mapper/RecipientMapperInterface.php index da034fa..06f2cec 100644 --- a/src/lib/Mapper/RecipientMapperInterface.php +++ b/src/lib/Mapper/RecipientMapperInterface.php @@ -8,6 +8,7 @@ namespace Ibexa\Notifications\Mapper; +use Ibexa\Contracts\Core\Exception\InvalidArgumentException; use Ibexa\Contracts\Notifications\Value\RecipientInterface; use Symfony\Component\Notifier\Recipient\RecipientInterface as SymfonyRecipientInterface; @@ -16,7 +17,7 @@ interface RecipientMapperInterface /** * Produces Symfony Notifier's compatible RecipientInterface object. * - * @throws \Ibexa\Contracts\Core\Exception\InvalidArgumentException + * @throws InvalidArgumentException */ public function mapToSymfonyRecipient(RecipientInterface $recipient): SymfonyRecipientInterface; } diff --git a/src/lib/Service/NotificationService.php b/src/lib/Service/NotificationService.php index a6d0d10..ce8e047 100644 --- a/src/lib/Service/NotificationService.php +++ b/src/lib/Service/NotificationService.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Notifications\Service\NotificationServiceInterface; use Ibexa\Contracts\Notifications\Value\NotificationInterface; +use Ibexa\Contracts\Notifications\Value\RecipientInterface; use Ibexa\Notifications\Mapper\NotificationMapperInterface; use Ibexa\Notifications\Mapper\RecipientMapperInterface; use Ibexa\Notifications\SubscriptionResolver\SubscriptionResolverInterface; @@ -39,10 +40,12 @@ public function __construct( } /** - * @param array<\Ibexa\Contracts\Notifications\Value\RecipientInterface> $recipients + * @param array $recipients */ - public function send(NotificationInterface $notification, array $recipients = []): void - { + public function send( + NotificationInterface $notification, + array $recipients = [] + ): void { $channels = array_map( static fn ( ChannelSubscription $channelSubscription diff --git a/src/lib/SubscriptionResolver/ChainSubscriptionResolver.php b/src/lib/SubscriptionResolver/ChainSubscriptionResolver.php index b94f9a9..4f33bc1 100644 --- a/src/lib/SubscriptionResolver/ChainSubscriptionResolver.php +++ b/src/lib/SubscriptionResolver/ChainSubscriptionResolver.php @@ -12,19 +12,21 @@ final class ChainSubscriptionResolver implements SubscriptionResolverInterface { - /** @var iterable<\Ibexa\Notifications\SubscriptionResolver\SubscriptionResolverInterface> */ + /** @var iterable */ private iterable $resolvers; /** - * @param iterable<\Ibexa\Notifications\SubscriptionResolver\SubscriptionResolverInterface> $resolvers + * @param iterable $resolvers */ public function __construct(iterable $resolvers) { $this->resolvers = $resolvers; } - public function resolve(NotificationInterface $notification, array $context = []): iterable - { + public function resolve( + NotificationInterface $notification, + array $context = [] + ): iterable { foreach ($this->resolvers as $resolver) { $channelSubscriptions = $resolver->resolve($notification, $context); foreach ($channelSubscriptions as $channelSubscription) { diff --git a/src/lib/SubscriptionResolver/ConfigBasedSubscriptionResolver.php b/src/lib/SubscriptionResolver/ConfigBasedSubscriptionResolver.php index 6cdaabc..74bca55 100644 --- a/src/lib/SubscriptionResolver/ConfigBasedSubscriptionResolver.php +++ b/src/lib/SubscriptionResolver/ConfigBasedSubscriptionResolver.php @@ -21,8 +21,10 @@ public function __construct(ConfigResolverInterface $configResolver) $this->configResolver = $configResolver; } - public function resolve(NotificationInterface $notification, array $context = []): iterable - { + public function resolve( + NotificationInterface $notification, + array $context = [] + ): iterable { $config = $this->configResolver->getParameter('notifications.subscriptions'); $notificationType = $notification->getType(); diff --git a/src/lib/SubscriptionResolver/SubscriptionResolverInterface.php b/src/lib/SubscriptionResolver/SubscriptionResolverInterface.php index e8c5f42..3bd6fd0 100644 --- a/src/lib/SubscriptionResolver/SubscriptionResolverInterface.php +++ b/src/lib/SubscriptionResolver/SubscriptionResolverInterface.php @@ -9,13 +9,17 @@ namespace Ibexa\Notifications\SubscriptionResolver; use Ibexa\Contracts\Notifications\Value\NotificationInterface; +use Ibexa\Notifications\Value\ChannelSubscription; interface SubscriptionResolverInterface { /** * @param array $context * - * @return \Iterator<\Ibexa\Notifications\Value\ChannelSubscription|null> + * @return \Iterator */ - public function resolve(NotificationInterface $notification, array $context = []): iterable; + public function resolve( + NotificationInterface $notification, + array $context = [] + ): iterable; } diff --git a/src/lib/SystemNotification/SystemNotificationChannel.php b/src/lib/SystemNotification/SystemNotificationChannel.php index 59983da..df20c64 100644 --- a/src/lib/SystemNotification/SystemNotificationChannel.php +++ b/src/lib/SystemNotification/SystemNotificationChannel.php @@ -24,18 +24,23 @@ final class SystemNotificationChannel implements ChannelInterface private NotificationService $notificationService; - public function __construct(Repository $repository, NotificationService $notificationService) - { + public function __construct( + Repository $repository, + NotificationService $notificationService + ) { $this->repository = $repository; $this->notificationService = $notificationService; } /** - * @param \Symfony\Component\Notifier\Notification\Notification&\Ibexa\Contracts\Notifications\SystemNotification\SystemNotificationInterface $notification - * @param \Ibexa\Contracts\Notifications\Value\Recipent\UserRecipientInterface $recipient + * @param Notification&SystemNotificationInterface $notification + * @param UserRecipientInterface $recipient */ - public function notify(Notification $notification, RecipientInterface $recipient, ?string $transportName = null): void - { + public function notify( + Notification $notification, + RecipientInterface $recipient, + ?string $transportName = null + ): void { $message = $notification->asSystemNotification($recipient, $transportName); if ($message === null) { return; @@ -56,8 +61,10 @@ public function notify(Notification $notification, RecipientInterface $recipient } } - public function supports(Notification $notification, RecipientInterface $recipient): bool - { + public function supports( + Notification $notification, + RecipientInterface $recipient + ): bool { return $notification instanceof SystemNotificationInterface && $recipient instanceof UserRecipientInterface; } } diff --git a/src/lib/Value/ChannelSubscription.php b/src/lib/Value/ChannelSubscription.php index 1da463a..089e969 100644 --- a/src/lib/Value/ChannelSubscription.php +++ b/src/lib/Value/ChannelSubscription.php @@ -14,8 +14,10 @@ final class ChannelSubscription private string $channel; - public function __construct(string $notificationType, string $channel) - { + public function __construct( + string $notificationType, + string $channel + ) { $this->notificationType = $notificationType; $this->channel = $channel; } diff --git a/tests/lib/Channel/SystemNotificationChannelTest.php b/tests/lib/Channel/SystemNotificationChannelTest.php index ac257c9..33f3b75 100644 --- a/tests/lib/Channel/SystemNotificationChannelTest.php +++ b/tests/lib/Channel/SystemNotificationChannelTest.php @@ -17,6 +17,7 @@ use Ibexa\Contracts\Notifications\SystemNotification\SystemNotificationInterface; use Ibexa\Contracts\Notifications\Value\Recipent\UserRecipientInterface; use Ibexa\Notifications\SystemNotification\SystemNotificationChannel; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Notifier\Notification\Notification; use Symfony\Component\Notifier\Recipient\RecipientInterface; @@ -25,10 +26,10 @@ final class SystemNotificationChannelTest extends TestCase { private const EXAMPLE_USER_ID = 12; - /** @var \Ibexa\Contracts\Core\Repository\Repository&\PHPUnit\Framework\MockObject\MockObject */ + /** @var Repository&MockObject */ private Repository $repository; - /** @var \Ibexa\Contracts\Core\Repository\NotificationService&\PHPUnit\Framework\MockObject\MockObject */ + /** @var NotificationService&MockObject */ private NotificationService $notificationService; private SystemNotificationChannel $channel; @@ -44,13 +45,16 @@ protected function setUp(): void /** * @dataProvider dataProviderForTestSupports */ - public function testSupports(Notification $notification, RecipientInterface $recipient, bool $expectedResult): void - { + public function testSupports( + Notification $notification, + RecipientInterface $recipient, + bool $expectedResult + ): void { self::assertEquals($expectedResult, $this->channel->supports($notification, $recipient)); } /** - * @return iterable + * @return iterable */ public function dataProviderForTestSupports(): iterable { @@ -99,7 +103,7 @@ public function testNotify(): void } /** - * @return \Symfony\Component\Notifier\Notification\Notification&\Ibexa\Contracts\Notifications\SystemNotification\SystemNotificationInterface + * @return Notification&SystemNotificationInterface */ private function createSupportedNotification(?SystemMessage $message = null): Notification { diff --git a/tests/lib/SubscriptionResolver/ChainSubscriptionResolverTest.php b/tests/lib/SubscriptionResolver/ChainSubscriptionResolverTest.php index 614cd90..cee4e67 100644 --- a/tests/lib/SubscriptionResolver/ChainSubscriptionResolverTest.php +++ b/tests/lib/SubscriptionResolver/ChainSubscriptionResolverTest.php @@ -11,6 +11,7 @@ use Ibexa\Contracts\Notifications\Value\NotificationInterface; use Ibexa\Notifications\SubscriptionResolver\ChainSubscriptionResolver; use Ibexa\Notifications\SubscriptionResolver\SubscriptionResolverInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; final class ChainSubscriptionResolverTest extends TestCase @@ -18,11 +19,13 @@ final class ChainSubscriptionResolverTest extends TestCase /** * @dataProvider provideForTestResolve * - * @param array<\Ibexa\Notifications\SubscriptionResolver\SubscriptionResolverInterface> $resolvers + * @param array $resolvers * @param array $expectedChannels */ - public function testResolve(array $resolvers, array $expectedChannels): void - { + public function testResolve( + array $resolvers, + array $expectedChannels + ): void { $subscriptionResolver = new ChainSubscriptionResolver($resolvers); $notification = $this->createMock(NotificationInterface::class); @@ -33,7 +36,7 @@ public function testResolve(array $resolvers, array $expectedChannels): void /** * @return iterable, + * array, * array, * }> */ @@ -59,7 +62,7 @@ public function provideForTestResolve(): iterable /** * @param array $channels * - * @return \Ibexa\Notifications\SubscriptionResolver\SubscriptionResolverInterface&\PHPUnit\Framework\MockObject\MockObject + * @return SubscriptionResolverInterface&MockObject */ private function mockResolver(array $channels): SubscriptionResolverInterface { diff --git a/tests/lib/SubscriptionResolver/ConfigBasedSubscriptionResolverTest.php b/tests/lib/SubscriptionResolver/ConfigBasedSubscriptionResolverTest.php index e5fdc30..abcd8ad 100644 --- a/tests/lib/SubscriptionResolver/ConfigBasedSubscriptionResolverTest.php +++ b/tests/lib/SubscriptionResolver/ConfigBasedSubscriptionResolverTest.php @@ -12,6 +12,7 @@ use Ibexa\Contracts\Notifications\Value\NotificationInterface; use Ibexa\Notifications\SubscriptionResolver\ConfigBasedSubscriptionResolver; use Ibexa\Notifications\Value\ChannelSubscription; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** @@ -21,7 +22,7 @@ final class ConfigBasedSubscriptionResolverTest extends TestCase { private ConfigBasedSubscriptionResolver $resolver; - /** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ConfigResolverInterface|MockObject */ private ConfigResolverInterface $configResolver; public function setUp(): void