Skip to content

Commit 90ba2b2

Browse files
committed
Actually throw if it is required regardless
1 parent 0aae141 commit 90ba2b2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/Resolver.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,10 @@ public function resolve(array $config): array
126126
$config = array_merge($this->defaults, $config);
127127

128128
if ($diff = array_diff($this->required, array_keys($config))) {
129-
$this->throwOrLogError(new InvalidMap(sprintf(
129+
throw new InvalidMap(sprintf(
130130
'Key(s) "%s" are required',
131131
implode('", "', $diff)
132-
)));
133-
$config = $this->removeKeys($config, $diff);
132+
));
134133
}
135134

136135
foreach ($config as $key => $value) {
@@ -149,12 +148,12 @@ public function resolve(array $config): array
149148
}
150149

151150
if (false === $valid) {
152-
$this->throwOrLogError(new InvalidMap(sprintf(
151+
throw new InvalidMap(sprintf(
153152
'Type for "%s" expected to be "%s", got "%s"',
154153
$key,
155154
$this->types[$key],
156155
$type
157-
)));
156+
));
158157
}
159158
}
160159
}
@@ -234,4 +233,12 @@ private function removeKeys(array $config, array $keys): array
234233

235234
return $config;
236235
}
236+
237+
/**
238+
* @return InvalidMap[]
239+
*/
240+
public function errors(): array
241+
{
242+
return $this->errors;
243+
}
237244
}

tests/Unit/ResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function testIgnoresUnknownKey(): void
4545
'one' => 1,
4646
'two' => 2
4747
]);
48+
self::assertCount(1, $resolver->errors());
4849
}
4950

5051
public function testMergesDefaults(): void

0 commit comments

Comments
 (0)