8000 [Mime] Remove @internal annotations for the serialize methods by francoispluchino · Pull Request #32302 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Mime] Remove @internal annotations for the serialize methods #32302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2019
Merged

[Mime] Remove @internal annotations for the serialize methods #32302

merged 1 commit into from
Jul 3, 2019

Conversation

francoispluchino
Copy link
Contributor
Q A
Branch? 4.3
Bug fix? yes (it's not really a bug)
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets ~
License MIT
Doc PR ~

Currently, when we extend the Symfony\Component\Mime\Message and Symfony\Component\Mime\MessageRaw classes of the Mime component, we get 2 deprecation messages:

The "Symfony\Component\Mime\Message::__serialize()" method is considered internal. It may change without further notice. You should not extend it from "Vendor\FooMessage".

and

The "Symfony\Component\Mime\Message::__unserialize()" method is considered internal. It may change without further notice. You should not extend it from "Vendor\FooMessage".

However, we need to add properties to the new class, and so, we need to extend __serialize() and __unserialize() methods in the same way as Symfony\Bridge\Twig\Mime\TemplatedEmail, to know, retrieve the serialization of the parent class:

    public function __serialize(): array
    {
        return [$this->foo, $this->bar, $this->baz, parent::__serialize()];
    }

    public function __unserialize(array $data): void
    {
        [$this->foo, $this->bar, $this->baz, $parentData] = $data;

        parent::__unserialize($parentData);
    }

But given that the third-party components use another namespace, we get the 2 deprecation messages, while the 2 methods must be inevitably used and extended. Of course, the methods serialize() and unserialize() are always marked by the @internal annotation and the final keyword.

This PR so deletes the 2 deprecation messages that should not be displayed.

@nicolas-grekas nicolas-grekas added this to the next milestone Jul 3, 2019
@nicolas-grekas nicolas-grekas changed the title [Mime] Remove @internal annotations for the serilize methods [Mime] Remove @internal annotations for the serialize methods Jul 3, 2019
@fabpot
Copy link
Member
fabpot commented Jul 3, 2019

Thank you @francoispluchino.

@fabpot fabpot merged commit 8544a35 into symfony:4.3 Jul 3, 2019
fabpot added a commit that referenced this pull request Jul 3, 2019
…ods (francoispluchino)

This PR was merged into the 4.3 branch.

Discussion
----------

[Mime] Remove @internal annotations for the serialize methods

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes (it's not really a bug)
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

Currently, when we extend the `Symfony\Component\Mime\Message` and `Symfony\Component\Mime\MessageRaw` classes of the Mime component, we get 2 deprecation messages:

```
The "Symfony\Component\Mime\Message::__serialize()" method is considered internal. It may change without further notice. You should not extend it from "Vendor\FooMessage".
```
and
```
The "Symfony\Component\Mime\Message::__unserialize()" method is considered internal. It may change without further notice. You should not extend it from "Vendor\FooMessage".
```

However, we need to add properties to the new class, and so, we need to extend `__serialize()` and `__unserialize()` methods in the same way as `Symfony\Bridge\Twig\Mime\TemplatedEmail`, to know, retrieve the serialization of the parent class:

```php
    public function __serialize(): array
    {
        return [$this->foo, $this->bar, $this->baz, parent::__serialize()];
    }

    public function __unserialize(array $data): void
    {
        [$this->foo, $this->bar, $this->baz, $parentData] = $data;

        parent::__unserialize($parentData);
    }
```

But given that the third-party components use another namespace, we get the 2 deprecation messages, while the 2 methods must be inevitably used and extended. Of course, the methods `serialize()` and `unserialize()` are always marked by the `@internal` annotation and the `final` keyword.

This PR so deletes the 2 deprecation messages that should not be displayed.

Commits
-------

8544a35 Remove @internal annotations for the serilize methods
@francoispluchino
Copy link
Contributor Author

@fabpot @nicolas-grekas Thank you.

@fabpot fabpot mentioned this pull request Jul 28, 2019
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0