Skip to content

[Mime] Remove @internal from Headers methods #40576

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
Mar 31, 2021

Conversation

VincentLanglet
Copy link
Contributor

Q A
Branch? 4.4
Bug fix? no
New feature? no
Deprecations? no
Tickets Fix #...
License MIT
Doc PR symfony/symfony-docs#...

I don't understand why the methods

  • Headers::getHeaderBody()
  • Headers::setHeaderBody()
  • Headers::getHeaderParameter()
  • Headers::setHeaderParameter()
    are marked as internal.

They are already used by others libraries, like
https://github.com/symfony/mailchimp-mailer/blob/a6c3fa9aeaf83ad79445c9e7c072e15288bea3c9/Transport/MandrillApiTransport.php#L92
https://github.com/symfony/mailchimp-mailer/blob/a6c3fa9aeaf83ad79445c9e7c072e15288bea3c9/Transport/MandrillApiTransport.php#L99

The implementation shouldn't change so they could be under the BC promise.
Plus they are useful, and I don't see any other way that reimplementing the method if we want to do something like

->getHeaderParameter('Content-Disposition', 'name')

@carsonbot carsonbot added this to the 4.4 milestone Mar 24, 2021
@derrabus derrabus added the Mime label Mar 25, 2021
@carsonbot carsonbot changed the title Remove @internal from Headers methods [Mime] Remove @internal from Headers methods Mar 25, 2021
@Nyholm
Copy link
Member

Nyholm commented Mar 25, 2021

Could you elaborate why you want them to be not internal? What is your scenario where these methods are the only solution?

@VincentLanglet
Copy link
Contributor Author

Sure,

I followed the recommendation #40056 (comment) and implemented my own mailchimp mailer with more configuration options.
It implied that I have some code similar with the official symfony/mailchimp-mailer.

When I create the payload, it requires at least the same data than the one symfony is building in https://github.com/symfony/mailchimp-mailer/blob/a6c3fa9aeaf83ad79445c9e7c072e15288bea3c9/Transport/MandrillApiTransport.php#L73
And in this method, two internals method are used by symfony
https://github.com/symfony/mailchimp-mailer/blob/a6c3fa9aeaf83ad79445c9e7c072e15288bea3c9/Transport/MandrillApiTransport.php#L92-L99

If I want to reproduce the same behavior, I don't have any other options to get the Content-Disposition.

@Nyholm
Copy link
Member

Nyholm commented Mar 25, 2021

Thank you. I appreciate the context.

I don't think this is a bug fix. It is a feature that we are making methods non-internal. Ie we should target 5.x.

I'll wait for a review from someone with better understanding of the Mime component.

@Nyholm Nyholm added the Feature label Mar 25, 2021
@Nyholm Nyholm modified the milestones: 4.4, 5.x Mar 25, 2021
@OskarStark
Copy link
Contributor

I agree, but I would go to merge this as a bugfix, because it just removes an annotation and opens sth instead of closing.

👍 for a bugfix

@Nyholm
Copy link
Member

Nyholm commented Mar 25, 2021

I consider this the same as making a private function public. Ie, we add a new function to the public API, hence a feature.

But Im not sure how we usually do in scenarios like this.

@VincentLanglet
Copy link
Contributor Author

The code in the 4.4 branch and the 5.x one for these internal methods are the same, so it won't hurt to merge it on 4.4.
It can fix some static analysis issues, like psalm reporting the usage of an internal method.

But I understand if you prefer to merge this on 5.x, I'll just ignore the error until the next version. Not a big deal.

@OskarStark
Copy link
Contributor

friendly ping @nicolas-grekas for a decision 😍

@nicolas-grekas
Copy link
Member

That's a new feature for sure: it will deserve dedicated changlog line + tests + doc.

@ro0NL
Copy link
Contributor

ro0NL commented Mar 25, 2021

IIUC the intended public API is has() and get()

edit: oh Headers has zero inheritance 👍 i agree this API is less boring.

@stof
Copy link
Member

stof commented Mar 25, 2021

For instance, the setHeaderBody method does not properly validate the value for $type before calling the method with the name built dynamically based on the type. That's not really suitable as a non-internal method (for an internal method, it can be considered our own responsibility to use it only with valid values for the type, so skipping validation).

@VincentLanglet
Copy link
Contributor Author

For instance, the setHeaderBody method does not properly validate the value for $type before calling the method with the name built dynamically based on the type. That's not really suitable as a non-internal method (for an internal method, it can be considered our own responsibility to use it only with valid values for the type, so skipping validation).

What about keeping the setter as internal, but not the getters ?

@VincentLanglet
Copy link
Contributor Author

PR was updated to only remove @internal on the getters.

UPGRADE-5.3.md Outdated
Mime
----

* Remove internal annotation to the method `getHeaderBody` and `getHeaderParameter`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] from the [...]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a second to that should be replaced with from :)

Copy link
Member

@xabbuh xabbuh Mar 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe reword it like this:

Remove the internal annotation from the getHeaderBody() and getHeaderParameter() methods of the Headers class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@VincentLanglet VincentLanglet force-pushed the removeInternal branch 2 times, most recently from ac1946a to 7eacdf7 Compare March 28, 2021 17:13
@fabpot
Copy link
Member

fabpot commented Mar 31, 2021

Thank you @VincentLanglet.

@fabpot fabpot merged commit f615903 into symfony:5.x Mar 31, 2021
@VincentLanglet VincentLanglet deleted the removeInternal branch March 31, 2021 12:32
@fabpot fabpot mentioned this pull request Apr 18, 2021
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.

10 participants