Skip to content

Commit 7569745

Browse files
committed
Update type hints
1 parent 90ba2b2 commit 7569745

File tree

3 files changed

+53
-19
lines changed

3 files changed

+53
-19
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"integrate": [
4141
"./vendor/bin/phpunit",
4242
"./vendor/bin/phpstan analyze",
43-
"./vendor/bin/php-cs-fixer fix"
43+
"./vendor/bin/php-cs-fixer fix --allow-risky=yes"
4444
]
4545
}
46-
}
46+
}

lib/Resolver.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,6 @@ public function merge(Resolver $schema): Resolver
190190
return $this;
191191
}
192192

193-
/**
194-
* @return array<string>
195-
*/
196-
private function resolveAllowedKeys(): array
197-
{
198-
$allowedKeys = array_merge(array_keys($this->defaults), $this->required);
199-
return $allowedKeys;
200-
}
201-
202193
public function definitions(): Definitions
203194
{
204195
$definitions = [];
@@ -216,6 +207,20 @@ public function definitions(): Definitions
216207
return new Definitions($definitions);
217208
}
218209

210+
public function errors(): ResolverErrors
211+
{
212+
return new ResolverErrors($this->errors);
213+
}
214+
215+
/**
216+
* @return array<string>
217+
*/
218+
private function resolveAllowedKeys(): array
219+
{
220+
$allowedKeys = array_merge(array_keys($this->defaults), $this->required);
221+
return $allowedKeys;
222+
}
223+
219224
private function throwOrLogError(InvalidMap $error): void
220225
{
221226
if (!$this->ignoreErrors) {
@@ -225,6 +230,11 @@ private function throwOrLogError(InvalidMap $error): void
225230
$this->errors[] = $error;
226231
}
227232

233+
/**
234+
* @param array<string,mixed> $config
235+
* @param string[] $keys
236+
* @return array<string,mixed> $config
237+
*/
228238
private function removeKeys(array $config, array $keys): array
229239
{
230240
foreach ($keys as $remove) {
@@ -233,12 +243,4 @@ private function removeKeys(array $config, array $keys): array
233243

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

lib/ResolverErrors.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Phpactor\MapResolver;
4+
5+
final class ResolverErrors
6+
{
7+
/**
8+
* @var array<InvalidMap>
9+
*/
10+
private $errors;
11+
12+
/**
13+
* @param array<InvalidMap> $errors
14+
*/
15+
public function __construct(array $errors)
16+
{
17+
$this->errors = $errors;
18+
}
19+
20+
/**
21+
* @return array<InvalidMap>
22+
*/
23+
public function errors(): array
24+
{
25+
return $this->errors;
26+
}
27+
28+
public function hasErrors(): bool
29+
{
30+
return count($this->errors) > 0;
31+
}
32+
}

0 commit comments

Comments
 (0)