Repository: spiral/framework (php)

Issue:
[SendIt] Interface "Spiral\Jobs\SerializerInterface" not found. After migration to roadrunner-bridge
### Description

I decide to migrate from spiral app to rr2. It requires `roadrunner-bridge` which conflicts with `spiral\jobs`.

The problem is SendIt uses interfaces from `spiral\jobs` but I can't use it with roadrunner-bridge

https://github.com/spiral/framework/blob/23299ff3442a9334494b9481b9adbd2b4a317907/src/SendIt/src/MailQueue.php#L48

https://github.com/spiral/framework/blob/23299ff3442a9334494b9481b9adbd2b4a317907/src/SendIt/src/MessageSerializer.php#L18


[<!-- A clear and concise description of the problem. -->](https://github.com/spiral/framework/blob/23299ff3442a9334494b9481b9adbd2b4a317907/src/SendIt/src/MessageSerializer.php#L18)

### How To Reproduce

- Install `roadrunner-bridge`
- try to send message to queue

```php
use Spiral\Mailer;
use Spiral\Mailer\MailerInterface as SpiralMailer;
// ...
$this->mailer->send(new Mailer\Message(
    'email/message.dark.php',
    $user->getEmail(),
    [
        'payload' => [],
    ]
));
```

### Additional Info

| Q                   | A
| ------------------- | ---
| Framework Version   | 2.13.0 <!-- Please set the framework's version -->
| PHP version         | 8.0 <!-- Please set the PHP version -->
| Operating system    | Linux <!-- Please set your OS -->

<!-- Optional: any other context about the problem: log messages, screenshots, etc. -->


Pull request:
Fixes problem with using roadrunner-bridge with SendIt component
fixed #682

| Q             | A
| ------------- | ---
| Bugfix?       | ✔️
| Breaks BC?    | ❌
| New feature?  | ❌
| Issues        | #682 

Patch:
diff --git a/src/SendIt/src/Bootloader/MailerBootloader.php b/src/SendIt/src/Bootloader/MailerBootloader.php
index 02793882b..c2660efd6 100644
--- a/src/SendIt/src/Bootloader/MailerBootloader.php
+++ b/src/SendIt/src/Bootloader/MailerBootloader.php
@@ -25,9 +25,9 @@ use Spiral\Queue\Bootloader\QueueBootloader;
 use Spiral\Queue\HandlerRegistryInterface;
 use Spiral\Queue\QueueConnectionProviderInterface;
 use Spiral\SendIt\Config\MailerConfig;
+use Spiral\SendIt\JsonJobSerializer;
 use Spiral\SendIt\MailJob;
 use Spiral\SendIt\MailQueue;
-use Spiral\SendIt\MessageSerializer;
 use Symfony\Component\Mailer\Mailer;
 use Symfony\Component\Mailer\MailerInterface as SymfonyMailer;
 use Symfony\Component\Mailer\Transport;
@@ -35,7 +35,7 @@ use Symfony\Component\Mailer\Transport;
 /**
  * Enables email sending pipeline.
  */
-class MailerBootloader extends Bootloader
+final class MailerBootloader extends Bootloader
 {
     protected const DEPENDENCIES = [
         JobsBootloader::class,
@@ -74,7 +74,7 @@ class MailerBootloader extends Bootloader
             // Will be removed since v3.0
             $registry = $container->get(JobRegistry::class);
             $registry->setHandler(MailQueue::JOB_NAME, MailJob::class);
-            $registry->setSerializer(MailQueue::JOB_NAME, MessageSerializer::class);
+            $registry->setSerializer(MailQueue::JOB_NAME, JsonJobSerializer::class);
             $container->bindSingleton(
                 MailerInterface::class,
                 static function (MailerConfig $config) use ($container) {
diff --git a/src/SendIt/src/JsonJobSerializer.php b/src/SendIt/src/JsonJobSerializer.php
new file mode 100644
index 000000000..240b93e1c
--- /dev/null
+++ b/src/SendIt/src/JsonJobSerializer.php
@@ -0,0 +1,15 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Spiral\SendIt;
+
+use Spiral\Jobs\SerializerInterface;
+
+final class JsonJobSerializer implements SerializerInterface
+{
+    public function serialize(string $jobType, array $payload): string
+    {
+        return json_encode($payload);
+    }
+}
diff --git a/src/SendIt/src/MessageSerializer.php b/src/SendIt/src/MessageSerializer.php
index 8bd76c814..a9661927a 100644
--- a/src/SendIt/src/MessageSerializer.php
+++ b/src/SendIt/src/MessageSerializer.php
@@ -11,17 +11,11 @@ declare(strict_types=1);
 
 namespace Spiral\SendIt;
 
-use Spiral\Jobs\SerializerInterface;
 use Spiral\Mailer\Message;
 use Spiral\Mailer\MessageInterface;
 
-final class MessageSerializer implements SerializerInterface
+final class MessageSerializer
 {
-    public function serialize(string $jobType, array $payload): string
-    {
-        return json_encode($payload);
-    }
-
     public static function pack(MessageInterface $message): array
     {
         return [


Test patch:
diff --git a/src/SendIt/tests/JsonJobSerializerTest.php b/src/SendIt/tests/JsonJobSerializerTest.php
new file mode 100644
index 000000000..5b2b6bd06
--- /dev/null
+++ b/src/SendIt/tests/JsonJobSerializerTest.php
@@ -0,0 +1,18 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Spiral\Tests\SendIt;
+
+use PHPUnit\Framework\TestCase;
+use Spiral\SendIt\JsonJobSerializer;
+
+final class JsonJobSerializerTest extends TestCase
+{
+    public function testSerialize(): void
+    {
+        $data = ['foo' => 'bar'];
+
+        $this->assertSame('{"foo":"bar"}', (new JsonJobSerializer())->serialize('baz', $data));
+    }
+}