Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3b7af3a

Browse files
committed
deprecate HeaderBag::get and fix tests and dependencies
1 parent fad5ccb commit 3b7af3a

File tree

71 files changed

+361
-343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+361
-343
lines changed

src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function onKernelResponse(FilterResponseEvent $event)
4040
return;
4141
}
4242

43-
if (!preg_match(static::USER_AGENT_REGEX, $event->getRequest()->headers->get('User-Agent'))) {
43+
if (!preg_match(static::USER_AGENT_REGEX, $event->getRequest()->headers->getValue('User-Agent'))) {
4444
$this->sendHeaders = false;
4545
$this->headers = [];
4646

src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function onKernelResponse(FilterResponseEvent $event)
4141
}
4242

4343
$request = $event->getRequest();
44-
if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->get('User-Agent'))
44+
if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->getValue('User-Agent'))
4545
&& !$request->headers->has('X-FirePHP-Version')) {
4646
self::$sendHeaders = false;
4747
$this->headers = [];

src/Symfony/Bridge/Monolog/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"conflict": {
3030
"symfony/console": "<3.4",
31-
"symfony/http-foundation": "<3.4"
31+
"symfony/http-foundation": "<4.4"
3232
},
3333
"suggest": {
3434
"symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.",

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ public function testFile()
186186
$response = $controller->file(new File(__FILE__));
187187
$this->assertInstanceOf(BinaryFileResponse::class, $response);
188188
$this->assertSame(200, $response->getStatusCode());
189-
if ($response->headers->get('content-type')) {
190-
$this->assertSame('text/x-php', $response->headers->get('content-type'));
189+
if ($response->headers->getValue('content-type')) {
190+
$this->assertSame('text/x-php', $response->headers->getValue('content-type'));
191191
}
192-
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
193-
$this->assertContains(basename(__FILE__), $response->headers->get('content-disposition'));
192+
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->getValue('content-disposition'));
193+
$this->assertContains(basename(__FILE__), $response->headers->getValue('content-disposition'));
194194
}
195195

196196
public function testFileAsInline()
@@ -202,11 +202,11 @@ public function testFileAsInline()
202202

203203
$this->assertInstanceOf(BinaryFileResponse::class, $response);
204204
$this->assertSame(200, $response->getStatusCode());
205-
if ($response->headers->get('content-type')) {
206-
$this->assertSame('text/x-php', $response->headers->get('content-type'));
205+
if ($response->headers->getValue('content-type')) {
206+
$this->assertSame('text/x-php', $response->headers->getValue('content-type'));
207207
}
208-
$this->assertContains(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition'));
209-
$this->assertContains(basename(__FILE__), $response->headers->get('content-disposition'));
208+
$this->assertContains(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->getValue('content-disposition'));
209+
$this->assertContains(basename(__FILE__), $response->headers->getValue('content-disposition'));
210210
}
211211

212212
public function testFileWithOwnFileName()
@@ -219,11 +219,11 @@ public function testFileWithOwnFileName()
219219

220220
$this->assertInstanceOf(BinaryFileResponse::class, $response);
221221
$this->assertSame(200, $response->getStatusCode());
222-
if ($response->headers->get('content-type')) {
223-
$this->assertSame('text/x-php', $response->headers->get('content-type'));
222+
if ($response->headers->getValue('content-type')) {
223+
$this->assertSame('text/x-php', $response->headers->getValue('content-type'));
224224
}
225-
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
226-
$this->assertContains($fileName, $response->headers->get('content-disposition'));
225+
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->getValue('content-disposition'));
226+
$this->assertContains($fileName, $response->headers->getValue('content-disposition'));
227227
}
228228

229229
public function testFileWithOwnFileNameAsInline()
@@ -236,11 +236,11 @@ public function testFileWithOwnFileNameAsInline()
236236

237237
$this->assertInstanceOf(BinaryFileResponse::class, $response);
238238
$this->assertSame(200, $response->getStatusCode());
239-
if ($response->headers->get('content-type')) {
240-
$this->assertSame('text/x-php', $response->headers->get('content-type'));
239+
if ($response->headers->getValue('content-type')) {
240+
$this->assertSame('text/x-php', $response->headers->getValue('content-type'));
241241
}
242-
$this->assertContains(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition'));
243-
$this->assertContains($fileName, $response->headers->get('content-disposition'));
242+
$this->assertContains(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->getValue('content-disposition'));
243+
$this->assertContains($fileName, $response->headers->getValue('content-disposition'));
244244
}
245245

246246
public function testFileFromPath()
@@ -252,11 +252,11 @@ public function testFileFromPath()
252252

253253
$this->assertInstanceOf(BinaryFileResponse::class, $response);
254254
$this->assertSame(200, $response->getStatusCode());
255-
if ($response->headers->get('content-type')) {
256-
$this->assertSame('text/x-php', $response->headers->get('content-type'));
255+
if ($response->headers->getValue('content-type')) {
256+
$this->assertSame('text/x-php', $response->headers->getValue('content-type'));
257257
}
258-
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
259-
$this->assertContains(basename(__FILE__), $response->headers->get('content-disposition'));
258+
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->getValue('content-disposition'));
259+
$this->assertContains(basename(__FILE__), $response->headers->getValue('content-disposition'));
260260
}
261261

262262
public function testFileFromPathWithCustomizedFileName()
@@ -268,11 +268,11 @@ public function testFileFromPathWithCustomizedFileName()
268268

269269
$this->assertInstanceOf(BinaryFileResponse::class, $response);
270270
$this->assertSame(200, $response->getStatusCode());
271-
if ($response->headers->get('content-type')) {
272-
$this->assertSame('text/x-php', $response->headers->get('content-type'));
271+
if ($response->headers->getValue('content-type')) {
272+
$this->assertSame('text/x-php', $response->headers->getValue('content-type'));
273273
}
274-
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
275-
$this->assertContains('test.php', $response->headers->get('content-disposition'));
274+
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->getValue('content-disposition'));
275+
$this->assertContains('test.php', $response->headers->getValue('content-disposition'));
276276
}
277277

