Skip to content

Commit 432f21f

Browse files
committed
Modernize code
1 parent 77aece4 commit 432f21f

File tree

81 files changed

+764
-569
lines changed

Some content is hidden

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

81 files changed

+764
-569
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The changelog describes what have been "Added", "Changed", "Removed" or "Fixed"
88

99
- Allow PSR-18 client
1010
- Updated Geocoder Provider dependency requirements to the latest versions
11+
- Deprecate `httplug_client` option in most provider factories in favour of `http_client`.
1112

1213
## Version 5.18.0
1314

phpstan-baseline.neon

Lines changed: 167 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,186 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:end\\(\\)\\.$#"
4+
message: "#^Parameter \\#1 \\$name of method Geocoder\\\\ProviderAggregator\\:\\:using\\(\\) expects string, mixed given\\.$#"
5+
count: 1
6+
path: src/Command/GeocodeCommand.php
7+
8+
-
9+
message: "#^Parameter \\#1 \\$string of function strtolower expects string, string\\|null given\\.$#"
10+
count: 1
11+
path: src/Command/GeocodeCommand.php
12+
13+
-
14+
message: "#^Parameter \\#1 \\$text of static method Geocoder\\\\Query\\\\GeocodeQuery\\:\\:create\\(\\) expects string, mixed given\\.$#"
15+
count: 1
16+
path: src/Command/GeocodeCommand.php
17+
18+
-
19+
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
20+
count: 3
21+
path: src/DependencyInjection/BazingaGeocoderExtension.php
22+
23+
-
24+
message: "#^Cannot access offset 'aliases' on mixed\\.$#"
25+
count: 1
26+
path: src/DependencyInjection/BazingaGeocoderExtension.php
27+
28+
-
29+
message: "#^Cannot access offset 'enabled' on mixed\\.$#"
30+
count: 1
31+
path: src/DependencyInjection/BazingaGeocoderExtension.php
32+
33+
-
34+
message: "#^Cannot access offset 'factory' on mixed\\.$#"
35+
count: 5
36+
path: src/DependencyInjection/BazingaGeocoderExtension.php
37+
38+
-
39+
message: "#^Cannot access offset 'id' on mixed\\.$#"
40+
count: 1
41+
path: src/DependencyInjection/BazingaGeocoderExtension.php
42+
43+
-
44+
message: "#^Cannot access offset 'options' on mixed\\.$#"
45+
count: 6
46+
path: src/DependencyInjection/BazingaGeocoderExtension.php
47+
48+
-
49+
message: "#^Cannot access offset 'reference' on mixed\\.$#"
50+
count: 2
51+
path: src/DependencyInjection/BazingaGeocoderExtension.php
52+
53+
-
54+
message: "#^Cannot call static method validate\\(\\) on mixed\\.$#"
55+
count: 1
56+
path: src/DependencyInjection/BazingaGeocoderExtension.php
57+
58+
-
59+
message: "#^Cannot cast mixed to int\\.$#"
60+
count: 2
61+
path: src/DependencyInjection/BazingaGeocoderExtension.php
62+
63+
-
64+
message: "#^Cannot cast mixed to string\\.$#"
65+
count: 1
66+
path: src/DependencyInjection/BazingaGeocoderExtension.php
67+
68+
-
69+
message: "#^Parameter \\#1 \\$alias of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:setAlias\\(\\) expects string, mixed given\\.$#"
70+
count: 1
71+
path: src/DependencyInjection/BazingaGeocoderExtension.php
72+
73+
-
74+
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: Symfony\\\\Component\\\\DependencyInjection\\\\Reference given\\.$#"
75+
count: 1
76+
path: src/DependencyInjection/BazingaGeocoderExtension.php
77+
78+
-
79+
message: "#^Parameter \\#1 \\$factoryServiceId of static method Bazinga\\\\GeocoderBundle\\\\DependencyInjection\\\\Compiler\\\\FactoryValidatorPass\\:\\:addFactoryServiceId\\(\\) expects string, mixed given\\.$#"
80+
count: 1
81+
path: src/DependencyInjection/BazingaGeocoderExtension.php
82+
83+
-
84+
message: "#^Parameter \\#1 \\$id of class Symfony\\\\Component\\\\DependencyInjection\\\\Reference constructor expects string, mixed given\\.$#"
85+
count: 3
86+
path: src/DependencyInjection/BazingaGeocoderExtension.php
87+
88+
-
89+
message: "#^Parameter \\#1 \\$id of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:getDefinition\\(\\) expects string, mixed given\\.$#"
90+
count: 1
91+
path: src/DependencyInjection/BazingaGeocoderExtension.php
92+
93+
-
94+
message: "#^Parameter \\#1 \\$object_or_class of function class_implements expects object\\|string, mixed given\\.$#"
95+
count: 1
96+
path: src/DependencyInjection/BazingaGeocoderExtension.php
97+
98+
-
99+
message: "#^Parameter \\#1 \\$options of method Bazinga\\\\GeocoderBundle\\\\DependencyInjection\\\\BazingaGeocoderExtension\\:\\:findReferences\\(\\) expects array\\<int\\|string, mixed\\>, mixed given\\.$#"
5100
count: 2
6-
path: DependencyInjection/Configuration.php
101+
path: src/DependencyInjection/BazingaGeocoderExtension.php
102+
103+
-
104+
message: "#^Parameter \\#1 \\$string of function ltrim expects string, mixed given\\.$#"
105+
count: 1
106+
path: src/DependencyInjection/BazingaGeocoderExtension.php
107+
108+
-
109+
message: "#^Parameter \\#2 \\$config of method Bazinga\\\\GeocoderBundle\\\\DependencyInjection\\\\BazingaGeocoderExtension\\:\\:configureProviderPlugins\\(\\) expects array\\<int\\|string, mixed\\>, mixed given\\.$#"
110+
count: 1
111+
path: src/DependencyInjection/BazingaGeocoderExtension.php
112+
113+
-
114+
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
115+
count: 1
116+
path: src/DependencyInjection/BazingaGeocoderExtension.php
117+
118+
-
119+
message: "#^Part \\$providerName \\(mixed\\) of encapsed string cannot be cast to string\\.$#"
120+
count: 1
121+
path: src/DependencyInjection/BazingaGeocoderExtension.php
122+
123+
-
124+
message: "#^Cannot call method end\\(\\) on Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\|null\\.$#"
125+
count: 2
126+
path: src/DependencyInjection/Configuration.php
127+
128+
-
129+
message: "#^Cannot call method variableNode\\(\\) on Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\|null\\.$#"
130+
count: 1
131+
path: src/DependencyInjection/Configuration.php
132+
133+
-
134+
message: "#^Cannot call method getLatitude\\(\\) on Geocoder\\\\Model\\\\Coordinates\\|null\\.$#"
135+
count: 1
136+
path: src/Doctrine/ORM/GeocoderListener.php
137+
138+
-
139+
message: "#^Cannot call method getLongitude\\(\\) on Geocoder\\\\Model\\\\Coordinates\\|null\\.$#"
140+
count: 1
141+
path: src/Doctrine/ORM/GeocoderListener.php
142+
143+
-
144+
message: "#^Parameter \\#1 \\$text of method Geocoder\\\\Query\\\\GeocodeQuery\\:\\:withText\\(\\) expects string, string\\|null given\\.$#"
145+
count: 1
146+
path: src/Plugin/FakeIpPlugin.php
147+
148+
-
149+
message: "#^Parameter \\#2 \\$replace of function str_replace expects array\\|string, string\\|null given\\.$#"
150+
count: 1
151+
path: src/Plugin/FakeIpPlugin.php
152+
153+
-
154+
message: "#^Parameter \\#1 \\$accountId of class GeoIp2\\\\WebService\\\\Client constructor expects int, int\\|null given\\.$#"
155+
count: 1
156+
path: src/ProviderFactory/GeoIP2Factory.php
157+
158+
-
159+
message: "#^Parameter \\#1 \\$filename of class GeoIp2\\\\Database\\\\Reader constructor expects string, string\\|null given\\.$#"
160+
count: 1
161+
path: src/ProviderFactory/GeoIP2Factory.php
162+
163+
-
164+
message: "#^Parameter \\#1 \\$geoIpProvider of class Geocoder\\\\Provider\\\\GeoIP2\\\\GeoIP2Adapter constructor expects GeoIp2\\\\ProviderInterface, GeoIp2\\\\ProviderInterface\\|null given\\.$#"
165+
count: 1
166+
path: src/ProviderFactory/GeoIP2Factory.php
7167

