Skip to content

Commit c3ec697

Browse files
committed
feat: add strong PHP Types, cleanup
1 parent b0229db commit c3ec697

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

src/ProviderFactory/PluginProviderFactory.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Geocoder\Plugin\Plugin;
1616
use Geocoder\Plugin\PluginProvider;
17+
use Geocoder\Provider\Provider;
1718

1819
/**
1920
* This factory creates a PluginProvider.
@@ -23,19 +24,17 @@
2324
final class PluginProviderFactory
2425
{
2526
/**
26-
* @param Plugin[] $plugins
27-
* @param callable|ProviderFactoryInterface $factory
28-
* @param array<mixed> $config config to the client factory
29-
* @param array{max_restarts?: int<0, max>} $pluginProviderOptions config forwarded to the PluginProvider
27+
* @param Plugin[] $plugins
28+
* @param callable(array):Provider|ProviderFactoryInterface $factory
29+
* @param array<mixed> $config config to the client factory
30+
* @param array{max_restarts?: int<0, max>} $pluginProviderOptions config forwarded to the PluginProvider
3031
*/
3132
public static function createPluginProvider(array $plugins, callable|ProviderFactoryInterface $factory, array $config, array $pluginProviderOptions = []): PluginProvider
3233
{
3334
if ($factory instanceof ProviderFactoryInterface) {
3435
$client = $factory->createProvider($config);
35-
} elseif (is_callable($factory)) {
36-
$client = $factory($config);
3736
} else {
38-
throw new \RuntimeException(sprintf('Second argument to PluginProviderFactory::createPluginProvider must be a "%s" or a callable.', ProviderFactoryInterface::class));
37+
$client = $factory($config);
3938
}
4039

4140
return new PluginProvider($client, $plugins, $pluginProviderOptions);

src/Validator/Constraint/Address.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,9 @@ class Address extends Constraint
3131

3232
public string $service = AddressValidator::class;
3333

34-
public string $message = 'Address {{ address }} is not valid.';
35-
36-
/**
37-
* @param string[]|null $options
38-
*/
39-
public function __construct(?array $options = null, ?string $message = null, ?array $groups = null, $payload = null)
34+
public function __construct(public string $message = 'Address {{ address }} is not valid.', ?array $groups = null, $payload = null)
4035
{
41-
parent::__construct($options, $groups, $payload);
42-
43-
$this->message = $message ?? $this->message;
36+
parent::__construct(null, $groups, $payload);
4437
}
4538

4639
public function validatedBy(): string

0 commit comments

Comments
 (0)