Skip to content

Commit 6cb8d5c

Browse files
committed
Add types declarations
1 parent 737e905 commit 6cb8d5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+92
-186
lines changed

Diff for: src/BazingaGeocoderBundle.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
*/
2424
class BazingaGeocoderBundle extends Bundle
2525
{
26-
/**
27-
* @return void
28-
*/
29-
public function build(ContainerBuilder $container)
26+
public function build(ContainerBuilder $container): void
3027
{
3128
parent::build($container);
3229

Diff for: src/Command/GeocodeCommand.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public function __construct(ProviderAggregator $geocoder)
3434
parent::__construct();
3535
}
3636

37-
/**
38-
* @return void
39-
*/
40-
protected function configure()
37+
protected function configure(): void
4138
{
4239
$this
4340
->setName('geocoder:geocode')

Diff for: src/DataCollector/GeocoderDataCollector.php

+4-15
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,14 @@ public function __construct()
3434
$this->data['providers'] = [];
3535
}
3636

37-
/**
38-
* @return void
39-
*/
40-
public function reset()
37+
public function reset(): void
4138
{
4239
$this->instances = [];
4340
$this->data['queries'] = [];
4441
$this->data['providers'] = [];
4542
}
4643

47-
/**
48-
* @return void
49-
*/
50-
public function collect(Request $request, Response $response, ?\Throwable $exception = null)
44+
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
5145
{
5246
if (!empty($this->data['queries'])) {
5347
// To avoid collection more that once.
@@ -101,15 +95,10 @@ public function getProviders(): array
10195
*/
10296
public function getProviderQueries(string $provider): array
10397
{
104-
return array_filter($this->data['queries'], static function ($data) use ($provider) {
105-
return $data['providerName'] === $provider;
106-
});
98+
return array_filter($this->data['queries'], static fn (array $data): bool => $data['providerName'] === $provider);
10799
}
108100

109-
/**
110-
* @return void
111-
*/
112-
public function addInstance(ProfilingPlugin $instance)
101+
public function addInstance(ProfilingPlugin $instance): void
113102
{
114103
$this->instances[] = $instance;
115104
$this->data['providers'][] = $instance->getName();

Diff for: src/DependencyInjection/BazingaGeocoderExtension.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ class BazingaGeocoderExtension extends Extension
4141
{
4242
/**
4343
* @param array<mixed, mixed> $configs
44-
*
45-
* @return void
4644
*/
47-
public function load(array $configs, ContainerBuilder $container)
45+
public function load(array $configs, ContainerBuilder $container): void
4846
{
4947
$processor = new Processor();
5048
$configuration = $this->getConfiguration($configs, $container);
@@ -78,10 +76,8 @@ public function load(array $configs, ContainerBuilder $container)
7876

7977
/**
8078
* @param array<mixed, mixed> $config
81-
*
82-
* @return void
8379
*/
84-
private function loadProviders(ContainerBuilder $container, array $config)
80+
private function loadProviders(ContainerBuilder $container, array $config): void
8581
{
8682
foreach ($config['providers'] as $providerName => $providerConfig) {
8783
try {
@@ -181,7 +177,7 @@ public function configureProviderPlugins(ContainerBuilder $container, array $con
181177
->addTag('bazinga_geocoder.profiling_plugin');
182178
}
183179

184-
return array_map(static fn (string $id) => new Reference($id), $plugins);
180+
return array_map(static fn (string $id): Reference => new Reference($id), $plugins);
185181
}
186182

187183
/**

Diff for: src/DependencyInjection/Compiler/AddProvidersPass.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ class AddProvidersPass implements CompilerPassInterface
2525
/**
2626
* Get all providers based on their tag (`bazinga_geocoder.provider`) and
2727
* register them.
28-
*
29-
* @return void
3028
*/
31-
public function process(ContainerBuilder $container)
29+
public function process(ContainerBuilder $container): void
3230
{
3331
if (!$container->hasDefinition(ProviderAggregator::class)) {
3432
return;

Diff for: src/DependencyInjection/Compiler/FactoryValidatorPass.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ class FactoryValidatorPass implements CompilerPassInterface
2626
/**
2727
* @var string[]
2828
*/
29-
private static $factoryServiceIds = [];
29+
private static array $factoryServiceIds = [];
3030

31-
/**
32-
* @return void
33-
*/
34-
public function process(ContainerBuilder $container)
31+
public function process(ContainerBuilder $container): void
3532
{
3633
foreach (self::$factoryServiceIds as $id) {
3734
if (!$container->hasAlias($id) && !$container->hasDefinition($id)) {
@@ -40,12 +37,7 @@ public function process(ContainerBuilder $container)
4037
}
4138
}
4239

43-
/**
44-
* @param string $factoryServiceId
45-
*
46-
* @return void
47-
*/
48-
public static function addFactoryServiceId($factoryServiceId)
40+
public static function addFactoryServiceId(string $factoryServiceId): void
4941
{
5042
self::$factoryServiceIds[] = $factoryServiceId;
5143
}

Diff for: src/DependencyInjection/Compiler/ProfilerPass.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
2424
*/
2525
class ProfilerPass implements CompilerPassInterface
2626
{
27-
/**
28-
* @return void
29-
*/
30-
public function process(ContainerBuilder $container)
27+
public function process(ContainerBuilder $container): void
3128
{
3229
if (!$container->hasDefinition(GeocoderDataCollector::class)) {
3330
return;

Diff for: src/DependencyInjection/Configuration.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ public function getConfigTreeBuilder(): TreeBuilder
5656
->arrayNode('fake_ip')
5757
->beforeNormalization()
5858
->ifString()
59-
->then(function ($value) {
60-
return ['ip' => $value];
61-
})
59+
->then(static fn (string $value): array => ['ip' => $value])
6260
->end()
6361
->canBeEnabled()
6462
->children()
@@ -73,10 +71,7 @@ public function getConfigTreeBuilder(): TreeBuilder
7371
return $treeBuilder;
7472
}
7573

76-
/**
77-
* @return ArrayNodeDefinition
78-
*/
79-
private function getProvidersNode()
74+
private function getProvidersNode(): ArrayNodeDefinition
8075
{
8176
$treeBuilder = new TreeBuilder('providers');
8277
$rootNode = $treeBuilder->getRootNode();
@@ -111,10 +106,8 @@ private function getProvidersNode()
111106

112107
/**
113108
* Create plugin node of a client.
114-
*
115-
* @return ArrayNodeDefinition The plugin node
116109
*/
117-
private function createClientPluginNode()
110+
private function createClientPluginNode(): ArrayNodeDefinition
118111
{
119112
$treeBuilder = new TreeBuilder('plugins');
120113
$rootNode = $treeBuilder->getRootNode();

Diff for: src/Doctrine/ORM/GeocoderListener.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ public function getSubscribedEvents(): array
4545
];
4646
}
4747

48-
/**
49-
* @return void
50-
*/
51-
public function onFlush(OnFlushEventArgs $args)
48+
public function onFlush(OnFlushEventArgs $args): void
5249
{
5350
$em = method_exists($args, 'getObjectManager') ? $args->getObjectManager() : $args->getEntityManager();
5451
$uow = $em->getUnitOfWork();
@@ -92,10 +89,8 @@ public function onFlush(OnFlushEventArgs $args)
9289

9390
/**
9491
* @param object $entity
95-
*
96-
* @return void
9792
*/
98-
private function geocodeEntity(ClassMetadata $metadata, $entity)
93+
private function geocodeEntity(ClassMetadata $metadata, $entity): void
9994
{
10095
if (null !== $metadata->addressGetter) {
10196
$address = $metadata->addressGetter->invoke($entity);

Diff for: src/Mapping/ClassMetadata.php

+4-16
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,11 @@
1717
*/
1818
class ClassMetadata
1919
{
20-
/**
21-
* @var \ReflectionProperty
22-
*/
23-
public $addressProperty;
20+
public \ReflectionProperty $addressProperty;
2421

25-
/**
26-
* @var \ReflectionProperty
27-
*/
28-
public $latitudeProperty;
22+
public \ReflectionProperty $latitudeProperty;
2923

30-
/**
31-
* @var \ReflectionProperty
32-
*/
33-
public $longitudeProperty;
24+
public \ReflectionProperty $longitudeProperty;
3425

35-
/**
36-
* @var \ReflectionMethod
37-
*/
38-
public $addressGetter;
26+
public ?\ReflectionMethod $addressGetter = null;
3927
}

Diff for: src/Mapping/Driver/AnnotationDriver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function isGeocodeable($object): bool
3838
return (bool) $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class);
3939
}
4040

41-
public function loadMetadataFromObject($object)
41+
public function loadMetadataFromObject($object): ClassMetadata
4242
{
4343
$reflection = self::getReflection($object);
4444

Diff for: src/Mapping/Driver/DriverInterface.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public function isGeocodeable($object): bool;
2323

2424
/**
2525
* @param object $object
26-
*
27-
* @return ClassMetadata
2826
*/
29-
public function loadMetadataFromObject($object);
27+
public function loadMetadataFromObject($object): ClassMetadata;
3028
}

Diff for: src/Plugin/FakeIpPlugin.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ public function __construct(?string $needle, ?string $replacement = null, bool $
4141
}
4242
}
4343

44-
/**
45-
* @return Promise
46-
*/
47-
public function handleQuery(Query $query, callable $next, callable $first)
44+
public function handleQuery(Query $query, callable $next, callable $first): Promise
4845
{
4946
if (!$query instanceof GeocodeQuery) {
5047
return $next($query);

Diff for: src/Plugin/ProfilingPlugin.php

+7-12
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,28 @@ class ProfilingPlugin implements Plugin
2929
/**
3030
* @var list<array{query: Query, queryString: string, duration: float, providerName: string, result: mixed, resultCount: int}>
3131
*/
32-
private $queries = [];
32+
private array $queries = [];
3333

3434
/**
35-
* @var string service id of the provider
35+
* service id of the provider.
3636
*/
37-
private $name;
37+
private string $name;
3838

3939
public function __construct(string $name)
4040
{
4141
$this->name = $name;
4242
}
4343

44-
/**
45-
* @return Promise
46-
*/
47-
public function handleQuery(Query $query, callable $next, callable $first)
44+
public function handleQuery(Query $query, callable $next, callable $first): Promise
4845
{
4946
$startTime = microtime(true);
5047

51-
return $next($query)->then(function (Collection $result) use ($query, $startTime) {
48+
return $next($query)->then(function (Collection $result) use ($query, $startTime): Collection {
5249
$duration = (microtime(true) - $startTime) * 1000;
5350
$this->logQuery($query, $duration, $result);
5451

5552
return $result;
56-
}, function (Exception $exception) use ($query, $startTime) {
53+
}, function (Exception $exception) use ($query, $startTime): void {
5754
$duration = (microtime(true) - $startTime) * 1000;
5855
$this->logQuery($query, $duration, $exception);
5956

@@ -63,10 +60,8 @@ public function handleQuery(Query $query, callable $next, callable $first)
6360

6461
/**
6562
* @param mixed $result
66-
*
67-
* @return void
6863
*/
69-
private function logQuery(Query $query, float $duration, $result = null)
64+
private function logQuery(Query $query, float $duration, $result = null): void
7065
{
7166
if ($query instanceof GeocodeQuery) {
7267
$queryString = $query->getText();

Diff for: src/ProviderFactory/AbstractFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function createProvider(array $options = []): Provider
5353
return $this->getProvider($config);
5454
}
5555

56-
public static function validate(array $options, $providerName)
56+
public static function validate(array $options, $providerName): void
5757
{
5858
static::verifyDependencies();
5959

Diff for: src/ProviderFactory/AlgoliaFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider
3434
return new AlgoliaPlaces($httpClient, $config['api_key'], $config['app_id']);
3535
}
3636

37-
protected static function configureOptionResolver(OptionsResolver $resolver)
37+
protected static function configureOptionResolver(OptionsResolver $resolver): void
3838
{
3939
$resolver->setDefaults([
4040
'httplug_client' => null,

Diff for: src/ProviderFactory/ArcGISOnlineFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider
3434
return new ArcGISOnline($httpClient, $config['source_country']);
3535
}
3636

37-
protected static function configureOptionResolver(OptionsResolver $resolver)
37+
protected static function configureOptionResolver(OptionsResolver $resolver): void
3838
{
3939
$resolver->setDefaults([
4040
'httplug_client' => null,

Diff for: src/ProviderFactory/BingMapsFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider
3434
return new BingMaps($httpClient, $config['api_key']);
3535
}
3636

37-
protected static function configureOptionResolver(OptionsResolver $resolver)
37+
protected static function configureOptionResolver(OptionsResolver $resolver): void
3838
{
3939
$resolver->setDefaults([
4040
'httplug_client' => null,

Diff for: src/ProviderFactory/ChainFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function getProvider(array $config): Provider
4242
return $provider;
4343
}
4444

45-
protected static function configureOptionResolver(OptionsResolver $resolver)
45+
protected static function configureOptionResolver(OptionsResolver $resolver): void
4646
{
4747
parent::configureOptionResolver($resolver);
4848

Diff for: src/ProviderFactory/FreeGeoIpFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider
3434
return new FreeGeoIp($httpClient, $config['base_url']);
3535
}
3636

37-
protected static function configureOptionResolver(OptionsResolver $resolver)
37+
protected static function configureOptionResolver(OptionsResolver $resolver): void
3838
{
3939
$resolver->setDefaults([
4040
'httplug_client' => null,

Diff for: src/ProviderFactory/GeoIP2Factory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function getProvider(array $config): Provider
4747
return new GeoIP2($adapter);
4848
}
4949

50-
protected static function configureOptionResolver(OptionsResolver $resolver)
50+
protected static function configureOptionResolver(OptionsResolver $resolver): void
5151
{
5252
$resolver->setDefaults([
5353
'model' => GeoIP2Adapter::GEOIP2_MODEL_CITY,

Diff for: src/ProviderFactory/GeoIPsFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function getProvider(array $config): Provider
4040
return new GeoIPs($httplug, $config['api_key']);
4141
}
4242

43-
protected static function configureOptionResolver(OptionsResolver $resolver)
43+
protected static function configureOptionResolver(OptionsResolver $resolver): void
4444
{
4545
$resolver->setDefaults([
4646
'httplug_client' => null,

Diff for: src/ProviderFactory/GeoPluginFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider
3434
return new GeoPlugin($httpClient);
3535
}
3636

37-
protected static function configureOptionResolver(OptionsResolver $resolver)
37+
protected static function configureOptionResolver(OptionsResolver $resolver): void
3838
{
3939
$resolver->setDefaults([
4040
'httplug_client' => null,

0 commit comments

Comments
 (0)