Skip to content

Commit d2bfcb6

Browse files
committed
Add types declarations
1 parent 9628346 commit d2bfcb6

Some content is hidden

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

60 files changed

+126
-258
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
/phpspec.ci.yml export-ignore
1212
/phpspec.yml.dist export-ignore
1313
/phpunit.xml.dist export-ignore
14+
/rector.php export-ignore
1415
/spec/ export-ignore
1516
/Tests/ export-ignore

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"php-http/curl-client": "^2.2",
6060
"php-http/message": "^1.13",
6161
"phpstan/phpstan": "^1.9.2",
62+
"rector/rector": "^0.18.3",
6263
"symfony/cache": "^4.4 || ^5.0 || ^6.0",
6364
"symfony/config": "^4.4 || ^5.0 || ^6.0",
6465
"symfony/phpunit-bridge": "^5.2 || ^6.0",
@@ -83,7 +84,8 @@
8384
},
8485
"config": {
8586
"allow-plugins": {
86-
"symfony/flex": true
87+
"symfony/flex": true,
88+
"php-http/discovery": true
8789
},
8890
"sort-packages": true
8991
},

rector.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
use Rector\Config\RectorConfig;
4+
use Rector\Set\ValueObject\SetList;
5+
6+
return static function (RectorConfig $rectorConfig): void {
7+
$rectorConfig->paths([
8+
__DIR__.'/src',
9+
__DIR__.'/tests',
10+
]);
11+
12+
$rectorConfig->sets([
13+
SetList::PHP_74,
14+
SetList::TYPE_DECLARATION,
15+
]);
16+
};

src/BazingaGeocoderBundle.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323
*/
2424
class BazingaGeocoderBundle extends Bundle
2525
{
26-
/**
27-
* {@inheritdoc}
28-
*
29-
* @return void
30-
*/
31-
public function build(ContainerBuilder $container)
26+
public function build(ContainerBuilder $container): void
3227
{
3328
parent::build($container);
3429

@@ -37,9 +32,6 @@ public function build(ContainerBuilder $container)
3732
$container->addCompilerPass(new FactoryValidatorPass());
3833
}
3934

40-
/**
41-
* {@inheritdoc}
42-
*/
4335
public function getPath(): string
4436
{
4537
return \dirname(__DIR__);

src/Command/GeocodeCommand.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ public function __construct(ProviderAggregator $geocoder)
3434
parent::__construct();
3535
}
3636

37-
/**
38-
* {@inheritdoc}
39-
*
40-
* @return void
41-
*/
42-
protected function configure()
37+
protected function configure(): void
4338
{
4439
$this
4540
->setName('geocoder:geocode')
@@ -57,12 +52,7 @@ protected function configure()
5752
);
5853
}
5954

60-
/**
61-
* {@inheritdoc}
62-
*
63-
* @return int
64-
*/
65-
protected function execute(InputInterface $input, OutputInterface $output)
55+
protected function execute(InputInterface $input, OutputInterface $output): int
6656
{
6757
if ($input->getOption('provider')) {
6858
$this->geocoder->using($input->getOption('provider'));

src/DataCollector/GeocoderDataCollector.php

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +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-
* {@inheritdoc}
49-
*
50-
* @return void
51-
*/
52-
public function collect(Request $request, Response $response, \Throwable $exception = null)
44+
public function collect(Request $request, Response $response, \Throwable $exception = null): void
5345
{
5446
if (!empty($this->data['queries'])) {
5547
// To avoid collection more that once.
@@ -103,23 +95,15 @@ public function getProviders(): array
10395
*/
10496
public function getProviderQueries(string $provider): array
10597
{
106-
return array_filter($this->data['queries'], static function ($data) use ($provider) {
107-
return $data['providerName'] === $provider;
108-
});
98+
return array_filter($this->data['queries'], static fn ($data): bool => $data['providerName'] === $provider);
10999
}
110100

111-
/**
112-
* @return void
113-
*/
114-
public function addInstance(ProfilingPlugin $instance)
101+
public function addInstance(ProfilingPlugin $instance): void
115102
{
116103
$this->instances[] = $instance;
117104
$this->data['providers'][] = $instance->getName();
118105
}
119106

120-
/**
121-
* {@inheritdoc}
122-
*/
123107
public function getName(): string
124108
{
125109
return 'geocoder';

src/DependencyInjection/BazingaGeocoderExtension.php

Lines changed: 3 additions & 10 deletions
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
/**
@@ -213,9 +209,6 @@ private function findReferences(array $options): array
213209
return $options;
214210
}
215211

216-
/**
217-
* @param mixed $factoryClass
218-
*/
219212
private function implementsProviderFactory($factoryClass): bool
220213
{
221214
if (false === $interfaces = class_implements($factoryClass)) {

src/DependencyInjection/Compiler/AddProvidersPass.php

Lines changed: 1 addition & 3 deletions
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;

src/DependencyInjection/Compiler/FactoryValidatorPass.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,9 @@ class FactoryValidatorPass implements CompilerPassInterface
2626
/**
2727
* @var string[]
2828
*/
29-
private static $factoryServiceIds = [];
29+
private static array $factoryServiceIds = [];
3030

31-
/**
32-
* {@inheritdoc}
33-
*
34-
* @return void
35-
*/
36-
public function process(ContainerBuilder $container)
31+
public function process(ContainerBuilder $container): void
3732
{
3833
foreach (self::$factoryServiceIds as $id) {
3934
if (!$container->hasAlias($id) && !$container->hasDefinition($id)) {
@@ -42,12 +37,7 @@ public function process(ContainerBuilder $container)
4237
}
4338
}
4439

45-
/**
46-
* @param string $factoryServiceId
47-
*
48-
* @return void
49-
*/
50-
public static function addFactoryServiceId($factoryServiceId)
40+
public static function addFactoryServiceId(string $factoryServiceId): void
5141
{
5242
self::$factoryServiceIds[] = $factoryServiceId;
5343
}

src/DependencyInjection/Compiler/ProfilerPass.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@
2424
*/
2525
class ProfilerPass implements CompilerPassInterface
2626
{
27-
/**
28-
* {@inheritdoc}
29-
*
30-
* @return void
31-
*/
32-
public function process(ContainerBuilder $container)
27+
public function process(ContainerBuilder $container): void
3328
{
3429
if (!$container->hasDefinition(GeocoderDataCollector::class)) {
3530
return;

0 commit comments

Comments
 (0)