278278
/**

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,6 @@ private function createRedirectController($httpPort = null, $httpsPort = null)
304304

305305
private function assertRedirectUrl(Response $returnResponse, $expectedUrl)
306306
{
307-
$this->assertTrue($returnResponse->isRedirect($expectedUrl), "Expected: $expectedUrl\nGot: ".$returnResponse->headers->get('Location'));
307+
$this->assertTrue($returnResponse->isRedirect($expectedUrl), "Expected: $expectedUrl\nGot: ".$returnResponse->headers->getValue('Location'));
308308
}
309309
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function testCorrectCacheControlHeadersForCacheableAction($config, $insul
139139
$client->request('GET', '/cacheable');
140140

141141
$response = $client->getResponse();
142-
$this->assertSame('public, s-maxage=100', $response->headers->get('cache-control'));
142+
$this->assertSame('public, s-maxage=100', $response->headers->getValue('cache-control'));
143143
}
144144

145145
public function getConfigs()

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/WebTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class WebTestCase extends BaseWebTestCase
1919
public static function assertRedirect($response, $location)
2020
{
2121
self::assertTrue($response->isRedirect(), 'Response is not a redirect, got status code: '.$response->getStatusCode());
22-
self::assertEquals('http://localhost'.$location, $response->headers->get('Location'));
22+
self::assertEquals('http://localhost'.$location, $response->headers->getValue('Location'));
2323
}
2424

2525
public static function setUpBeforeClass()

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"symfony/cache": "^4.3|^5.0",
2222
"symfony/config": "^4.2|^5.0",
2323
"symfony/dependency-injection": "^4.4|^5.0",
24-
"symfony/http-foundation": "^4.3|^5.0",
24+
"symfony/http-foundation": "^4.4|^5.0",
2525
"symfony/http-kernel": "^4.3|^5.0",
2626
"symfony/polyfill-mbstring": "~1.0",
2727
"symfony/filesystem": "^3.4|^4.0|^5.0",
@@ -79,7 +79,8 @@
7979
"symfony/translation": "<4.3",
8080
"symfony/twig-bridge": "<4.1.1",
8181
"symfony/validator": "<4.1",
82-
"symfony/workflow": "<4.3"
82+
"symfony/workflow": "<4.3",
83+
"symfony/http-foundation": "<4.4"
8384
},
8485
"suggest": {
8586
"ext-apcu": "For best performance of the system caches",

src/Symfony/Bundle/SecurityBundle/Tests/Functional/JsonLoginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testDefaultJsonLoginBadRequest()
6969
$response = $client->getResponse();
7070

7171
$this->assertSame(400, $response->getStatusCode());
72-
$this->assertSame('application/json', $response->headers->get('Content-Type'));
72+
$this->assertSame('application/json', $response->headers->getValue('Content-Type'));
7373
$this->assertArraySubset(['error' => ['code' => 400, 'message' => 'Bad Request']], json_decode($response->getContent(), true));
7474
}
7575
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/WebTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class WebTestCase extends BaseWebTestCase
1919
public static function assertRedirect($response, $location)
2020
{
2121
self::assertTrue($response->isRedirect(), 'Response is not a redirect, got status code: '.substr($response, 0, 2000));
22-
self::assertEquals('http://localhost'.$location, $response->headers->get('Location'));
22+
self::assertEquals('http://localhost'.$location, $response->headers->getValue('Location'));
2323
}
2424

2525
public static function setUpBeforeClass()

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/StandardFormLogin/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ security:
4444
- { path: ^/secured-by-one-real-ip-with-mask$, ips: '203.0.113.0/24', roles: IS_AUTHENTICATED_ANONYMOUSLY }
4545
- { path: ^/secured-by-one-real-ipv6$, ips: 0:0:0:0:0:ffff:c633:6400, roles: IS_AUTHENTICATED_ANONYMOUSLY }
4646
- { path: ^/highly_protected_resource$, roles: IS_ADMIN }
47-
- { path: ^/protected-via-expression$, allow_if: "(is_anonymous() and request.headers.get('user-agent') matches '/Firefox/i') or is_granted('ROLE_USER')" }
47+
- { path: ^/protected-via-expression$, allow_if: "(is_anonymous() and request.headers.getValue('user-agent') matches '/Firefox/i') or is_granted('ROLE_USER')" }
4848
- { path: .*, roles: IS_AUTHENTICATED_FULLY }

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"symfony/dom-crawler": "^3.4|^4.0|^5.0",
3535
"symfony/form": "^3.4|^4.0|^5.0",
3636
"symfony/framework-bundle": "^4.2|^5.0",
37-
"symfony/http-foundation": "^3.4|^4.0|^5.0",
37+
"symfony/http-foundation": "^4.4|^5.0",
3838
"symfony/translation": "^3.4|^4.0|^5.0",
3939
"symfony/twig-bundle": "^4.2|^5.0",
4040
"symfony/twig-bridge": "^3.4|^4.0|^5.0",

src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct(Environment $twig, bool $debug)
5454
*/
5555
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
5656
{
57-
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
57+
$currentContent = $this->getAndCleanOutputBuffering($request->headers->getValue('X-Php-Ob-Level', -1));
5858
$showException = $request->attributes->get('showException', $this->debug); // As opposed to an additional parameter, this maintains BC
5959

6060
$code = $exception->getStatusCode();

src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testResponseHasRequestedMimeType()
7373
$response = $controller->showAction($request, $exception);
7474

7575
$this->assertEquals('json', $request->getRequestFormat());
76-
$this->assertEquals($request->getMimeType('json'), $response->headers->get('Content-Type'));
76+
$this->assertEquals($request->getMimeType('json'), $response->headers->getValue('Content-Type'));
7777
}
7878

