diff --git a/doc/index.md b/doc/index.md index 3868bf0..1ff19b7 100644 --- a/doc/index.md +++ b/doc/index.md @@ -90,7 +90,7 @@ bazinga_geocoder: acme: factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory options: - httplug_client: '@httplug.client' # When using HTTPlugBundle + http_client: '@any.psr18.client' region: 'Sweden' api_key: 'xxyy' ``` @@ -116,7 +116,7 @@ bazinga_geocoder: factory: Bazinga\GeocoderBundle\ProviderFactory\TomTomFactory options: api_key: 'xxyy' - httplug_client: '@httplug.client' # When using HTTPlugBundle + http_client: '@any.psr18.client' region: 'Sweden' chain: factory: Bazinga\GeocoderBundle\ProviderFactory\ChainFactory @@ -295,17 +295,27 @@ your service argument as: `!tagged bazinga_geocoder.dumper`. ### Custom HTTP Clients -The HTTP geocoder providers integrates with [HTTPlug](http://httplug.io/). It will give you all -the power of the HTTP client. You have to select which one you want to use and how -you want to configure it. +The HTTP geocoder allows to use any [PSR-18](https://www.php-fig.org/psr/psr-18/) compatible client. +In Symfony apps it is recommended to use `symfony/http-client`, but if you want to use Guzzle, +just require it in your dependencies: -Read their [usage page](http://docs.php-http.org/en/latest/httplug/users.html), you -may also be interested in checking out the [HTTPlugBundle](https://github.com/php-http/HttplugBundle). +```bash +composer require guzzlehttp/guzzle http-interop/http-factory-guzzle +``` -An example, if you want to use Guzzle6. +And configure your provider to use it: -```bash -composer require php-http/guzzle6-adapter php-http/message +```yaml +services: + guzzle.client: + class: GuzzleHttp\Client + +bazinga_geocoder: + providers: + acme: + factory: ... + options: + http_client: '@guzzle.client' ``` Reference Configuration @@ -372,19 +382,3 @@ Setup the test suite using [Composer](http://getcomposer.org/): composer update composer test ``` - -### Doctrine test - -There is also a test that tests the doctrine integration. It runs automatically on -[GitHub Actions](https://github.com/geocoder-php/BazingaGeocoderBundle/actions) but if you want to run it locally you must do the following. - -```bash -composer require phpunit/phpunit:^9.5 --no-update -composer update --prefer-source -wget https://phar.phpunit.de/phpunit-9.5.phar -php phpunit-9.5.phar --testsuit doctrine -``` - -**Important:** this command must be run with `--prefer-source`, otherwise the -`Doctrine\Tests\OrmTestCase` class won't be found. - diff --git a/doc/services.md b/doc/services.md index 22a2378..8335baf 100644 --- a/doc/services.md +++ b/doc/services.md @@ -10,35 +10,35 @@ Here is a list of all provider factories and their options. | Service | Options | | ------- | ------- | -| `Bazinga\GeocoderBundle\ProviderFactory\AlgoliaPlaceFactory` | httplug_client, api_key, app_id -| `Bazinga\GeocoderBundle\ProviderFactory\ArcGISOnlineFactory` | httplug_client, source_country -| `Bazinga\GeocoderBundle\ProviderFactory\BingMapsFactory` | httplug_client, api_key +| `Bazinga\GeocoderBundle\ProviderFactory\AlgoliaPlaceFactory` | http_client, api_key, app_id +| `Bazinga\GeocoderBundle\ProviderFactory\ArcGISOnlineFactory` | http_client, source_country +| `Bazinga\GeocoderBundle\ProviderFactory\BingMapsFactory` | http_client, api_key | `Bazinga\GeocoderBundle\ProviderFactory\ChainFactory` | services -| `Bazinga\GeocoderBundle\ProviderFactory\FreeGeoIpFactory` | httplug_client, base_url +| `Bazinga\GeocoderBundle\ProviderFactory\FreeGeoIpFactory` | http_client, base_url | `Bazinga\GeocoderBundle\ProviderFactory\GeoIP2Factory` | provider, database_filename, user_id, license_key, webservice_options, locales, provider_service | `Bazinga\GeocoderBundle\ProviderFactory\GeoipFactory` | -| `Bazinga\GeocoderBundle\ProviderFactory\GeoIPsFactory` | httplug_client, api_key -| `Bazinga\GeocoderBundle\ProviderFactory\GeonamesFactory` | httplug_client, username -| `Bazinga\GeocoderBundle\ProviderFactory\GeoPluginFactory` | httplug_client -| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory` | httplug_client, api_key, region -| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsPlacesFactory` | httplug_client, api_key -| `Bazinga\GeocoderBundle\ProviderFactory\HereFactory` | httplug_client, app_id, app_code, use_cit -| `Bazinga\GeocoderBundle\ProviderFactory\HostIpFactory` | httplug_client -| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoFactory` | httplug_client -| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoDbFactory` | httplug_client, api_key, precision -| `Bazinga\GeocoderBundle\ProviderFactory\IpstackFactory` | httplug_client, api_key -| `Bazinga\GeocoderBundle\ProviderFactory\LocationIQFactory` | httplug_client, api_key -| `Bazinga\GeocoderBundle\ProviderFactory\MapboxFactory` | httplug_client, api_key, country, mode -| `Bazinga\GeocoderBundle\ProviderFactory\MapQuestFactory` | httplug_client, api_key, licensed -| `Bazinga\GeocoderBundle\ProviderFactory\MapzenFactory` | httplug_client, api_key +| `Bazinga\GeocoderBundle\ProviderFactory\GeoIPsFactory` | http_client, api_key +| `Bazinga\GeocoderBundle\ProviderFactory\GeonamesFactory` | http_client, username +| `Bazinga\GeocoderBundle\ProviderFactory\GeoPluginFactory` | http_client +| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory` | http_client, api_key, region +| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsPlacesFactory` | http_client, api_key +| `Bazinga\GeocoderBundle\ProviderFactory\HereFactory` | http_client, app_id, app_code, use_cit +| `Bazinga\GeocoderBundle\ProviderFactory\HostIpFactory` | http_client +| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoFactory` | http_client +| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoDbFactory` | http_client, api_key, precision +| `Bazinga\GeocoderBundle\ProviderFactory\IpstackFactory` | http_client, api_key +| `Bazinga\GeocoderBundle\ProviderFactory\LocationIQFactory` | http_client, api_key +| `Bazinga\GeocoderBundle\ProviderFactory\MapboxFactory` | http_client, api_key, country, mode +| `Bazinga\GeocoderBundle\ProviderFactory\MapQuestFactory` | http_client, api_key, licensed +| `Bazinga\GeocoderBundle\ProviderFactory\MapzenFactory` | http_client, api_key | `Bazinga\GeocoderBundle\ProviderFactory\MaxMindBinaryFactory` | dat_file, open_flag -| `Bazinga\GeocoderBundle\ProviderFactory\MaxMindFactory` | httplug_client, api_key, endpoint -| `Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory` | httplug_client, root_url -| `Bazinga\GeocoderBundle\ProviderFactory\OpenCageFactory` | httplug_client, api_key -| `Bazinga\GeocoderBundle\ProviderFactory\OpenRouteServiceFactory` | httplug_client, api_key -| `Bazinga\GeocoderBundle\ProviderFactory\PickPointFactory` | httplug_client, api_key -| `Bazinga\GeocoderBundle\ProviderFactory\TomTomFactory` | httplug_client, api_key -| `Bazinga\GeocoderBundle\ProviderFactory\YandexFactory` | httplug_client, toponym +| `Bazinga\GeocoderBundle\ProviderFactory\MaxMindFactory` | http_client, api_key, endpoint +| `Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory` | http_client, root_url +| `Bazinga\GeocoderBundle\ProviderFactory\OpenCageFactory` | http_client, api_key +| `Bazinga\GeocoderBundle\ProviderFactory\OpenRouteServiceFactory` | http_client, api_key +| `Bazinga\GeocoderBundle\ProviderFactory\PickPointFactory` | http_client, api_key +| `Bazinga\GeocoderBundle\ProviderFactory\TomTomFactory` | http_client, api_key +| `Bazinga\GeocoderBundle\ProviderFactory\YandexFactory` | http_client, toponym ### Services diff --git a/src/ProviderFactory/AlgoliaFactory.php b/src/ProviderFactory/AlgoliaFactory.php index de1d523..d88639e 100644 --- a/src/ProviderFactory/AlgoliaFactory.php +++ b/src/ProviderFactory/AlgoliaFactory.php @@ -25,11 +25,11 @@ final class AlgoliaFactory extends AbstractFactory ]; /** - * @param array{api_key: ?string, app_id: ?string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: ?string, app_id: ?string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new AlgoliaPlaces($httpClient, $config['api_key'], $config['app_id']); } @@ -37,17 +37,13 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'api_key' => null, 'app_id' => null, ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('api_key', ['string', 'null']); $resolver->setAllowedTypes('app_id', ['string', 'null']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/ArcGISOnlineFactory.php b/src/ProviderFactory/ArcGISOnlineFactory.php index c5c97a4..a51aeb0 100644 --- a/src/ProviderFactory/ArcGISOnlineFactory.php +++ b/src/ProviderFactory/ArcGISOnlineFactory.php @@ -25,11 +25,11 @@ final class ArcGISOnlineFactory extends AbstractFactory ]; /** - * @param array{source_country: ?string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{source_country: ?string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new ArcGISOnline($httpClient, $config['source_country']); } @@ -37,15 +37,11 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'source_country' => null, ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('source_country', ['string', 'null']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/BingMapsFactory.php b/src/ProviderFactory/BingMapsFactory.php index a0412e9..ce141b9 100644 --- a/src/ProviderFactory/BingMapsFactory.php +++ b/src/ProviderFactory/BingMapsFactory.php @@ -25,11 +25,11 @@ final class BingMapsFactory extends AbstractFactory ]; /** - * @param array{api_key: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new BingMaps($httpClient, $config['api_key']); } @@ -37,15 +37,11 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('api_key', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/FreeGeoIpFactory.php b/src/ProviderFactory/FreeGeoIpFactory.php index bbff314..d488461 100644 --- a/src/ProviderFactory/FreeGeoIpFactory.php +++ b/src/ProviderFactory/FreeGeoIpFactory.php @@ -25,11 +25,11 @@ final class FreeGeoIpFactory extends AbstractFactory ]; /** - * @param array{base_url: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{base_url: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new FreeGeoIp($httpClient, $config['base_url']); } @@ -37,15 +37,11 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'base_url' => 'https://freegeoip.app/json/%s', ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('base_url', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/GeoPluginFactory.php b/src/ProviderFactory/GeoPluginFactory.php index dd68c8a..ec77677 100644 --- a/src/ProviderFactory/GeoPluginFactory.php +++ b/src/ProviderFactory/GeoPluginFactory.php @@ -25,11 +25,11 @@ final class GeoPluginFactory extends AbstractFactory ]; /** - * @param array{http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new GeoPlugin($httpClient); } @@ -37,13 +37,9 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/GeonamesFactory.php b/src/ProviderFactory/GeonamesFactory.php index b37c79f..284f97a 100644 --- a/src/ProviderFactory/GeonamesFactory.php +++ b/src/ProviderFactory/GeonamesFactory.php @@ -25,11 +25,11 @@ final class GeonamesFactory extends AbstractFactory ]; /** - * @param array{username: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{username: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new Geonames($httpClient, $config['username']); } @@ -37,15 +37,11 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); $resolver->setRequired('username'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('username', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/GoogleMapsFactory.php b/src/ProviderFactory/GoogleMapsFactory.php index d7c4b75..01339d1 100644 --- a/src/ProviderFactory/GoogleMapsFactory.php +++ b/src/ProviderFactory/GoogleMapsFactory.php @@ -25,11 +25,11 @@ final class GoogleMapsFactory extends AbstractFactory ]; /** - * @param array{api_key: ?string, region: ?string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: ?string, region: ?string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new GoogleMaps($httpClient, $config['region'], $config['api_key']); } @@ -37,17 +37,13 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'region' => null, 'api_key' => null, ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('region', ['string', 'null']); $resolver->setAllowedTypes('api_key', ['string', 'null']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "%name%" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/GoogleMapsPlacesFactory.php b/src/ProviderFactory/GoogleMapsPlacesFactory.php index db2e95d..ceaf9b0 100644 --- a/src/ProviderFactory/GoogleMapsPlacesFactory.php +++ b/src/ProviderFactory/GoogleMapsPlacesFactory.php @@ -25,11 +25,11 @@ final class GoogleMapsPlacesFactory extends AbstractFactory ]; /** - * @param array{api_key: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new GoogleMapsPlaces($httpClient, $config['api_key']); } @@ -37,15 +37,11 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setRequired(['api_key']); $resolver->setAllowedTypes('api_key', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/HereFactory.php b/src/ProviderFactory/HereFactory.php index c940d7e..6b723f4 100644 --- a/src/ProviderFactory/HereFactory.php +++ b/src/ProviderFactory/HereFactory.php @@ -25,7 +25,7 @@ final class HereFactory extends AbstractFactory ]; /** - * @param array{app_key: ?string, app_id: ?string, app_code: ?string, use_cit: bool, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{app_key: ?string, app_id: ?string, app_code: ?string, use_cit: bool, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { @@ -33,7 +33,7 @@ protected function getProvider(array $config): Provider throw new \InvalidArgumentException('No authentication key provided. Here requires app_key or app_code and app_id.'); } - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); if (!empty($config['app_key'])) { if (!method_exists(Here::class, 'createUsingApiKey')) { @@ -49,7 +49,6 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'use_cit' => false, 'app_key' => null, @@ -57,13 +56,10 @@ protected static function configureOptionResolver(OptionsResolver $resolver) 'app_code' => null, ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('app_key', ['string', 'null']); $resolver->setAllowedTypes('app_id', ['string', 'null']); $resolver->setAllowedTypes('app_code', ['string', 'null']); $resolver->setAllowedTypes('use_cit', ['bool', 'false']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/HostIpFactory.php b/src/ProviderFactory/HostIpFactory.php index f90e66b..3585478 100644 --- a/src/ProviderFactory/HostIpFactory.php +++ b/src/ProviderFactory/HostIpFactory.php @@ -25,11 +25,11 @@ final class HostIpFactory extends AbstractFactory ]; /** - * @param array{http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new HostIp($httpClient); } @@ -37,13 +37,9 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/IpInfoDbFactory.php b/src/ProviderFactory/IpInfoDbFactory.php index 2349f0b..105648c 100644 --- a/src/ProviderFactory/IpInfoDbFactory.php +++ b/src/ProviderFactory/IpInfoDbFactory.php @@ -25,11 +25,11 @@ final class IpInfoDbFactory extends AbstractFactory ]; /** - * @param array{api_key: string, precision: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, precision: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new IpInfoDb($httpClient, $config['api_key'], $config['precision']); } @@ -37,17 +37,13 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'precision' => 'city', ]); $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('api_key', ['string']); $resolver->setAllowedTypes('precision', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/IpInfoFactory.php b/src/ProviderFactory/IpInfoFactory.php index 4e396fd..ea11dd5 100644 --- a/src/ProviderFactory/IpInfoFactory.php +++ b/src/ProviderFactory/IpInfoFactory.php @@ -25,11 +25,11 @@ final class IpInfoFactory extends AbstractFactory ]; /** - * @param array{http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new IpInfo($httpClient); } @@ -37,13 +37,9 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/IpstackFactory.php b/src/ProviderFactory/IpstackFactory.php index 0062e83..5706fbd 100644 --- a/src/ProviderFactory/IpstackFactory.php +++ b/src/ProviderFactory/IpstackFactory.php @@ -25,11 +25,11 @@ final class IpstackFactory extends AbstractFactory ]; /** - * @param array{api_key: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new Ipstack($httpClient, $config['api_key']); } @@ -37,15 +37,11 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('api_key', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/LocationIQFactory.php b/src/ProviderFactory/LocationIQFactory.php index 63e4b0f..d8081fe 100644 --- a/src/ProviderFactory/LocationIQFactory.php +++ b/src/ProviderFactory/LocationIQFactory.php @@ -23,11 +23,11 @@ final class LocationIQFactory extends AbstractFactory ]; /** - * @param array{api_key: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new LocationIQ($httpClient, $config['api_key']); } @@ -35,15 +35,11 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setRequired(['api_key']); $resolver->setAllowedTypes('api_key', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/MapQuestFactory.php b/src/ProviderFactory/MapQuestFactory.php index 4491997..d376f2f 100644 --- a/src/ProviderFactory/MapQuestFactory.php +++ b/src/ProviderFactory/MapQuestFactory.php @@ -25,11 +25,11 @@ final class MapQuestFactory extends AbstractFactory ]; /** - * @param array{api_key: string, licensed: bool, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, licensed: bool, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new MapQuest($httpClient, $config['api_key'], $config['licensed']); } @@ -37,17 +37,13 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'licensed' => false, ]); $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('api_key', ['string']); $resolver->setAllowedTypes('licensed', ['boolean']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/MapboxFactory.php b/src/ProviderFactory/MapboxFactory.php index cdaaa63..04ba1db 100644 --- a/src/ProviderFactory/MapboxFactory.php +++ b/src/ProviderFactory/MapboxFactory.php @@ -23,11 +23,11 @@ final class MapboxFactory extends AbstractFactory ]; /** - * @param array{api_key: string, country: ?string, mode: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, country: ?string, mode: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new Mapbox($httpClient, $config['api_key'], $config['country'], $config['mode']); } @@ -35,7 +35,6 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'country' => null, 'mode' => Mapbox::GEOCODING_MODE_PLACES, @@ -44,10 +43,7 @@ protected static function configureOptionResolver(OptionsResolver $resolver) $resolver->setRequired('api_key'); $resolver->setAllowedTypes('api_key', ['string']); $resolver->setAllowedTypes('mode', ['string']); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('country', ['string', 'null']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/MaxMindFactory.php b/src/ProviderFactory/MaxMindFactory.php index c7da086..a3b3043 100644 --- a/src/ProviderFactory/MaxMindFactory.php +++ b/src/ProviderFactory/MaxMindFactory.php @@ -25,11 +25,11 @@ final class MaxMindFactory extends AbstractFactory ]; /** - * @param array{api_key: string, endpoint: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, endpoint: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new MaxMind($httpClient, $config['api_key'], $config['endpoint']); } @@ -37,17 +37,13 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'endpoint' => MaxMind::CITY_EXTENDED_SERVICE, ]); $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('api_key', ['string']); $resolver->setAllowedValues('endpoint', [MaxMind::CITY_EXTENDED_SERVICE, MaxMind::OMNI_SERVICE]); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/NominatimFactory.php b/src/ProviderFactory/NominatimFactory.php index f6d9c46..f86ea22 100644 --- a/src/ProviderFactory/NominatimFactory.php +++ b/src/ProviderFactory/NominatimFactory.php @@ -25,11 +25,11 @@ final class NominatimFactory extends AbstractFactory ]; /** - * @param array{root_url: string, user_agent: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{root_url: string, user_agent: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new Nominatim($httpClient, $config['root_url'], $config['user_agent']); } @@ -37,18 +37,14 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'root_url' => 'https://nominatim.openstreetmap.org', 'user_agent' => 'BazingaGeocoderBundle', ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('root_url', ['string']); $resolver->setAllowedTypes('user_agent', ['string']); $resolver->setRequired('user_agent'); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/OpenCageFactory.php b/src/ProviderFactory/OpenCageFactory.php index 02b253b..fb21b7f 100644 --- a/src/ProviderFactory/OpenCageFactory.php +++ b/src/ProviderFactory/OpenCageFactory.php @@ -25,11 +25,11 @@ final class OpenCageFactory extends AbstractFactory ]; /** - * @param array{api_key: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new OpenCage($httpClient, $config['api_key']); } @@ -37,15 +37,11 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('api_key', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/OpenRouteServiceFactory.php b/src/ProviderFactory/OpenRouteServiceFactory.php index 2bcd2e8..f53e96d 100644 --- a/src/ProviderFactory/OpenRouteServiceFactory.php +++ b/src/ProviderFactory/OpenRouteServiceFactory.php @@ -25,11 +25,11 @@ final class OpenRouteServiceFactory extends AbstractFactory ]; /** - * @param array{api_key: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new OpenRouteService($httpClient, $config['api_key']); } @@ -37,16 +37,12 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'api_key' => null, ]); $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('api_key', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/PickPointFactory.php b/src/ProviderFactory/PickPointFactory.php index 66d583c..f7fdc9f 100644 --- a/src/ProviderFactory/PickPointFactory.php +++ b/src/ProviderFactory/PickPointFactory.php @@ -25,11 +25,11 @@ final class PickPointFactory extends AbstractFactory ]; /** - * @param array{api_key: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new PickPoint($httpClient, $config['api_key']); } @@ -37,15 +37,11 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('api_key', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/TomTomFactory.php b/src/ProviderFactory/TomTomFactory.php index b707b2a..4f57151 100644 --- a/src/ProviderFactory/TomTomFactory.php +++ b/src/ProviderFactory/TomTomFactory.php @@ -25,11 +25,11 @@ final class TomTomFactory extends AbstractFactory ]; /** - * @param array{api_key: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{api_key: string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new TomTom($httpClient, $config['api_key']); } @@ -37,15 +37,11 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, ]); $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('api_key', ['string']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/src/ProviderFactory/YandexFactory.php b/src/ProviderFactory/YandexFactory.php index 37c9c2d..77b2a6d 100644 --- a/src/ProviderFactory/YandexFactory.php +++ b/src/ProviderFactory/YandexFactory.php @@ -25,11 +25,11 @@ final class YandexFactory extends AbstractFactory ]; /** - * @param array{toponym: ?string, api_key: ?string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config + * @param array{toponym: ?string, api_key: ?string, http_client: ?ClientInterface} $config */ protected function getProvider(array $config): Provider { - $httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); + $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); return new Yandex($httpClient, $config['toponym'], $config['api_key']); } @@ -37,17 +37,13 @@ protected function getProvider(array $config): Provider protected static function configureOptionResolver(OptionsResolver $resolver) { $resolver->setDefaults([ - 'httplug_client' => null, 'http_client' => null, 'toponym' => null, 'api_key' => null, ]); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); $resolver->setAllowedTypes('http_client', ['object', 'null']); $resolver->setAllowedTypes('toponym', ['string', 'null']); $resolver->setAllowedTypes('api_key', ['string', 'null']); - - $resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.'); } } diff --git a/tests/Functional/ProviderFactoryTest.php b/tests/Functional/ProviderFactoryTest.php index a360d8a..64489d6 100644 --- a/tests/Functional/ProviderFactoryTest.php +++ b/tests/Functional/ProviderFactoryTest.php @@ -125,27 +125,4 @@ public function getProviders(): iterable yield [TomTom::class, ['acme']]; yield [Yandex::class, ['empty', 'acme']]; } - - /** - * @group legacy - */ - public function testProviderConfigurationWithDeprecatedHttplugClientOption(): void - { - self::bootKernel(['config' => static function (TestKernel $kernel) { - $kernel->addTestConfig(__DIR__.'/config/framework.yml'); - - if ($kernel::VERSION_ID >= 60000) { - $kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml'); - } - - $kernel->addTestConfig(__DIR__.'/config/deprecated_httplug_client_option.yml'); - }]); - - $container = self::getContainer(); - - $this->expectDeprecation('Since willdurand/geocoder-bundle 5.19: The option "httplug_client" is deprecated, use "http_client" instead.'); - - self::assertTrue($container->has('bazinga_geocoder.provider.acme')); - $container->get('bazinga_geocoder.provider.acme'); - } } diff --git a/tests/Functional/config/deprecated_httplug_client_option.yml b/tests/Functional/config/deprecated_httplug_client_option.yml deleted file mode 100644 index c52ac75..0000000 --- a/tests/Functional/config/deprecated_httplug_client_option.yml +++ /dev/null @@ -1,12 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - options: - httplug_client: '@test_http_client' - -services: - test_http_client: - class: Http\Client\Curl\Client diff --git a/tests/baseline-ignore b/tests/baseline-ignore index 0e1fe13..83bf6c9 100644 --- a/tests/baseline-ignore +++ b/tests/baseline-ignore @@ -5,7 +5,6 @@ %Doctrine\\DBAL\\Connection::getEventManager is deprecated% %DebugStack is deprecated% %In ORM 3.0, the AttributeDriver will report fields for the classes where they are declared% -%Class "Nyholm\\Psr7\\Factory\\HttplugFactory" is deprecated since version 1.8, use "Nyholm\\Psr7\\Factory\\Psr17Factory" instead% %Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0% %Since doctrine/doctrine-bundle 2.11: Not setting "doctrine.orm.enable_lazy_ghost_objects" to true is deprecated% %Geocoder\\Http\\Provider\\AbstractHttpProvider::createRequest\(\): Implicitly marking parameter \$body as nullable is deprecated, the explicit nullable type must be used instead%