8168
-
9-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:variableNode\\(\\)\\.$#"
169+
message: "#^Parameter \\#2 \\$licenseKey of class GeoIp2\\\\WebService\\\\Client constructor expects string, string\\|null given\\.$#"
10170
count: 1
11-
path: DependencyInjection/Configuration.php
171+
path: src/ProviderFactory/GeoIP2Factory.php
12172

13173
-
14174
message: "#^Class Geocoder\\\\Provider\\\\Geoip\\\\Geoip not found\\.$#"
15175
count: 1
16-
path: ProviderFactory/GeoipFactory.php
176+
path: src/ProviderFactory/GeoipFactory.php
17177

18178
-
19179
message: "#^Instantiated class Geocoder\\\\Provider\\\\Geoip\\\\Geoip not found\\.$#"
20180
count: 1
21-
path: ProviderFactory/GeoipFactory.php
181+
path: src/ProviderFactory/GeoipFactory.php
22182

23183
-
24184
message: "#^Method Bazinga\\\\GeocoderBundle\\\\ProviderFactory\\\\GeoipFactory\\:\\:getProvider\\(\\) should return Geocoder\\\\Provider\\\\Provider but returns Geocoder\\\\Provider\\\\Geoip\\\\Geoip\\.$#"
25185
count: 1
26-
path: ProviderFactory/GeoipFactory.php
186+
path: src/ProviderFactory/GeoipFactory.php

phpstan.neon.dist

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ includes:
22
- phpstan-baseline.neon
33

44
parameters:
5+
bootstrapFiles:
6+
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
57
paths:
6-
- %currentWorkingDirectory%
7-
excludePaths:
8-
- ./vendor/
9-
- ./Tests/
10-
level: 7
8+
- src/
9+
#- tests/
10+
level: 9

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@
2626
<directory>src</directory>
2727
</whitelist>
2828
</filter>
29+
30+
<listeners>
31+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
32+
</listeners>
2933
</phpunit>

src/Command/GeocodeCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
*/
2626
class GeocodeCommand extends Command
2727
{
28-
/**
29-
* @var ProviderAggregator
30-
*/
31-
private $geocoder;
28+
private ProviderAggregator $geocoder;
3229

3330
public function __construct(ProviderAggregator $geocoder)
3431
{

src/DataCollector/GeocoderDataCollector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class GeocoderDataCollector extends DataCollector
2626
/**
2727
* @var ProfilingPlugin[]
2828
*/
29-
private $instances = [];
29+
private array $instances = [];
3030

3131
public function __construct()
3232
{
@@ -70,7 +70,7 @@ public function collect(Request $request, Response $response, \Throwable $except
7070
/**
7171
* Returns an array of collected requests.
7272
*
73-
* @phpstan-return array<int, array{query: Query, queryString: string, duration: float, providerName: string, result: mixed, resultCount: int}>
73+
* @return list<array{query: Query, queryString: string, duration: float, providerName: string, result: mixed, resultCount: int}>
7474
*/
7575
public function getQueries(): array
7676
{
@@ -99,7 +99,7 @@ public function getProviders(): array
9999
}
100100

101101
/**
102-
* @phpstan-return array<int, array{query: Query, queryString: string, duration: float, providerName: string, result: mixed, resultCount: int}>
102+
* @return list<array{query: Query, queryString: string, duration: float, providerName: string, result: mixed, resultCount: int}>
103103
*/
104104
public function getProviderQueries(string $provider): array
105105
{

src/DependencyInjection/BazingaGeocoderExtension.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
class BazingaGeocoderExtension extends Extension
4141
{
4242
/**
43-
* @phpstan-param array<mixed, mixed> $configs
43+
* @param array<mixed, mixed> $configs
4444
*
4545
* @return void
4646
*/
@@ -77,7 +77,7 @@ public function load(array $configs, ContainerBuilder $container)
7777
}
7878

7979
/**
80-
* @phpstan-param array<mixed, mixed> $config
80+
* @param array<mixed, mixed> $config
8181
*
8282
* @return void
8383
*/
@@ -120,7 +120,7 @@ private function loadProviders(ContainerBuilder $container, array $config)
120120
/**
121121
* Configure plugins for a client.
122122
*
123-
* @phpstan-param array<mixed, mixed> $config
123+
* @param array<mixed, mixed> $config
124124
*
125125
* @return Reference[]
126126
*/
@@ -181,17 +181,13 @@ public function configureProviderPlugins(ContainerBuilder $container, array $con
181181
->addTag('bazinga_geocoder.profiling_plugin');
182182
}
183183

184-
return array_map(function (string $id) {
185-
return new Reference($id);
186-
}, $plugins);
184+
return array_map(static fn (string $id) => new Reference($id), $plugins);
187185
}
188186

189187
/**
190-
* @phpstan-param array<mixed, mixed> $config
191-
*
192-
* @return Configuration
188+
* @param array<mixed, mixed> $config
193189
*/
194-
public function getConfiguration(array $config, ContainerBuilder $container)
190+
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
195191
{
196192
/** @var bool $debug */
197193
$debug = $container->getParameter('kernel.debug');
@@ -200,9 +196,9 @@ public function getConfiguration(array $config, ContainerBuilder $container)
200196
}
201197

202198
/**
203-
* @phpstan-param array<mixed, mixed> $options
199+
* @param array<mixed, mixed> $options
204200
*
205-
* @phpstan-return array<mixed, mixed>
201+
* @return array<mixed, mixed>
206202
*/
207203
private function findReferences(array $options): array
208204
{

src/DependencyInjection/Configuration.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,11 @@
2121
*/
2222
class Configuration implements ConfigurationInterface
2323
{
24-
/**
25-
* Whether to use the debug mode.
26-
*
27-
* @see https://github.com/doctrine/DoctrineBundle/blob/v1.5.2/DependencyInjection/Configuration.php#L31-L41
28-
*
29-
* @var bool
30-
*/
31-
private $debug;
24+
private bool $debug;
3225

33-
/**
34-
* @param bool $debug
35-
*/
36-
public function __construct($debug)
26+
public function __construct(bool $debug)
3727
{
38-
$this->debug = (bool) $debug;
28+
$this->debug = $debug;
3929
}
4030

4131
/**

src/Doctrine/ORM/GeocoderListener.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,8 @@
2626
*/
2727
class GeocoderListener implements EventSubscriber
2828
{
29-
/**
30-
* @var DriverInterface
31-
*/
32-
private $driver;
33-
34-
/**
35-
* @var Provider
36-
*/
37-
private $geocoder;
29+
private DriverInterface $driver;
30+
private Provider $geocoder;
3831

3932
public function __construct(Provider $geocoder, DriverInterface $driver)
4033
{
@@ -45,10 +38,9 @@ public function __construct(Provider $geocoder, DriverInterface $driver)
4538
/**
4639
* {@inheritdoc}
4740
*
48-
* @return array
49-
* @phpstan-return list<string>
41+
* @return list<string>
5042
*/
51-
public function getSubscribedEvents()
43+
public function getSubscribedEvents(): array
5244
{
5345
return [
5446
Events::onFlush,

src/Mapping/Driver/AnnotationDriver.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
*/
2424
class AnnotationDriver implements DriverInterface
2525
{
26-
/**
27-
* @var Reader
28-
*/
29-
private $reader;
26+
private Reader $reader;
3027

3128
public function __construct(Reader $reader)
3229
{

0 commit comments

Comments
 (0)