Skip to content

Commit 22e0713

Browse files
committed
No need to validate anymore with typed properties
1 parent 9d32c50 commit 22e0713

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

src/CorsService.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,9 @@ public function setOptions(array $options): void
8888
$exposedHeaders = $options['exposedHeaders'] ?? $options['exposed_headers'] ?? $this->exposedHeaders;
8989
$this->exposedHeaders = $exposedHeaders === false ? [] : $exposedHeaders;
9090

91-
$this->validateOptions();
9291
$this->normalizeOptions();
9392
}
9493

95-
private function validateOptions(): void
96-
{
97-
$arrayHeaders = [
98-
'allowedOrigins',
99-
'allowedOriginsPatterns',
100-
'allowedHeaders',
101-
'allowedMethods',
102-
'exposedHeaders',
103-
];
104-
foreach ($arrayHeaders as $key) {
105-
if (!is_array($this->{$key})) {
106-
throw new InvalidOptionException("CORS option `{$key}` should be an array");
107-
}
108-
}
109-
}
110-
11194
private function normalizeOptions(): void
11295
{
11396
// Normalize case

tests/CorsServiceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function itAllowsZeroMaxAge(): void
201201
*/
202202
public function itThrowsExceptionOnInvalidExposedHeaders(): void
203203
{
204-
$this->expectException(InvalidOptionException::class);
204+
$this->expectException(\TypeError::class);
205205

206206
/** @phpstan-ignore-next-line */
207207
$service = new CorsService(['exposedHeaders' => true]);
@@ -212,7 +212,7 @@ public function itThrowsExceptionOnInvalidExposedHeaders(): void
212212
*/
213213
public function itThrowsExceptionOnInvalidOriginsArray(): void
214214
{
215-
$this->expectException(InvalidOptionException::class);
215+
$this->expectException(\TypeError::class);
216216

217217
/** @phpstan-ignore-next-line */
218218
$service = new CorsService(['allowedOrigins' => 'string']);

0 commit comments

Comments
 (0)