diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa07df6c..bfc2dd39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,13 +54,11 @@ jobs: fail-fast: true matrix: strategy: ['default'] - php: ['7.3', '7.4', '8.0', '8.1'] + php: ['8.0', '8.1'] include: - - php: '7.3' + - php: '8.0' sf_version: '4.4.*' strategy: 'lowest' - - php: '7.4' - sf_version: '5.4.*' - php: '8.0' sf_version: '5.4.*' - php: '8.1' @@ -104,18 +102,16 @@ jobs: max-parallel: 10 fail-fast: true matrix: - php: ['7.4', '8.0', '8.1'] + php: ['8.0', '8.1'] include: - - php: '7.4' + - php: '8.0' sf_version: '4.4.*' - - php: '7.4' - sf_version: '5.4.*' - php: '8.0' sf_version: '5.4.*' - - php: '8.1' - sf_version: '5.4.*' - php: '8.0' sf_version: '6.0.*' + - php: '8.1' + sf_version: '5.4.*' - php: '8.1' sf_version: '6.0.*' steps: diff --git a/BazingaGeocoderBundle.php b/BazingaGeocoderBundle.php index 4b81367c..1162f4a7 100644 --- a/BazingaGeocoderBundle.php +++ b/BazingaGeocoderBundle.php @@ -25,10 +25,8 @@ class BazingaGeocoderBundle extends Bundle { /** * {@inheritdoc} - * - * @return void */ - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { parent::build($container); diff --git a/CHANGELOG.md b/CHANGELOG.md index bd11b8ee..3dff09e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ The changelog describes what have been "Added", "Changed", "Removed" or "Fixed" between versions. +## Version 6.0 + +### Added + +- PHP 8 language features +- Typehints according to PHP 8 + +### Removed + +- Remove MapzenFactory +- Remove GeoIPsFactory +- Remove PHP 7.x support + ## Version 5.16.1 ### Fixed diff --git a/Command/GeocodeCommand.php b/Command/GeocodeCommand.php index 18ad3fcb..bea05682 100644 --- a/Command/GeocodeCommand.php +++ b/Command/GeocodeCommand.php @@ -27,24 +27,15 @@ class GeocodeCommand extends Command { protected static $defaultName = 'geocoder:geocode'; - /** - * @var ProviderAggregator - */ - private $geocoder; - - public function __construct(ProviderAggregator $geocoder) + public function __construct(private ProviderAggregator $geocoder) { - $this->geocoder = $geocoder; - parent::__construct(); } /** * {@inheritdoc} - * - * @return void */ - protected function configure() + protected function configure(): void { $this ->setName('geocoder:geocode') @@ -65,9 +56,9 @@ protected function configure() /** * {@inheritdoc} * - * @return int + * @throws \Geocoder\Exception\Exception */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { if ($input->getOption('provider')) { $this->geocoder->using($input->getOption('provider')); diff --git a/DataCollector/GeocoderDataCollector.php b/DataCollector/GeocoderDataCollector.php index a0442f79..58ae8cf8 100644 --- a/DataCollector/GeocoderDataCollector.php +++ b/DataCollector/GeocoderDataCollector.php @@ -27,7 +27,7 @@ class GeocoderDataCollector extends DataCollector /** * @var ProfilingPlugin[] */ - private $instances = []; + private array $instances = []; public function __construct() { @@ -35,10 +35,7 @@ public function __construct() $this->data['providers'] = []; } - /** - * @return void - */ - public function reset() + public function reset(): void { $this->instances = []; $this->data['queries'] = []; @@ -47,10 +44,8 @@ public function reset() /** * {@inheritdoc} - * - * @return void */ - public function collect(Request $request, Response $response, \Throwable $exception = null) + public function collect(Request $request, Response $response, \Throwable $exception = null): void { if (!empty($this->data['queries'])) { // To avoid collection more that once. @@ -109,10 +104,7 @@ public function getProviderQueries(string $provider): array }); } - /** - * @return void - */ - public function addInstance(ProfilingPlugin $instance) + public function addInstance(ProfilingPlugin $instance): void { $this->instances[] = $instance; $this->data['providers'][] = $instance->getName(); diff --git a/DependencyInjection/BazingaGeocoderExtension.php b/DependencyInjection/BazingaGeocoderExtension.php index 2301b162..739b2670 100644 --- a/DependencyInjection/BazingaGeocoderExtension.php +++ b/DependencyInjection/BazingaGeocoderExtension.php @@ -41,10 +41,8 @@ class BazingaGeocoderExtension extends Extension { /** * @phpstan-param array $configs - * - * @return void */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $processor = new Processor(); $configuration = $this->getConfiguration($configs, $container); @@ -78,10 +76,8 @@ public function load(array $configs, ContainerBuilder $container) /** * @phpstan-param array $config - * - * @return void */ - private function loadProviders(ContainerBuilder $container, array $config) + private function loadProviders(ContainerBuilder $container, array $config): void { foreach ($config['providers'] as $providerName => $providerConfig) { try { @@ -188,10 +184,8 @@ public function configureProviderPlugins(ContainerBuilder $container, array $con /** * @phpstan-param array $config - * - * @return Configuration */ - public function getConfiguration(array $config, ContainerBuilder $container) + public function getConfiguration(array $config, ContainerBuilder $container): Configuration { /** @var bool $debug */ $debug = $container->getParameter('kernel.debug'); @@ -209,7 +203,7 @@ private function findReferences(array $options): array foreach ($options as $key => $value) { if (is_array($value)) { $options[$key] = $this->findReferences($value); - } elseif ('_service' === substr((string) $key, -8) || 0 === strpos((string) $value, '@') || 'service' === $key) { + } elseif (str_ends_with((string) $key, '_service') || str_starts_with((string) $value, '@') || 'service' === $key) { $options[$key] = new Reference(ltrim($value, '@')); } } @@ -217,10 +211,7 @@ private function findReferences(array $options): array return $options; } - /** - * @param mixed $factoryClass - */ - private function implementsProviderFactory($factoryClass): bool + private function implementsProviderFactory(mixed $factoryClass): bool { if (false === $interfaces = class_implements($factoryClass)) { return false; diff --git a/DependencyInjection/Compiler/AddProvidersPass.php b/DependencyInjection/Compiler/AddProvidersPass.php index 526a94c1..a98e83fb 100644 --- a/DependencyInjection/Compiler/AddProvidersPass.php +++ b/DependencyInjection/Compiler/AddProvidersPass.php @@ -25,10 +25,8 @@ class AddProvidersPass implements CompilerPassInterface /** * Get all providers based on their tag (`bazinga_geocoder.provider`) and * register them. - * - * @return void */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->hasDefinition(ProviderAggregator::class)) { return; diff --git a/DependencyInjection/Compiler/FactoryValidatorPass.php b/DependencyInjection/Compiler/FactoryValidatorPass.php index ed202d13..3ab723a0 100644 --- a/DependencyInjection/Compiler/FactoryValidatorPass.php +++ b/DependencyInjection/Compiler/FactoryValidatorPass.php @@ -26,14 +26,12 @@ class FactoryValidatorPass implements CompilerPassInterface /** * @var string[] */ - private static $factoryServiceIds = []; + private static array $factoryServiceIds = []; /** * {@inheritdoc} - * - * @return void */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { foreach (self::$factoryServiceIds as $id) { if (!$container->hasAlias($id) && !$container->hasDefinition($id)) { @@ -42,12 +40,7 @@ public function process(ContainerBuilder $container) } } - /** - * @param string $factoryServiceId - * - * @return void - */ - public static function addFactoryServiceId($factoryServiceId) + public static function addFactoryServiceId(string $factoryServiceId): void { self::$factoryServiceIds[] = $factoryServiceId; } diff --git a/DependencyInjection/Compiler/ProfilerPass.php b/DependencyInjection/Compiler/ProfilerPass.php index 982bcd35..5f357a6d 100644 --- a/DependencyInjection/Compiler/ProfilerPass.php +++ b/DependencyInjection/Compiler/ProfilerPass.php @@ -26,10 +26,8 @@ class ProfilerPass implements CompilerPassInterface { /** * {@inheritdoc} - * - * @return void */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->hasDefinition(GeocoderDataCollector::class)) { return; diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 72f68d3b..093dc001 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -25,25 +25,18 @@ class Configuration implements ConfigurationInterface * Whether to use the debug mode. * * @see https://github.com/doctrine/DoctrineBundle/blob/v1.5.2/DependencyInjection/Configuration.php#L31-L41 - * - * @var bool */ - private $debug; + private bool $debug; - /** - * @param bool $debug - */ - public function __construct($debug) + public function __construct(bool $debug) { - $this->debug = (bool) $debug; + $this->debug = $debug; } /** * Generates the configuration tree builder. - * - * @return TreeBuilder The tree builder */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('bazinga_geocoder'); $rootNode = $treeBuilder->getRootNode(); @@ -85,10 +78,7 @@ public function getConfigTreeBuilder() return $treeBuilder; } - /** - * @return ArrayNodeDefinition - */ - private function getProvidersNode() + private function getProvidersNode(): ArrayNodeDefinition { $treeBuilder = new TreeBuilder('providers'); $rootNode = $treeBuilder->getRootNode(); @@ -126,13 +116,12 @@ private function getProvidersNode() * * @return ArrayNodeDefinition The plugin node */ - private function createClientPluginNode() + private function createClientPluginNode(): ArrayNodeDefinition { $treeBuilder = new TreeBuilder('plugins'); $rootNode = $treeBuilder->getRootNode(); assert($rootNode instanceof ArrayNodeDefinition); - /** @var ArrayNodeDefinition $pluginList */ $pluginList = $rootNode ->info('A list of plugin service ids. The order is important.') ->arrayPrototype() diff --git a/Doctrine/ORM/GeocoderListener.php b/Doctrine/ORM/GeocoderListener.php index 557ab8f7..6da6daab 100644 --- a/Doctrine/ORM/GeocoderListener.php +++ b/Doctrine/ORM/GeocoderListener.php @@ -26,39 +26,23 @@ */ class GeocoderListener implements EventSubscriber { - /** - * @var DriverInterface - */ - private $driver; - - /** - * @var Provider - */ - private $geocoder; - - public function __construct(Provider $geocoder, DriverInterface $driver) + public function __construct(private Provider $geocoder, private DriverInterface $driver) { - $this->driver = $driver; - $this->geocoder = $geocoder; } /** * {@inheritdoc} * - * @return array * @phpstan-return list */ - public function getSubscribedEvents() + public function getSubscribedEvents(): array { return [ Events::onFlush, ]; } - /** - * @return void - */ - public function onFlush(OnFlushEventArgs $args) + public function onFlush(OnFlushEventArgs $args): void { $em = $args->getEntityManager(); $uow = $em->getUnitOfWork(); @@ -68,7 +52,6 @@ public function onFlush(OnFlushEventArgs $args) continue; } - /** @var ClassMetadata $metadata */ $metadata = $this->driver->loadMetadataFromObject($entity); $this->geocodeEntity($metadata, $entity); @@ -84,7 +67,6 @@ public function onFlush(OnFlushEventArgs $args) continue; } - /** @var ClassMetadata $metadata */ $metadata = $this->driver->loadMetadataFromObject($entity); if (!$this->shouldGeocode($metadata, $uow, $entity)) { @@ -100,12 +82,7 @@ public function onFlush(OnFlushEventArgs $args) } } - /** - * @param object $entity - * - * @return void - */ - private function geocodeEntity(ClassMetadata $metadata, $entity) + private function geocodeEntity(ClassMetadata $metadata, object $entity): void { if (null !== $metadata->addressGetter) { $address = $metadata->addressGetter->invoke($entity); @@ -126,10 +103,7 @@ private function geocodeEntity(ClassMetadata $metadata, $entity) } } - /** - * @param object $entity - */ - private function shouldGeocode(ClassMetadata $metadata, UnitOfWork $unitOfWork, $entity): bool + private function shouldGeocode(ClassMetadata $metadata, UnitOfWork $unitOfWork, object $entity): bool { if (null !== $metadata->addressGetter) { return true; diff --git a/Mapping/ClassMetadata.php b/Mapping/ClassMetadata.php index 891bffb2..2704247d 100644 --- a/Mapping/ClassMetadata.php +++ b/Mapping/ClassMetadata.php @@ -17,23 +17,11 @@ */ class ClassMetadata { - /** - * @var \ReflectionProperty - */ - public $addressProperty; + public \ReflectionProperty $addressProperty; - /** - * @var \ReflectionProperty - */ - public $latitudeProperty; + public \ReflectionProperty $latitudeProperty; - /** - * @var \ReflectionProperty - */ - public $longitudeProperty; + public \ReflectionProperty $longitudeProperty; - /** - * @var \ReflectionMethod - */ - public $addressGetter; + public ?\ReflectionMethod $addressGetter = null; } diff --git a/Mapping/Driver/AnnotationDriver.php b/Mapping/Driver/AnnotationDriver.php index 5c6d6957..7a6146f2 100644 --- a/Mapping/Driver/AnnotationDriver.php +++ b/Mapping/Driver/AnnotationDriver.php @@ -23,30 +23,18 @@ */ class AnnotationDriver implements DriverInterface { - /** - * @var Reader - */ - private $reader; - - public function __construct(Reader $reader) + public function __construct(private Reader $reader) { - $this->reader = $reader; } - /** - * {@inheritdoc} - */ - public function isGeocodeable($object): bool + public function isGeocodeable(object $object): bool { $reflection = ClassUtils::newReflectionObject($object); return (bool) $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class); } - /** - * {@inheritdoc} - */ - public function loadMetadataFromObject($object) + public function loadMetadataFromObject(object $object): ClassMetadata { $reflection = ClassUtils::newReflectionObject($object); diff --git a/Mapping/Driver/AttributeDriver.php b/Mapping/Driver/AttributeDriver.php index 21c68612..52d3a21b 100644 --- a/Mapping/Driver/AttributeDriver.php +++ b/Mapping/Driver/AttributeDriver.php @@ -22,31 +22,18 @@ */ final class AttributeDriver implements DriverInterface { - /** - * {@inheritdoc} - */ - public function isGeocodeable($object): bool + public function isGeocodeable(object $object): bool { - if (PHP_VERSION_ID < 80000) { - return false; - } - $reflection = ClassUtils::newReflectionObject($object); return count($reflection->getAttributes(Annotations\Geocodeable::class)) > 0; } /** - * {@inheritdoc} - * * @throws MappingException */ - public function loadMetadataFromObject($object): ClassMetadata + public function loadMetadataFromObject(object $object): ClassMetadata { - if (PHP_VERSION_ID < 80000) { - throw new MappingException(sprintf('The class %s is not geocodeable', get_class($object))); - } - $reflection = ClassUtils::newReflectionObject($object); $attributes = $reflection->getAttributes(Annotations\Geocodeable::class); diff --git a/Mapping/Driver/DriverInterface.php b/Mapping/Driver/DriverInterface.php index 0f38cfcc..8d06209c 100644 --- a/Mapping/Driver/DriverInterface.php +++ b/Mapping/Driver/DriverInterface.php @@ -16,15 +16,7 @@ interface DriverInterface { - /** - * @param object $object - */ - public function isGeocodeable($object): bool; + public function isGeocodeable(object $object): bool; - /** - * @param object $object - * - * @return ClassMetadata - */ - public function loadMetadataFromObject($object); + public function loadMetadataFromObject(object $object): ClassMetadata; } diff --git a/Plugin/FakeIpPlugin.php b/Plugin/FakeIpPlugin.php index 479d390a..af81b8d2 100644 --- a/Plugin/FakeIpPlugin.php +++ b/Plugin/FakeIpPlugin.php @@ -26,36 +26,17 @@ */ class FakeIpPlugin implements Plugin { - /** - * @var string|null - */ - private $needle; + private ?Generator $faker = null; - /** - * @var string - */ - private $replacement; - - /** - * @var Generator|null - */ - private $faker; - - public function __construct(?string $needle, string $replacement = null, bool $useFaker = false) + public function __construct(private ?string $needle, private ?string $replacement = null, bool $useFaker = false) { - $this->needle = $needle; - $this->replacement = $replacement; - if ($useFaker) { $this->faker = new Generator(); $this->faker->addProvider(new Internet($this->faker)); } } - /** - * @return Promise - */ - public function handleQuery(Query $query, callable $next, callable $first) + public function handleQuery(Query $query, callable $next, callable $first): Promise|GeocodeQuery { if (!$query instanceof GeocodeQuery) { return $next($query); diff --git a/Plugin/ProfilingPlugin.php b/Plugin/ProfilingPlugin.php index 9698a39a..6b394f1b 100644 --- a/Plugin/ProfilingPlugin.php +++ b/Plugin/ProfilingPlugin.php @@ -27,25 +27,18 @@ class ProfilingPlugin implements Plugin { /** - * @var array * @phpstan-var array */ - private $queries = []; + private array $queries = []; /** - * @var string service id of the provider + * @param string $name service id of the provider */ - private $name; - - public function __construct(string $name) + public function __construct(private string $name) { - $this->name = $name; } - /** - * @return Promise - */ - public function handleQuery(Query $query, callable $next, callable $first) + public function handleQuery(Query $query, callable $next, callable $first): Promise { $startTime = microtime(true); @@ -62,12 +55,7 @@ public function handleQuery(Query $query, callable $next, callable $first) }); } - /** - * @param mixed $result - * - * @return void - */ - private function logQuery(Query $query, float $duration, $result = null) + private function logQuery(Query $query, float $duration, mixed $result = null): void { if ($query instanceof GeocodeQuery) { $queryString = $query->getText(); diff --git a/ProviderFactory/AbstractFactory.php b/ProviderFactory/AbstractFactory.php index fd4eb7b2..531e5a3d 100644 --- a/ProviderFactory/AbstractFactory.php +++ b/ProviderFactory/AbstractFactory.php @@ -28,16 +28,10 @@ abstract class AbstractFactory implements ProviderFactoryInterface /** * @var array */ - protected static $dependencies = []; + protected static array $dependencies = []; - /** - * @var HttpClient|null - */ - protected $httpClient; - - public function __construct(HttpClient $httpClient = null) + public function __construct(protected ?HttpClient $httpClient = null) { - $this->httpClient = $httpClient; } /** @@ -50,7 +44,7 @@ abstract protected function getProvider(array $config): Provider; */ public function createProvider(array $options = []): Provider { - $this->verifyDependencies(); + self::verifyDependencies(); $resolver = new OptionsResolver(); static::configureOptionResolver($resolver); @@ -62,7 +56,7 @@ public function createProvider(array $options = []): Provider /** * {@inheritdoc} */ - public static function validate(array $options, $providerName) + public static function validate(array $options, string $providerName): void { static::verifyDependencies(); @@ -86,11 +80,9 @@ public static function validate(array $options, $providerName) /** * Make sure that we have the required class and throw and exception if we don't. * - * @return void - * * @throws \LogicException */ - protected static function verifyDependencies() + protected static function verifyDependencies(): void { foreach (static::$dependencies as $dependency) { if (!class_exists($dependency['requiredClass'])) { @@ -100,12 +92,10 @@ protected static function verifyDependencies() } /** - * By default we do not have any options to configure. A factory should override this function and confgure + * By default we do not have any options to configure. A factory should override this function and configure * the options resolver. - * - * @return void */ - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { } } diff --git a/ProviderFactory/AlgoliaFactory.php b/ProviderFactory/AlgoliaFactory.php index 54c33d7c..681739a5 100644 --- a/ProviderFactory/AlgoliaFactory.php +++ b/ProviderFactory/AlgoliaFactory.php @@ -20,7 +20,7 @@ final class AlgoliaFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => AlgoliaPlaces::class, 'packageName' => 'geocoder-php/algolia-places-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new AlgoliaPlaces($httplug, $config['api_key'], $config['app_id']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/ArcGISOnlineFactory.php b/ProviderFactory/ArcGISOnlineFactory.php index 9ea3ed0a..bf153520 100644 --- a/ProviderFactory/ArcGISOnlineFactory.php +++ b/ProviderFactory/ArcGISOnlineFactory.php @@ -20,7 +20,7 @@ final class ArcGISOnlineFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => ArcGISOnline::class, 'packageName' => 'geocoder-php/arcgis-online-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new ArcGISOnline($httplug, $config['source_country']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/BingMapsFactory.php b/ProviderFactory/BingMapsFactory.php index 9e8167fe..e5f74e0e 100644 --- a/ProviderFactory/BingMapsFactory.php +++ b/ProviderFactory/BingMapsFactory.php @@ -20,7 +20,7 @@ final class BingMapsFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => BingMaps::class, 'packageName' => 'geocoder-php/bing-maps-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new BingMaps($httplug, $config['api_key']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/ChainFactory.php b/ProviderFactory/ChainFactory.php index 0b078f49..8e364a2a 100644 --- a/ProviderFactory/ChainFactory.php +++ b/ProviderFactory/ChainFactory.php @@ -25,7 +25,7 @@ final class ChainFactory extends AbstractFactory implements LoggerAwareInterface { use LoggerAwareTrait; - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => Chain::class, 'packageName' => 'geocoder-php/chain-provider'], ]; @@ -45,7 +45,7 @@ protected function getProvider(array $config): Provider /** * {@inheritdoc} */ - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { parent::configureOptionResolver($resolver); diff --git a/ProviderFactory/FreeGeoIpFactory.php b/ProviderFactory/FreeGeoIpFactory.php index a09b7e2a..22ea9603 100644 --- a/ProviderFactory/FreeGeoIpFactory.php +++ b/ProviderFactory/FreeGeoIpFactory.php @@ -20,7 +20,7 @@ final class FreeGeoIpFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => FreeGeoIp::class, 'packageName' => 'geocoder-php/free-geoip-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new FreeGeoIp($httplug, $config['base_url']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/GeoIP2Factory.php b/ProviderFactory/GeoIP2Factory.php index 89911e8a..e59e2bcb 100644 --- a/ProviderFactory/GeoIP2Factory.php +++ b/ProviderFactory/GeoIP2Factory.php @@ -22,12 +22,14 @@ final class GeoIP2Factory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => GeoIP2::class, 'packageName' => 'geocoder-php/geoip2-provider'], ]; /** - * @phpstan-param array{provider: string, provider_service: ?ProviderInterface, model: string, user_id: string|int|null, license_key: string|null, locales: list, webservice_options: array, database_filename: ?string} $config + * @phpstan-param array{provider: string, provider_service: ?ProviderInterface, model: string, user_id: string|int|null, license_key: string|null, locales: list, webservice_options: array, database_filename: ?string} $config + * + * @throws \MaxMind\Db\Reader\InvalidDatabaseException */ protected function getProvider(array $config): Provider { @@ -47,7 +49,7 @@ protected function getProvider(array $config): Provider return new GeoIP2($adapter); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'model' => GeoIP2Adapter::GEOIP2_MODEL_CITY, diff --git a/ProviderFactory/GeoIPsFactory.php b/ProviderFactory/GeoIPsFactory.php deleted file mode 100644 index 9a203aac..00000000 --- a/ProviderFactory/GeoIPsFactory.php +++ /dev/null @@ -1,52 +0,0 @@ - GeoIPs::class, 'packageName' => 'geocoder-php/geoips-provider'], - ]; - - /** - * @phpstan-param array{api_key: string, httplug_client: ?HttpClient} $config - */ - protected function getProvider(array $config): Provider - { - @trigger_error('Bazinga\GeocoderBundle\ProviderFactory\GeoIPsFactory is deprecated since 5.6, to be removed in 6.0. See https://github.com/geocoder-php/Geocoder/issues/965', E_USER_DEPRECATED); - - $httplug = $config['httplug_client'] ?: $this->httpClient ?? HttpClientDiscovery::find(); - - return new GeoIPs($httplug, $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'httplug_client' => null, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - } -} diff --git a/ProviderFactory/GeoPluginFactory.php b/ProviderFactory/GeoPluginFactory.php index c3152d80..2aaf2580 100644 --- a/ProviderFactory/GeoPluginFactory.php +++ b/ProviderFactory/GeoPluginFactory.php @@ -20,7 +20,7 @@ final class GeoPluginFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => GeoPlugin::class, 'packageName' => 'geocoder-php/geo-plugin-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new GeoPlugin($httplug); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/GeoipFactory.php b/ProviderFactory/GeoipFactory.php deleted file mode 100644 index 0b4dbf4e..00000000 --- a/ProviderFactory/GeoipFactory.php +++ /dev/null @@ -1,36 +0,0 @@ - Geoip::class, 'packageName' => 'geocoder-php/geoip-provider'], - ]; - - /** - * @phpstan-param array{} $config - */ - protected function getProvider(array $config): Provider - { - return new Geoip(); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - } -} diff --git a/ProviderFactory/GeonamesFactory.php b/ProviderFactory/GeonamesFactory.php index bb5c751d..8bd3294d 100644 --- a/ProviderFactory/GeonamesFactory.php +++ b/ProviderFactory/GeonamesFactory.php @@ -20,7 +20,7 @@ final class GeonamesFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => Geonames::class, 'packageName' => 'geocoder-php/geonames-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new Geonames($httplug, $config['username']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/GoogleMapsFactory.php b/ProviderFactory/GoogleMapsFactory.php index ebdef6a5..9f2d110b 100644 --- a/ProviderFactory/GoogleMapsFactory.php +++ b/ProviderFactory/GoogleMapsFactory.php @@ -20,7 +20,7 @@ final class GoogleMapsFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => GoogleMaps::class, 'packageName' => 'geocoder-php/google-maps-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new GoogleMaps($httplug, $config['region'], $config['api_key']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/GoogleMapsPlacesFactory.php b/ProviderFactory/GoogleMapsPlacesFactory.php index 8d4b75d1..6b7754a9 100644 --- a/ProviderFactory/GoogleMapsPlacesFactory.php +++ b/ProviderFactory/GoogleMapsPlacesFactory.php @@ -20,7 +20,7 @@ final class GoogleMapsPlacesFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => GoogleMapsPlaces::class, 'packageName' => 'geocoder-php/google-maps-places-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new GoogleMapsPlaces($httplug, $config['api_key']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/HereFactory.php b/ProviderFactory/HereFactory.php index 9027f738..39f1a6b7 100644 --- a/ProviderFactory/HereFactory.php +++ b/ProviderFactory/HereFactory.php @@ -20,7 +20,7 @@ final class HereFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => Here::class, 'packageName' => 'geocoder-php/here-provider'], ]; @@ -46,7 +46,7 @@ protected function getProvider(array $config): Provider return new Here($httplug, $config['app_id'], $config['app_code'], $config['use_cit']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/HostIpFactory.php b/ProviderFactory/HostIpFactory.php index 549b6e77..fc2ea6ae 100644 --- a/ProviderFactory/HostIpFactory.php +++ b/ProviderFactory/HostIpFactory.php @@ -20,7 +20,7 @@ final class HostIpFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => HostIp::class, 'packageName' => 'geocoder-php/host-ip-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new HostIp($httplug); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/IpInfoDbFactory.php b/ProviderFactory/IpInfoDbFactory.php index ec487149..e1f8bccd 100644 --- a/ProviderFactory/IpInfoDbFactory.php +++ b/ProviderFactory/IpInfoDbFactory.php @@ -20,7 +20,7 @@ final class IpInfoDbFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => IpInfoDb::class, 'packageName' => 'geocoder-php/ip-info-db-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new IpInfoDb($httplug, $config['api_key'], $config['precision']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/IpInfoFactory.php b/ProviderFactory/IpInfoFactory.php index 48870f80..ad9bd862 100644 --- a/ProviderFactory/IpInfoFactory.php +++ b/ProviderFactory/IpInfoFactory.php @@ -20,7 +20,7 @@ final class IpInfoFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => IpInfo::class, 'packageName' => 'geocoder-php/ip-info-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new IpInfo($httplug); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/IpstackFactory.php b/ProviderFactory/IpstackFactory.php index e00d0828..4926dc3d 100644 --- a/ProviderFactory/IpstackFactory.php +++ b/ProviderFactory/IpstackFactory.php @@ -20,7 +20,7 @@ final class IpstackFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => Ipstack::class, 'packageName' => 'geocoder-php/ipstack-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new Ipstack($httplug, $config['api_key']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/LocationIQFactory.php b/ProviderFactory/LocationIQFactory.php index c383e056..879ef133 100644 --- a/ProviderFactory/LocationIQFactory.php +++ b/ProviderFactory/LocationIQFactory.php @@ -18,7 +18,7 @@ final class LocationIQFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => LocationIQ::class, 'packageName' => 'geocoder-php/locationiq-provider'], ]; @@ -32,7 +32,7 @@ protected function getProvider(array $config): Provider return new LocationIQ($httplug, $config['api_key']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/MapQuestFactory.php b/ProviderFactory/MapQuestFactory.php index 9c0f6901..21f73f28 100644 --- a/ProviderFactory/MapQuestFactory.php +++ b/ProviderFactory/MapQuestFactory.php @@ -20,7 +20,7 @@ final class MapQuestFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => MapQuest::class, 'packageName' => 'geocoder-php/mapquest-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new MapQuest($httplug, $config['api_key'], $config['licensed']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/MapboxFactory.php b/ProviderFactory/MapboxFactory.php index 1f3e110c..6b5e2fb7 100644 --- a/ProviderFactory/MapboxFactory.php +++ b/ProviderFactory/MapboxFactory.php @@ -18,7 +18,7 @@ final class MapboxFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => Mapbox::class, 'packageName' => 'geocoder-php/mapbox-provider'], ]; @@ -32,7 +32,7 @@ protected function getProvider(array $config): Provider return new Mapbox($httplug, $config['api_key'], $config['country'], $config['mode']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/MapzenFactory.php b/ProviderFactory/MapzenFactory.php deleted file mode 100644 index 509e6bbe..00000000 --- a/ProviderFactory/MapzenFactory.php +++ /dev/null @@ -1,52 +0,0 @@ - Mapzen::class, 'packageName' => 'geocoder-php/mapzen-provider'], - ]; - - /** - * @phpstan-param array{api_key: string, httplug_client: ?HttpClient} $config - */ - protected function getProvider(array $config): Provider - { - @trigger_error('Bazinga\GeocoderBundle\ProviderFactory\MapzenFactory is deprecated since 5.6, to be removed in 6.0. See https://github.com/geocoder-php/Geocoder/issues/808', E_USER_DEPRECATED); - - $httplug = $config['httplug_client'] ?: $this->httpClient ?? HttpClientDiscovery::find(); - - return new Mapzen($httplug, $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'httplug_client' => null, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('httplug_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - } -} diff --git a/ProviderFactory/MaxMindBinaryFactory.php b/ProviderFactory/MaxMindBinaryFactory.php index 8b37b09b..86363920 100644 --- a/ProviderFactory/MaxMindBinaryFactory.php +++ b/ProviderFactory/MaxMindBinaryFactory.php @@ -18,7 +18,7 @@ final class MaxMindBinaryFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => MaxMindBinary::class, 'packageName' => 'geocoder-php/maxmind-binary-provider'], ]; @@ -30,7 +30,7 @@ protected function getProvider(array $config): Provider return new MaxMindBinary($config['dat_file'], $config['open_flag']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'open_flag' => null, diff --git a/ProviderFactory/MaxMindFactory.php b/ProviderFactory/MaxMindFactory.php index ae747696..957b4e51 100644 --- a/ProviderFactory/MaxMindFactory.php +++ b/ProviderFactory/MaxMindFactory.php @@ -20,7 +20,7 @@ final class MaxMindFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => MaxMind::class, 'packageName' => 'geocoder-php/maxmind-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new MaxMind($httplug, $config['api_key'], $config['endpoint']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/NominatimFactory.php b/ProviderFactory/NominatimFactory.php index 6150465d..546501e9 100644 --- a/ProviderFactory/NominatimFactory.php +++ b/ProviderFactory/NominatimFactory.php @@ -20,7 +20,7 @@ final class NominatimFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => Nominatim::class, 'packageName' => 'geocoder-php/nominatim-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new Nominatim($httplug, $config['root_url'], $config['user_agent']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/OpenCageFactory.php b/ProviderFactory/OpenCageFactory.php index 57ab893b..86f807b4 100644 --- a/ProviderFactory/OpenCageFactory.php +++ b/ProviderFactory/OpenCageFactory.php @@ -20,7 +20,7 @@ final class OpenCageFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => OpenCage::class, 'packageName' => 'geocoder-php/open-cage-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new OpenCage($httplug, $config['api_key']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/PickPointFactory.php b/ProviderFactory/PickPointFactory.php index cf7a265d..fa6bd88a 100644 --- a/ProviderFactory/PickPointFactory.php +++ b/ProviderFactory/PickPointFactory.php @@ -20,7 +20,7 @@ final class PickPointFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => PickPoint::class, 'packageName' => 'geocoder-php/pickpoint-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new PickPoint($httplug, $config['api_key']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/PluginProviderFactory.php b/ProviderFactory/PluginProviderFactory.php index 14c013a2..19675eca 100644 --- a/ProviderFactory/PluginProviderFactory.php +++ b/ProviderFactory/PluginProviderFactory.php @@ -23,14 +23,13 @@ final class PluginProviderFactory { /** - * @param Plugin[] $plugins - * @param ProviderFactoryInterface|callable $factory - * @param array $config config to the client factory - * @param array $pluginProviderOptions config forwarded to the PluginProvider + * @param Plugin[] $plugins + * @param array $config config to the client factory + * @param array $pluginProviderOptions config forwarded to the PluginProvider * @phpstan-param array $config * @phpstan-param array $pluginProviderOptions */ - public static function createPluginProvider(array $plugins, $factory, array $config, array $pluginProviderOptions = []): PluginProvider + public static function createPluginProvider(array $plugins, callable|ProviderFactoryInterface $factory, array $config, array $pluginProviderOptions = []): PluginProvider { if ($factory instanceof ProviderFactoryInterface) { $client = $factory->createProvider($config); diff --git a/ProviderFactory/ProviderFactoryInterface.php b/ProviderFactory/ProviderFactoryInterface.php index 41af5e62..642441e4 100644 --- a/ProviderFactory/ProviderFactoryInterface.php +++ b/ProviderFactory/ProviderFactoryInterface.php @@ -31,8 +31,6 @@ public function createProvider(array $options = []): Provider; * @param string $providerName the name the user has chosen for this provider * @phpstan-param array $options * - * @return void - * * @throws \LogicException If the factory has missing dependencies * @throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException If an option name is undefined * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException If an option doesn't fulfill the specified validation rules @@ -41,5 +39,5 @@ public function createProvider(array $options = []): Provider; * @throws \Symfony\Component\OptionsResolver\Exception\NoSuchOptionException If a lazy option reads an unavailable option * @throws \Symfony\Component\OptionsResolver\Exception\AccessException If called from a lazy option or normalizer */ - public static function validate(array $options, $providerName); + public static function validate(array $options, string $providerName): void; } diff --git a/ProviderFactory/TomTomFactory.php b/ProviderFactory/TomTomFactory.php index 44a27683..1444656b 100644 --- a/ProviderFactory/TomTomFactory.php +++ b/ProviderFactory/TomTomFactory.php @@ -20,7 +20,7 @@ final class TomTomFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => TomTom::class, 'packageName' => 'geocoder-php/tomtom-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new TomTom($httplug, $config['api_key']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/ProviderFactory/YandexFactory.php b/ProviderFactory/YandexFactory.php index 53ccceb0..05dc5f29 100644 --- a/ProviderFactory/YandexFactory.php +++ b/ProviderFactory/YandexFactory.php @@ -20,7 +20,7 @@ final class YandexFactory extends AbstractFactory { - protected static $dependencies = [ + protected static array $dependencies = [ ['requiredClass' => Yandex::class, 'packageName' => 'geocoder-php/yandex-provider'], ]; @@ -34,7 +34,7 @@ protected function getProvider(array $config): Provider return new Yandex($httplug, $config['toponym'], $config['api_key']); } - protected static function configureOptionResolver(OptionsResolver $resolver) + protected static function configureOptionResolver(OptionsResolver $resolver): void { $resolver->setDefaults([ 'httplug_client' => null, diff --git a/Resources/doc/cache.md b/Resources/doc/cache.md index 11a3f09d..3bf6a866 100644 --- a/Resources/doc/cache.md +++ b/Resources/doc/cache.md @@ -44,7 +44,7 @@ bazinga_geocoder: ```yaml # services.yml -servies: +services: my_cached_geocoder: class: Geocoder\Provider\Cache\ProviderCache arguments: ['@bazinga_geocoder.provider.acme', '@any.psr16.service', 3600] diff --git a/Resources/doc/custom-provider.md b/Resources/doc/custom-provider.md index da856fbf..17904063 100644 --- a/Resources/doc/custom-provider.md +++ b/Resources/doc/custom-provider.md @@ -12,7 +12,7 @@ If you want to use your own provider in your application, create a service, and ``` The bundle will automatically register your provider into the`Geocoder\ProviderAggregator` service. However, it will not -show up the the web profiler because it is not registered with the [PluginProvider](/Resources/doc/plugins.md). +show up the web profiler because it is not registered with the [PluginProvider](/Resources/doc/plugins.md). If you want your provider to show up the web profiler you have to create a custom factory for your provider. diff --git a/Resources/doc/plugins.md b/Resources/doc/plugins.md index c6d39d95..dfac720b 100644 --- a/Resources/doc/plugins.md +++ b/Resources/doc/plugins.md @@ -24,7 +24,7 @@ may then use the `QueryDataPlugin`. ```yaml # services.yml -sevices: +services: app.query_data_plugin: class: Geocoder\Plugin\Plugin\QueryDataPlugin arguments: diff --git a/Resources/doc/services.md b/Resources/doc/services.md index d2f61e1f..41e8b5d7 100644 --- a/Resources/doc/services.md +++ b/Resources/doc/services.md @@ -17,7 +17,6 @@ Here is a list of all provider factories and their options. | `Bazinga\GeocoderBundle\ProviderFactory\FreeGeoIpFactory` | httplug_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 @@ -30,7 +29,6 @@ Here is a list of all provider factories and their options. | `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\MaxMindBinaryFactory` | dat_file, open_flag | `Bazinga\GeocoderBundle\ProviderFactory\MaxMindFactory` | httplug_client, api_key, endpoint | `Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory` | httplug_client, root_url diff --git a/Tests/Command/GeocodeCommandTest.php b/Tests/Command/GeocodeCommandTest.php index a13de67c..e1b30b04 100644 --- a/Tests/Command/GeocodeCommandTest.php +++ b/Tests/Command/GeocodeCommandTest.php @@ -30,7 +30,7 @@ */ class GeocodeCommandTest extends TestCase { - private static $address = '10 rue Gambetta, Paris, France'; + private static string $address = '10 rue Gambetta, Paris, France'; public function testExecute(): void { diff --git a/Tests/DependencyInjection/Compiler/AddProvidersPassTest.php b/Tests/DependencyInjection/Compiler/AddProvidersPassTest.php index 8e5a276f..ee38db42 100644 --- a/Tests/DependencyInjection/Compiler/AddProvidersPassTest.php +++ b/Tests/DependencyInjection/Compiler/AddProvidersPassTest.php @@ -22,10 +22,7 @@ class AddProvidersPassTest extends TestCase { - /** - * @var AddProvidersPass - */ - private $compilerPass; + private AddProvidersPass $compilerPass; protected function setUp(): void { diff --git a/Tests/DependencyInjection/Compiler/FactoryValidatorPassTest.php b/Tests/DependencyInjection/Compiler/FactoryValidatorPassTest.php index 099f506b..6c8e48bf 100644 --- a/Tests/DependencyInjection/Compiler/FactoryValidatorPassTest.php +++ b/Tests/DependencyInjection/Compiler/FactoryValidatorPassTest.php @@ -19,15 +19,9 @@ class FactoryValidatorPassTest extends TestCase { - /** - * @var FactoryValidatorPass - */ - private $compilerPass; + private FactoryValidatorPass $compilerPass; - /** - * @var string - */ - private $factoryId; + private string $factoryId; protected function setUp(): void { diff --git a/Tests/DependencyInjection/Compiler/ProfilerPassTest.php b/Tests/DependencyInjection/Compiler/ProfilerPassTest.php index e7b8e458..6d34d59f 100644 --- a/Tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/ProfilerPassTest.php @@ -22,10 +22,7 @@ class ProfilerPassTest extends TestCase { - /** - * @var ProfilerPass - */ - private $compilerPass; + private ProfilerPass $compilerPass; protected function setUp(): void { diff --git a/Tests/Doctrine/ORM/GeocoderListenerTest.php b/Tests/Doctrine/ORM/GeocoderListenerTest.php index 667a6a60..c4b87409 100644 --- a/Tests/Doctrine/ORM/GeocoderListenerTest.php +++ b/Tests/Doctrine/ORM/GeocoderListenerTest.php @@ -39,15 +39,9 @@ */ class GeocoderListenerTest extends OrmTestCase { - /** - * @var EntityManager - */ - private $em; + private EntityManager $em; - /** - * @var GeocoderListener - */ - private $listener; + private GeocoderListener $listener; public static function setUpBeforeClass(): void { @@ -255,7 +249,7 @@ class DummyWithGetter */ private $_address; - public function setAddress($address) + public function setAddress($address): void { $this->_address = $address; } @@ -273,7 +267,7 @@ public function getLatitude() return $this->latitude; } - public function setLatitude($latitude) + public function setLatitude($latitude): void { $this->latitude = $latitude; } @@ -283,7 +277,7 @@ public function getLongitude() return $this->longitude; } - public function setLongitude($longitude) + public function setLongitude($longitude): void { $this->longitude = $longitude; } @@ -318,7 +312,7 @@ class DummyWithInvalidGetter */ private $_address; - public function setAddress($address) + public function setAddress($address): void { $this->_address = $address; } @@ -336,7 +330,7 @@ public function getLatitude() return $this->latitude; } - public function setLatitude($latitude) + public function setLatitude($latitude): void { $this->latitude = $latitude; } @@ -346,7 +340,7 @@ public function getLongitude() return $this->longitude; } - public function setLongitude($longitude) + public function setLongitude($longitude): void { $this->longitude = $longitude; } @@ -385,7 +379,7 @@ class DummyWithEmptyProperty class TrackedCurlClient extends Client { - private $responses = []; + private array $responses = []; public function sendRequest(RequestInterface $request): ResponseInterface { diff --git a/Tests/Functional/ProviderFactoryTest.php b/Tests/Functional/ProviderFactoryTest.php index 73fa31f0..df121cd9 100644 --- a/Tests/Functional/ProviderFactoryTest.php +++ b/Tests/Functional/ProviderFactoryTest.php @@ -19,9 +19,7 @@ use Geocoder\Provider\BingMaps\BingMaps; use Geocoder\Provider\Chain\Chain; use Geocoder\Provider\FreeGeoIp\FreeGeoIp; -use Geocoder\Provider\Geoip\Geoip; use Geocoder\Provider\GeoIP2\GeoIP2; -use Geocoder\Provider\GeoIPs\GeoIPs; use Geocoder\Provider\Geonames\Geonames; use Geocoder\Provider\GeoPlugin\GeoPlugin; use Geocoder\Provider\GoogleMaps\GoogleMaps; @@ -34,7 +32,6 @@ use Geocoder\Provider\LocationIQ\LocationIQ; use Geocoder\Provider\Mapbox\Mapbox; use Geocoder\Provider\MapQuest\MapQuest; -use Geocoder\Provider\Mapzen\Mapzen; use Geocoder\Provider\MaxMind\MaxMind; use Geocoder\Provider\MaxMindBinary\MaxMindBinary; use Geocoder\Provider\Nominatim\Nominatim; @@ -93,11 +90,7 @@ public function getProviders(): iterable yield [BingMaps::class, ['acme']]; yield [Chain::class, ['acme']]; yield [FreeGeoIp::class, ['empty', 'acme']]; - //yield [Geoip::class, ['empty']]; yield [GeoIP2::class, ['acme']]; - if (class_exists(GeoIPs::class)) { - yield [GeoIPs::class, ['acme']]; - } yield [Geonames::class, ['acme']]; yield [GeoPlugin::class, ['empty']]; yield [GoogleMaps::class, ['empty']]; @@ -110,9 +103,6 @@ public function getProviders(): iterable yield [LocationIQ::class, ['acme']]; yield [Mapbox::class, ['acme']]; yield [MapQuest::class, ['acme']]; - if (class_exists(Mapzen::class)) { - yield [Mapzen::class, ['acme']]; - } yield [MaxMind::class, ['acme']]; yield [MaxMindBinary::class, ['acme']]; yield [Nominatim::class, ['empty', 'acme']]; diff --git a/Tests/Functional/config/provider/geoips.yml b/Tests/Functional/config/provider/geoips.yml deleted file mode 100644 index 769d4c7d..00000000 --- a/Tests/Functional/config/provider/geoips.yml +++ /dev/null @@ -1,9 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GeoIPsFactory - options: - api_key: 'foo' - diff --git a/Tests/Functional/config/provider/mapzen.yml b/Tests/Functional/config/provider/mapzen.yml deleted file mode 100644 index 9b68737f..00000000 --- a/Tests/Functional/config/provider/mapzen.yml +++ /dev/null @@ -1,9 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\MapzenFactory - options: - api_key: 'bar' - diff --git a/Tests/Mapping/Driver/AnnotationDriverTest.php b/Tests/Mapping/Driver/AnnotationDriverTest.php index 84354583..9dce8e54 100644 --- a/Tests/Mapping/Driver/AnnotationDriverTest.php +++ b/Tests/Mapping/Driver/AnnotationDriverTest.php @@ -12,6 +12,10 @@ namespace Bazinga\GeocoderBundle\Tests\Mapping\Driver; +use Bazinga\GeocoderBundle\Mapping\Annotations\Address; +use Bazinga\GeocoderBundle\Mapping\Annotations\Geocodeable; +use Bazinga\GeocoderBundle\Mapping\Annotations\Latitude; +use Bazinga\GeocoderBundle\Mapping\Annotations\Longitude; use Bazinga\GeocoderBundle\Mapping\Driver\AnnotationDriver; use Bazinga\GeocoderBundle\Mapping\Exception\MappingException; use Doctrine\Common\Annotations\AnnotationRegistry; @@ -24,15 +28,9 @@ */ class AnnotationDriverTest extends TestCase { - /** - * @var AnnotationDriver - */ - private $driver; + private AnnotationDriver $driver; - /** - * @var Reader - */ - private $reader; + private SimpleAnnotationReader|Reader $reader; protected function setUp(): void { diff --git a/Tests/Mapping/Driver/AttributeDriverTest.php b/Tests/Mapping/Driver/AttributeDriverTest.php index a2ec185a..73088118 100644 --- a/Tests/Mapping/Driver/AttributeDriverTest.php +++ b/Tests/Mapping/Driver/AttributeDriverTest.php @@ -25,17 +25,7 @@ */ final class AttributeDriverTest extends TestCase { - /** - * @var AttributeDriver - */ - private $driver; - - public static function setUpBeforeClass(): void - { - if (PHP_VERSION_ID < 80000) { - self::markTestSkipped(sprintf('"%s" is only supported on PHP 8', AttributeDriver::class)); - } - } + private AttributeDriver $driver; protected function setUp(): void { @@ -75,16 +65,16 @@ public function testIsGeocodable(): void } } -#[Geocodeable()] +#[Geocodeable] class Dummy3 { - #[Latitude()] + #[Latitude] public $latitude; - #[Longitude()] + #[Longitude] public $longitude; - #[Address()] + #[Address] public $address; } diff --git a/Tests/Plugin/FakeIpPluginTest.php b/Tests/Plugin/FakeIpPluginTest.php index 4997763c..8167d955 100644 --- a/Tests/Plugin/FakeIpPluginTest.php +++ b/Tests/Plugin/FakeIpPluginTest.php @@ -28,7 +28,7 @@ public function testSimpleHandleQuery(): void $query = GeocodeQuery::create('127.0.0.1'); /** @var Query $query */ - $query = $fakeIpPlugin->handleQuery($query, function (Query $query) { return $query; }, function () {}); + $query = $fakeIpPlugin->handleQuery($query, function (Query $query) { return $query; }, static function () {}); $this->assertSame($query->getText(), '123.123.123.123'); } @@ -43,7 +43,7 @@ public function testEmptyLocalIpQuery(?string $localIp): void $query = GeocodeQuery::create('124.124.124.124'); /** @var Query $query */ - $query = $fakeIpPlugin->handleQuery($query, function (Query $query) { return $query; }, function () {}); + $query = $fakeIpPlugin->handleQuery($query, function (Query $query) { return $query; }, static function () {}); $this->assertSame($query->getText(), '123.123.123.123'); } @@ -54,7 +54,7 @@ public function testHandleQueryUsingFaker(): void $query = GeocodeQuery::create('127.0.0.1'); /** @var Query $query */ - $query = $fakeIpPlugin->handleQuery($query, function (Query $query) { return $query; }, function () {}); + $query = $fakeIpPlugin->handleQuery($query, function (Query $query) { return $query; }, static function () {}); $this->assertNotSame($query->getText(), '192.168.1.1'); } diff --git a/Tests/PublicServicePass.php b/Tests/PublicServicePass.php index daff186f..849c6f5b 100644 --- a/Tests/PublicServicePass.php +++ b/Tests/PublicServicePass.php @@ -26,20 +26,15 @@ final class PublicServicePass implements CompilerPassInterface { /** * A regex to match the services that should be public. - * - * @var string */ - private $regex; + private string $regex; - /** - * @param string $regex - */ - public function __construct($regex = '|.*|') + public function __construct(string $regex = '|.*|') { $this->regex = $regex; } - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { foreach ($container->getDefinitions() as $id => $definition) { if (preg_match($this->regex, $id)) { diff --git a/Validator/Constraint/Address.php b/Validator/Constraint/Address.php index 40cdc9cd..935b9431 100644 --- a/Validator/Constraint/Address.php +++ b/Validator/Constraint/Address.php @@ -30,15 +30,9 @@ class Address extends Constraint self::INVALID_ADDRESS_ERROR => 'INVALID_ADDRESS_ERROR', ]; - /** - * @var string - */ - public $service = AddressValidator::class; + public string $service = AddressValidator::class; - /** - * @var string - */ - public $message = 'Address {{ address }} is not valid.'; + public string $message = 'Address {{ address }} is not valid.'; /** * @param string[]|null $options diff --git a/Validator/Constraint/AddressValidator.php b/Validator/Constraint/AddressValidator.php index a01ff13a..5c8b7db9 100644 --- a/Validator/Constraint/AddressValidator.php +++ b/Validator/Constraint/AddressValidator.php @@ -25,22 +25,11 @@ */ class AddressValidator extends ConstraintValidator { - /** - * @var Provider - */ - protected $addressGeocoder; - - public function __construct(Provider $addressGeocoder) + public function __construct(protected Provider $addressGeocoder) { - $this->addressGeocoder = $addressGeocoder; } - /** - * @param mixed $value - * - * @return void - */ - public function validate($value, Constraint $constraint) + public function validate(mixed $value, Constraint $constraint): void { if (!$constraint instanceof Address) { throw new UnexpectedTypeException($constraint, Address::class); @@ -67,10 +56,7 @@ public function validate($value, Constraint $constraint) } } - /** - * @return void - */ - private function buildViolation(Address $constraint, string $address) + private function buildViolation(Address $constraint, string $address): void { $this->context->buildViolation($constraint->message) ->setParameter('{{ address }}', $this->formatValue($address)) diff --git a/composer.json b/composer.json index bb22fad2..e2ec1f46 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,13 @@ } ], "require": { - "php": "^7.3 || ^8.0", - "geocoder-php/plugin": "^1.3", + "php": "^8.0", + "geocoder-php/plugin": "^1.4", "php-http/discovery": "^1.13", - "symfony/console": "^4.4 || ^5.0 || ^6.0", - "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0", - "symfony/options-resolver": "^4.4 || ^5.0 || ^6.0", - "willdurand/geocoder": "^4.4" + "symfony/console": "^4.4 || ^5.4 || ^6.0", + "symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0", + "symfony/options-resolver": "^4.4 || ^5.4 || ^6.0", + "willdurand/geocoder": "^4.5" }, "require-dev": { "doctrine/orm": "~2.8", @@ -27,11 +27,10 @@ "geocoder-php/arcgis-online-provider": "^4.3", "geocoder-php/bing-maps-provider": "^4.2", "geocoder-php/cache-provider": "^4.3", - "geocoder-php/chain-provider": "^4.3", - "geocoder-php/free-geoip-provider": "^4.3", + "geocoder-php/chain-provider": "^4.4", + "geocoder-php/free-geoip-provider": "^4.4", "geocoder-php/geo-plugin-provider": "^4.2", "geocoder-php/geoip2-provider": "^4.2", - "geocoder-php/geoips-provider": "^4.0", "geocoder-php/geonames-provider": "^4.3", "geocoder-php/google-maps-places-provider": "^1.3", "geocoder-php/google-maps-provider": "^4.6", @@ -43,23 +42,22 @@ "geocoder-php/locationiq-provider": "^1.2", "geocoder-php/mapbox-provider": "^1.3", "geocoder-php/mapquest-provider": "^4.2", - "geocoder-php/mapzen-provider": "^4.0", "geocoder-php/maxmind-binary-provider": "^4.2", "geocoder-php/maxmind-provider": "^4.3", - "geocoder-php/nominatim-provider": "^5.4", + "geocoder-php/nominatim-provider": "^5.5", "geocoder-php/open-cage-provider": "^4.5", "geocoder-php/pickpoint-provider": "^4.2", "geocoder-php/tomtom-provider": "^4.2", "geocoder-php/yandex-provider": "^4.4", "geoip/geoip": "~1.17", - "nyholm/nsa": "^1.2", - "nyholm/psr7": "^1.3", + "nyholm/nsa": "^1.3", + "nyholm/psr7": "^1.5", "nyholm/symfony-bundle-test": "dev-master", "php-http/curl-client": "^2.2", "php-http/message": "^1.5", - "phpstan/phpstan": "^1.2", + "phpstan/phpstan": "^1.6", "symfony/config": "^4.4 || ^5.0 || ^6.0", - "symfony/phpunit-bridge": "^5.2 || ^6.0", + "symfony/phpunit-bridge": "^6.0", "symfony/validator": "^4.4 || ^5.0 || ^6.0", "symfony/yaml": "^4.4 || ^5.0 || ^6.0" }, diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c58ec88f..f14898b7 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -10,5 +10,5 @@ parameters: path: %currentWorkingDirectory%/DependencyInjection/Configuration.php message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::(end|variableNode)#' - - path: %currentWorkingDirectory%/ProviderFactory/GeoipFactory.php - message: '#Geocoder\\Provider\\Geoip\\Geoip#' + path: %currentWorkingDirectory%/ProviderFactory/GeoIP2Factory.php + message: '#has parameter \$config with no value type specified in iterable type array#' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a2164d55..3d7c47d4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ - - - - - ./Tests - ./Tests/Doctrine - - - ./Tests/Doctrine - - - - - - . - - ./Resources - ./Tests - ./vendor - - - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + + . + + + ./Resources + ./Tests + ./vendor + + + + + ./Tests + ./Tests/Doctrine + + + ./Tests/Doctrine + +