Skip to content

Commit f615903

Browse files
committed
feature #40576 [Mime] Remove @internal from Headers methods (VincentLanglet)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Mime] Remove @internal from Headers methods | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too.) - Features and deprecations must be submitted against branch 5.x. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry --> 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') ``` Commits ------- 592fb13 Remove internal annotation
2 parents 2f20156 + 592fb13 commit f615903

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

UPGRADE-5.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ Messenger
6161
* Deprecated the `prefetch_count` parameter in the AMQP bridge, it has no effect and will be removed in Symfony 6.0
6262
* Deprecated the use of TLS option for Redis Bridge, use `rediss://127.0.0.1` instead of `redis://127.0.0.1?tls=1`
6363

64+
Mime
65+
----
66+
67+
* Remove the internal annotation from the `getHeaderBody()` and `getHeaderParameter()` methods of the `Headers` class.
68+
6469
Notifier
6570
--------
6671

src/Symfony/Component/Mime/Header/Headers.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,6 @@ public function toArray(): array
254254
return $arr;
255255
}
256256

257-
/**
258-
* @internal
259-
*/
260257
public function getHeaderBody($name)
261258
{
262259
return $this->has($name) ? $this->get($name)->getBody() : null;
@@ -274,9 +271,6 @@ public function setHeaderBody(string $type, string $name, $body): void
274271
}
275272
}
276273

277-
/**
278-
* @internal
279-
*/
280274
public function getHeaderParameter(string $name, string $parameter): ?string
281275
{
282276
if (!$this->has($name)) {

src/Symfony/Component/Mime/Tests/Header/HeadersTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,39 @@ public function testToArray()
279279
"Foo: =?utf-8?Q?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?=\r\n =?utf-8?Q?aaaa?=",
280280
], $headers->toArray());
281281
}
282+
283+
public function testHeaderBody()
284+
{
285+
$headers = new Headers();
286+
$this->assertNull($headers->getHeaderBody('Content-Type'));
287+
$headers->setHeaderBody('Text', 'Content-Type', 'type');
288+
$this->assertSame('type', $headers->getHeaderBody('Content-Type'));
289+
}
290+
291+
public function testHeaderParameter()
292+
{
293+
$headers = new Headers();
294+
$this->assertNull($headers->getHeaderParameter('Content-Disposition', 'name'));
295+
296+
$headers->addParameterizedHeader('Content-Disposition', 'name');
297+
$headers->setHeaderParameter('Content-Disposition', 'name', 'foo');
298+
$this->assertSame('foo', $headers->getHeaderParameter('Content-Disposition', 'name'));
299+
}
300+
301+
public function testHeaderParameterNotDefined()
302+
{
303+
$headers = new Headers();
304+
305+
$this->expectException(\LogicException::class);
306+
$headers->setHeaderParameter('Content-Disposition', 'name', 'foo');
307+
}
308+
309+
public function testSetHeaderParameterNotParameterized()
310+
{
311+
$headers = new Headers();
312+
$headers->addTextHeader('Content-Disposition', 'name');
313+
314+
$this->expectException(\LogicException::class);
315+
$headers->setHeaderParameter('Content-Disposition', 'name', 'foo');
316+
}
282317
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy