Skip to content

Commit f12daab

Browse files
committed
style(routing): Fix PHPCS errors
1 parent 2376520 commit f12daab

2 files changed

Lines changed: 34 additions & 20 deletions

File tree

src/Routing/QueryRouteEnhancer.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function assertValidPostRequestHeaders(Request $request) : void {
9292
return;
9393
}
9494

95-
/** @phpstan-ignore-next-line */
95+
// @phpstan-ignore-next-line
9696
$content_format = method_exists($request, 'getContentTypeFormat') ? $request->getContentTypeFormat() : $request->getContentType();
9797
if ($content_format === NULL) {
9898
// Symfony before 5.4 does not detect "multipart/form-data", check for it
@@ -116,7 +116,11 @@ protected function assertValidPostRequestHeaders(Request $request) : void {
116116
if ($content_format === "form") {
117117
// If the client set a custom header then we can be sure CORS was
118118
// respected.
119-
$custom_headers = ['Apollo-Require-Preflight', 'X-Apollo-Operation-Name', 'x-graphql-yoga-csrf'];
119+
$custom_headers = [
120+
'Apollo-Require-Preflight',
121+
'X-Apollo-Operation-Name',
122+
'x-graphql-yoga-csrf',
123+
];
120124
foreach ($custom_headers as $custom_header) {
121125
if ($request->headers->has($custom_header)) {
122126
return;
@@ -133,7 +137,7 @@ protected function assertValidPostRequestHeaders(Request $request) : void {
133137
if (!empty($this->corsOptions['enabled'])) {
134138
$cors_service = new CorsService($this->corsOptions);
135139
// Drupal 9 compatibility, method name has changed in Drupal 10.
136-
/** @phpstan-ignore-next-line */
140+
// @phpstan-ignore-next-line
137141
if ($cors_service->isActualRequestAllowed($request)) {
138142
return;
139143
}

tests/src/Kernel/Framework/CsrfTest.php

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,36 @@ public function provideAllowedFormRequests(): array {
155155
[['CONTENT_TYPE' => 'multipart/form-data']],
156156
// The custom Apollo-Require-Preflight header overrules any evil Origin
157157
// header.
158-
[[
159-
'CONTENT_TYPE' => 'multipart/form-data',
160-
'HTTP_APOLLO_REQUIRE_PREFLIGHT' => 'test',
161-
'HTTP_ORIGIN' => 'https://evil.example.com',
162-
]],
158+
[
159+
[
160+
'CONTENT_TYPE' => 'multipart/form-data',
161+
'HTTP_APOLLO_REQUIRE_PREFLIGHT' => 'test',
162+
'HTTP_ORIGIN' => 'https://evil.example.com',
163+
],
164+
],
163165
// The Origin header alone with the correct domain is allowed.
164-
[[
165-
'CONTENT_TYPE' => 'multipart/form-data',
166-
'HTTP_ORIGIN' => 'https://example.com',
167-
]],
166+
[
167+
[
168+
'CONTENT_TYPE' => 'multipart/form-data',
169+
'HTTP_ORIGIN' => 'https://example.com',
170+
],
171+
],
168172
// The Origin header with an allowed domain.
169-
[[
170-
'CONTENT_TYPE' => 'multipart/form-data',
171-
'HTTP_ORIGIN' => 'https://allowed.example.com',
172-
], ['https://allowed.example.com']],
173+
[
174+
[
175+
'CONTENT_TYPE' => 'multipart/form-data',
176+
'HTTP_ORIGIN' => 'https://allowed.example.com',
177+
],
178+
['https://allowed.example.com'],
179+
],
173180
// The Origin header with any allowed domain.
174-
[[
175-
'CONTENT_TYPE' => 'multipart/form-data',
176-
'HTTP_ORIGIN' => 'https://allowed.example.com',
177-
], ['*']],
181+
[
182+
[
183+
'CONTENT_TYPE' => 'multipart/form-data',
184+
'HTTP_ORIGIN' => 'https://allowed.example.com',
185+
],
186+
['*'],
187+
],
178188
];
179189
}
180190

0 commit comments

Comments
 (0)