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

Diff for: .gitattributes

+1
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

Diff for: composer.json

+3-1
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
},

Diff for: rector.php

+16
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+
};

Diff for: src/BazingaGeocoderBundle.php

+1-9
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__);

Diff for: src/Command/GeocodeCommand.php

+2-12
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'));

Diff for: src/DataCollector/GeocoderDataCollector.php

+4-20
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';

Diff for: src/DependencyInjection/BazingaGeocoderExtension.php

+3-10
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)) {

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-13
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
}

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

+1-6
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;

Diff for: src/DependencyInjection/Configuration.php

+4-13
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ public function __construct(bool $debug)
3030

3131
/**
3232
* Generates the configuration tree builder.
33-
*
34-
* @return TreeBuilder The tree builder
3533
*/
36-
public function getConfigTreeBuilder()
34+
public function getConfigTreeBuilder(): TreeBuilder
3735
{
3836
$treeBuilder = new TreeBuilder('bazinga_geocoder');
3937
$rootNode = $treeBuilder->getRootNode();
@@ -58,9 +56,7 @@ public function getConfigTreeBuilder()
5856
->arrayNode('fake_ip')
5957
->beforeNormalization()
6058
->ifString()
61-
->then(function ($value) {
62-
return ['ip' => $value];
63-
})
59+
->then(fn ($value): array => ['ip' => $value])
6460
->end()
6561
->canBeEnabled()
6662
->children()
@@ -75,10 +71,7 @@ public function getConfigTreeBuilder()
7571
return $treeBuilder;
7672
}
7773

78-
/**
79-
* @return ArrayNodeDefinition
80-
*/
81-
private function getProvidersNode()
74+
private function getProvidersNode(): ArrayNodeDefinition
8275
{
8376
$treeBuilder = new TreeBuilder('providers');
8477
$rootNode = $treeBuilder->getRootNode();
@@ -113,10 +106,8 @@ private function getProvidersNode()
113106

114107
/**
115108
* Create plugin node of a client.
116-
*
117-
* @return ArrayNodeDefinition The plugin node
118109
*/
119-
private function createClientPluginNode()
110+
private function createClientPluginNode(): ArrayNodeDefinition
120111
{
121112
$treeBuilder = new TreeBuilder('plugins');
122113
$rootNode = $treeBuilder->getRootNode();

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

+2-9
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public function __construct(Provider $geocoder, DriverInterface $driver)
3636
}
3737

3838
/**
39-
* {@inheritdoc}
40-
*
4139
* @return list<string>
4240
*/
4341
public function getSubscribedEvents(): array
@@ -47,10 +45,7 @@ public function getSubscribedEvents(): array
4745
];
4846
}
4947

50-
/**
51-
* @return void
52-
*/
53-
public function onFlush(OnFlushEventArgs $args)
48+
public function onFlush(OnFlushEventArgs $args): void
5449
{
5550
$em = $args->getEntityManager();
5651
$uow = $em->getUnitOfWork();
@@ -94,10 +89,8 @@ public function onFlush(OnFlushEventArgs $args)
9489

9590
/**
9691
* @param object $entity
97-
*
98-
* @return void
9992
*/
100-
private function geocodeEntity(ClassMetadata $metadata, $entity)
93+
private function geocodeEntity(ClassMetadata $metadata, $entity): void
10194
{
10295
if (null !== $metadata->addressGetter) {
10396
$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;
3927
}

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,14 @@ public function __construct(Reader $reader)
3030
$this->reader = $reader;
3131
}
3232

33-
/**
34-
* {@inheritdoc}
35-
*/
3633
public function isGeocodeable($object): bool
3734
{
3835
$reflection = ClassUtils::newReflectionObject($object);
3936

4037
return (bool) $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class);
4138
}
4239

43-
/**
44-
* {@inheritdoc}
45-
*/
46-
public function loadMetadataFromObject($object)
40+
public function loadMetadataFromObject($object): ClassMetadata
4741
{
4842
$reflection = ClassUtils::newReflectionObject($object);
4943

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

-5
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
*/
2323
final class AttributeDriver implements DriverInterface
2424
{
25-
/**
26-
* {@inheritdoc}
27-
*/
2825
public function isGeocodeable($object): bool
2926
{
3027
if (PHP_VERSION_ID < 80000) {
@@ -37,8 +34,6 @@ public function isGeocodeable($object): bool
3734
}
3835

3936
/**
40-
* {@inheritdoc}
41-
*
4237
* @throws MappingException
4338
*/
4439
public function loadMetadataFromObject($object): ClassMetadata

0 commit comments

Comments
 (0)