Skip to content

Commit abc63bf

Browse files
committed
Increase phpstan level to 7
1 parent c9318d5 commit abc63bf

Some content is hidden

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

47 files changed

+252
-16
lines changed

BazingaGeocoderBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class BazingaGeocoderBundle extends Bundle
2525
{
2626
/**
2727
* {@inheritdoc}
28+
*
29+
* @return void
2830
*/
2931
public function build(ContainerBuilder $container)
3032
{

Command/GeocodeCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public function __construct(ProviderAggregator $geocoder)
4141

4242
/**
4343
* {@inheritdoc}
44+
*
45+
* @return void
4446
*/
4547
protected function configure()
4648
{

DataCollector/GeocoderDataCollector.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
namespace Bazinga\GeocoderBundle\DataCollector;
1414

1515
use Bazinga\GeocoderBundle\Plugin\ProfilingPlugin;
16+
use Geocoder\Collection;
17+
use Geocoder\Query\Query;
1618
use Symfony\Component\HttpFoundation\Request;
1719
use Symfony\Component\HttpFoundation\Response;
1820
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
@@ -34,7 +36,7 @@ public function __construct()
3436
}
3537

3638
/**
37-
* {@inheritdoc}
39+
* @return void
3840
*/
3941
public function reset()
4042
{
@@ -45,6 +47,8 @@ public function reset()
4547

4648
/**
4749
* {@inheritdoc}
50+
*
51+
* @return void
4852
*/
4953
public function collect(Request $request, Response $response, \Throwable $exception = null)
5054
{
@@ -53,7 +57,6 @@ public function collect(Request $request, Response $response, \Throwable $except
5357
return;
5458
}
5559

56-
/** @var ProfilingPlugin[] $instances */
5760
$instances = $this->instances;
5861

5962
foreach ($instances as $instance) {
@@ -67,6 +70,8 @@ public function collect(Request $request, Response $response, \Throwable $except
6770

6871
/**
6972
* Returns an array of collected requests.
73+
*
74+
* @phpstan-return array<int, array{query: Query, queryString: string, duration: float, providerName: string, result: mixed, resultCount: int}>
7075
*/
7176
public function getQueries(): array
7277
{
@@ -86,18 +91,27 @@ public function getTotalDuration(): float
8691
return $time;
8792
}
8893

94+
/**
95+
* @return string[]
96+
*/
8997
public function getProviders(): array
9098
{
9199
return $this->data['providers'];
92100
}
93101

102+
/**
103+
* @phpstan-return array<int, array{query: Query, queryString: string, duration: float, providerName: string, result: mixed, resultCount: int}>
104+
*/
94105
public function getProviderQueries(string $provider): array
95106
{
96-
return array_filter($this->data['queries'], function ($data) use ($provider) {
107+
return array_filter($this->data['queries'], static function ($data) use ($provider) {
97108
return $data['providerName'] === $provider;
98109
});
99110
}
100111

112+
/**
113+
* @return void
114+
*/
101115
public function addInstance(ProfilingPlugin $instance)
102116
{
103117
$this->instances[] = $instance;

DependencyInjection/BazingaGeocoderExtension.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
*/
4040
class BazingaGeocoderExtension extends Extension
4141
{
42+
/**
43+
* @phpstan-param array<mixed, mixed> $configs
44+
*
45+
* @return void
46+
*/
4247
public function load(array $configs, ContainerBuilder $container)
4348
{
4449
$processor = new Processor();
@@ -71,6 +76,11 @@ public function load(array $configs, ContainerBuilder $container)
7176
->addTag('bazinga_geocoder.dumper');
7277
}
7378

79+
/**
80+
* @phpstan-param array<mixed, mixed> $config
81+
*
82+
* @return void
83+
*/
7484
private function loadProviders(ContainerBuilder $container, array $config)
7585
{
7686
foreach ($config['providers'] as $providerName => $providerConfig) {
@@ -109,6 +119,10 @@ private function loadProviders(ContainerBuilder $container, array $config)
109119

110120
/**
111121
* Configure plugins for a client.
122+
*
123+
* @phpstan-param array<mixed, mixed> $config
124+
*
125+
* @return Reference[]
112126
*/
113127
public function configureProviderPlugins(ContainerBuilder $container, array $config, string $providerServiceId): array
114128
{
@@ -173,13 +187,23 @@ public function configureProviderPlugins(ContainerBuilder $container, array $con
173187
}
174188

175189
/**
190+
* @phpstan-param array<mixed, mixed> $config
191+
*
176192
* @return Configuration
177193
*/
178194
public function getConfiguration(array $config, ContainerBuilder $container)
179195
{
180-
return new Configuration($container->getParameter('kernel.debug'));
196+
/** @var bool $debug */
197+
$debug = $container->getParameter('kernel.debug');
198+
199+
return new Configuration($debug);
181200
}
182201

202+
/**
203+
* @phpstan-param array<mixed, mixed> $options
204+
*
205+
* @phpstan-return array<mixed, mixed>
206+
*/
183207
private function findReferences(array $options): array
184208
{
185209
foreach ($options as $key => $value) {

DependencyInjection/Compiler/AddProvidersPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +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
2830
*/
2931
public function process(ContainerBuilder $container)
3032
{

DependencyInjection/Compiler/FactoryValidatorPass.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@
2323
*/
2424
class FactoryValidatorPass implements CompilerPassInterface
2525
{
26+
/**
27+
* @var string[]
28+
*/
2629
private static $factoryServiceIds = [];
2730

2831
/**
2932
* {@inheritdoc}
33+
*
34+
* @return void
3035
*/
3136
public function process(ContainerBuilder $container)
3237
{
@@ -38,10 +43,12 @@ public function process(ContainerBuilder $container)
3843
}
3944

4045
/**
41-
* @param mixed $factoryServiceIds
46+
* @param string $factoryServiceId
47+
*
48+
* @return void
4249
*/
43-
public static function addFactoryServiceId($factoryServiceIds)
50+
public static function addFactoryServiceId($factoryServiceId)
4451
{
45-
self::$factoryServiceIds[] = $factoryServiceIds;
52+
self::$factoryServiceIds[] = $factoryServiceId;
4653
}
4754
}

DependencyInjection/Compiler/ProfilerPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class ProfilerPass implements CompilerPassInterface
2626
{
2727
/**
2828
* {@inheritdoc}
29+
*
30+
* @return void
2931
*/
3032
public function process(ContainerBuilder $container)
3133
{

Doctrine/ORM/GeocoderListener.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function __construct(Provider $geocoder, DriverInterface $driver)
4646
* {@inheritdoc}
4747
*
4848
* @return array
49+
* @phpstan-return list<string>
4950
*/
5051
public function getSubscribedEvents()
5152
{
@@ -54,6 +55,9 @@ public function getSubscribedEvents()
5455
];
5556
}
5657

58+
/**
59+
* @return void
60+
*/
5761
public function onFlush(OnFlushEventArgs $args)
5862
{
5963
$em = $args->getEntityManager();
@@ -98,6 +102,8 @@ public function onFlush(OnFlushEventArgs $args)
98102

99103
/**
100104
* @param object $entity
105+
*
106+
* @return void
101107
*/
102108
private function geocodeEntity(ClassMetadata $metadata, $entity)
103109
{
@@ -107,7 +113,7 @@ private function geocodeEntity(ClassMetadata $metadata, $entity)
107113
$address = $metadata->addressProperty->getValue($entity);
108114
}
109115

110-
if (empty($address)) {
116+
if (empty($address) || !is_string($address)) {
111117
return;
112118
}
113119

Mapping/Driver/AnnotationDriver.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,29 @@
2323
*/
2424
class AnnotationDriver implements DriverInterface
2525
{
26+
/**
27+
* @var Reader
28+
*/
2629
private $reader;
2730

2831
public function __construct(Reader $reader)
2932
{
3033
$this->reader = $reader;
3134
}
3235

36+
/**
37+
* {@inheritdoc}
38+
*/
3339
public function isGeocodeable($object): bool
3440
{
3541
$reflection = ClassUtils::newReflectionObject($object);
3642

3743
return (bool) $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class);
3844
}
3945

46+
/**
47+
* {@inheritdoc}
48+
*/
4049
public function loadMetadataFromObject($object)
4150
{
4251
$reflection = ClassUtils::newReflectionObject($object);

Mapping/Driver/AttributeDriver.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
final class AttributeDriver implements DriverInterface
2424
{
25+
/**
26+
* {@inheritdoc}
27+
*/
2528
public function isGeocodeable($object): bool
2629
{
2730
if (PHP_VERSION_ID < 80000) {
@@ -34,6 +37,8 @@ public function isGeocodeable($object): bool
3437
}
3538

3639
/**
40+
* {@inheritdoc}
41+
*
3742
* @throws MappingException
3843
*/
3944
public function loadMetadataFromObject($object): ClassMetadata

0 commit comments

Comments
 (0)