7979
private function createRequest($requestFormat)

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": "^7.1.3",
2020
"symfony/config": "^4.2|^5.0",
2121
"symfony/twig-bridge": "^4.4|^5.0",
22-
"symfony/http-foundation": "^4.3|^5.0",
22+
"symfony/http-foundation": "^4.4|^5.0",
2323
"symfony/http-kernel": "^4.1|^5.0",
2424
"symfony/polyfill-ctype": "~1.8",
2525
"twig/twig": "~1.41|~2.10"
@@ -43,7 +43,9 @@
4343
"conflict": {
4444
"symfony/dependency-injection": "<4.1",
4545
"symfony/framework-bundle": "<4.3",
46-
"symfony/translation": "<4.2"
46+
"symfony/translation": "<4.2",
47+
"symfony/http-foundation": "<4.4"
48+
4749
},
4850
"autoload": {
4951
"psr-4": { "Symfony\\Bundle\\TwigBundle\\": "" },

src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public function getNonces(Request $request, Response $response)
4545
{
4646
if ($request->headers->has('X-SymfonyProfiler-Script-Nonce') && $request->headers->has('X-SymfonyProfiler-Style-Nonce')) {
4747
return [
48-
'csp_script_nonce' => $request->headers->get('X-SymfonyProfiler-Script-Nonce'),
49-
'csp_style_nonce' => $request->headers->get('X-SymfonyProfiler-Style-Nonce'),
48+
'csp_script_nonce' => $request->headers->getValue('X-SymfonyProfiler-Script-Nonce'),
49+
'csp_style_nonce' => $request->headers->getValue('X-SymfonyProfiler-Style-Nonce'),
5050
];
5151
}
5252

5353
if ($response->headers->has('X-SymfonyProfiler-Script-Nonce') && $response->headers->has('X-SymfonyProfiler-Style-Nonce')) {
5454
return [
55-
'csp_script_nonce' => $response->headers->get('X-SymfonyProfiler-Script-Nonce'),
56-
'csp_style_nonce' => $response->headers->get('X-SymfonyProfiler-Style-Nonce'),
55+
'csp_script_nonce' => $response->headers->getValue('X-SymfonyProfiler-Script-Nonce'),
56+
'csp_style_nonce' => $response->headers->getValue('X-SymfonyProfiler-Style-Nonce'),
5757
];
5858
}
5959

@@ -255,15 +255,15 @@ private function getCspHeaders(Response $response)
255255
$headers = [];
256256

257257
if ($response->headers->has('Content-Security-Policy')) {
258-
$headers['Content-Security-Policy'] = $this->parseDirectives($response->headers->get('Content-Security-Policy'));
258+
$headers['Content-Security-Policy'] = $this->parseDirectives($response->headers->getValue('Content-Security-Policy'));
259259
}
260260

261261
if ($response->headers->has('Content-Security-Policy-Report-Only')) {
262-
$headers['Content-Security-Policy-Report-Only'] = $this->parseDirectives($response->headers->get('Content-Security-Policy-Report-Only'));
262+
$headers['Content-Security-Policy-Report-Only'] = $this->parseDirectives($response->headers->getValue('Content-Security-Policy-Report-Only'));
263263
}
264264

265265
if ($response->headers->has('X-Content-Security-Policy')) {
266-
$headers['X-Content-Security-Policy'] = $this->parseDirectives($response->headers->get('X-Content-Security-Policy'));
266+
$headers['X-Content-Security-Policy'] = $this->parseDirectives($response->headers->getValue('X-Content-Security-Policy'));
267267
}
268268

269269
return $headers;

src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function onKernelResponse(FilterResponseEvent $event)
6969
try {
7070
$response->headers->set(
7171
'X-Debug-Token-Link',
72-
$this->urlGenerator->generate('_profiler', ['token' => $response->headers->get('X-Debug-Token')], UrlGeneratorInterface::ABSOLUTE_URL)
72+
$this->urlGenerator->generate('_profiler', ['token' => $response->headers->getValue('X-Debug-Token')], UrlGeneratorInterface::ABSOLUTE_URL)
7373
);
7474
} catch (\Exception $e) {
7575
$response->headers->set('X-Debug-Error', \get_class($e).': '.preg_replace('/\s+/', ' ', $e->getMessage()));
@@ -94,17 +94,17 @@ public function onKernelResponse(FilterResponseEvent $event)
9494
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
9595
}
9696

97-
$response->setContent($this->twig->render('@WebProfiler/Profiler/toolbar_redirect.html.twig', ['location' => $response->headers->get('Location')]));
97+
$response->setContent($this->twig->render('@WebProfiler/Profiler/toolbar_redirect.html.twig', ['location' => $response->headers->getValue('Location')]));
9898
$response->setStatusCode(200);
9999
$response->headers->remove('Location');
100100
}
101101

102102
if (self::DISABLED === $this->mode
103103
|| !$response->headers->has('X-Debug-Token')
104104
|| $response->isRedirection()
105-
|| ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
105+
|| ($response->headers->has('Content-Type') && false === strpos($response->headers->getValue('Content-Type'), 'html'))
106106
|| 'html' !== $request->getRequestFormat()
107-
|| false !== stripos($response->headers->get('Content-Disposition'), 'attachment;')
107+
|| false !== stripos($response->headers->getValue('Content-Disposition'), 'attachment;')
108108
) {
109109
return;
110110
}
@@ -125,7 +125,7 @@ protected function injectToolbar(Response $response, Request $request, array $no
125125
'@WebProfiler/Profiler/toolbar_js.html.twig',
126126
[
127127
'excluded_ajax_paths' => $this->excludedAjaxPaths,
128-
'token' => $response->headers->get('X-Debug-Token'),
128+
'token' => $response->headers->getValue('X-Debug-Token'),
129129
'request' => $request,
130130
'csp_script_nonce' => isset($nonces['csp_script_nonce']) ? $nonces['csp_script_nonce'] : null,
131131
'csp_style_nonce' => isset($nonces['csp_style_nonce']) ? $nonces['csp_style_nonce'] : null,

src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testOnKernelResponse($nonce, $expectedNonce, Request $request, R
4141
$this->assertFalse($response->headers->has('X-SymfonyProfiler-Style-Nonce'));
4242

4343
foreach ($expectedCsp as $header => $value) {
44-
$this->assertSame($value, $response->headers->get($header));
44+
$this->assertSame($value, $response->headers->getValue($header));
4545
}
4646
}
4747

0 commit comments

Comments
 (0)