diff --git a/.editorconfig b/.editorconfig index 68a969e..ac0010b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,5 +8,18 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true -[*.{yml,yaml}] +[.github/**/*.{yml,yaml}] indent_size = 2 + +[*.{yml,yaml}] +trim_trailing_whitespace = false + +[**.md] +indent_size = unset +indent_style = unset + +[*.json] +insert_final_newline = false + +[*.{neon,neon.dist}] +indent_style = tab diff --git a/composer.json b/composer.json index 0cf72da..6df5d55 100644 --- a/composer.json +++ b/composer.json @@ -74,9 +74,6 @@ "symfony/var-exporter": "^5.4 || ^6.4 || ^7.0", "symfony/yaml": "^5.4 || ^6.4 || ^7.0" }, - "conflict": { - "geocoder-php/nominatim-provider": "<5.0" - }, "autoload": { "psr-4": { "Bazinga\\GeocoderBundle\\": "src/" @@ -88,7 +85,7 @@ } }, "scripts": { - "test": "vendor/bin/simple-phpunit --testsuite main" + "test": "SYMFONY_DEPRECATIONS_HELPER=ignoreFile='./tests/baseline-ignore' vendor/bin/simple-phpunit --testsuite main" }, "config": { "allow-plugins": { diff --git a/config/profiling.php b/config/profiling.php new file mode 100644 index 0000000..14608eb --- /dev/null +++ b/config/profiling.php @@ -0,0 +1,14 @@ +services(); + + $services->set(GeocoderDataCollector::class) + ->tag('data_collector', ['template' => '@BazingaGeocoder/Collector/geocoder.html.twig', 'id' => 'geocoder']); +}; diff --git a/config/profiling.yml b/config/profiling.yml deleted file mode 100644 index 5a399da..0000000 --- a/config/profiling.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - Bazinga\GeocoderBundle\DataCollector\GeocoderDataCollector: - class: Bazinga\GeocoderBundle\DataCollector\GeocoderDataCollector - public: false - tags: - - { name: data_collector, template: '@BazingaGeocoder/Collector/geocoder.html.twig', id: 'geocoder' } diff --git a/config/services.php b/config/services.php new file mode 100644 index 0000000..e8dce8c --- /dev/null +++ b/config/services.php @@ -0,0 +1,53 @@ +services(); + $services->instanceof(Dumper::class) + ->public(); + + $services + ->set(GeoArray::class) + ->set(GeoJson::class) + ->set(Gpx::class) + ->set(Kml::class) + ->set(Wkb::class) + ->set(Wkt::class) + + ->load('Bazinga\\GeocoderBundle\\ProviderFactory\\', __DIR__.'/../src/ProviderFactory') + ->autowire() + ->autoconfigure() + + ->set(ProviderAggregator::class) + + ->set(FakeIpPlugin::class) + ->args([null, null, false]) + + ->set(GeocodeCommand::class) + ->args([ + service(ProviderAggregator::class), + ]) + ->tag('console.command') + + ->set(AddressValidator::class) + ->args([ + service(ProviderAggregator::class), + ]) + ->tag('validator.constraint_validator') + ; +}; diff --git a/config/services.yml b/config/services.yml deleted file mode 100644 index aa01e01..0000000 --- a/config/services.yml +++ /dev/null @@ -1,41 +0,0 @@ -services: - _instanceof: - Geocoder\Dumper\Dumper: - tags: ['bazinga_geocoder.dumper'] - public: true - - Geocoder\Dumper\GeoArray: ~ - Geocoder\Dumper\GeoJson: ~ - Geocoder\Dumper\Gpx: ~ - Geocoder\Dumper\Kml: ~ - Geocoder\Dumper\Wkb: ~ - Geocoder\Dumper\Wkt: ~ - - Bazinga\GeocoderBundle\ProviderFactory\: - resource: '../src/ProviderFactory' - public: false - autowire: true - autoconfigure: true - - Geocoder\ProviderAggregator: - class: Geocoder\ProviderAggregator - - Bazinga\GeocoderBundle\Plugin\FakeIpPlugin: - class: Bazinga\GeocoderBundle\Plugin\FakeIpPlugin - arguments: [~, ~, false] - - Bazinga\GeocoderBundle\Command\GeocodeCommand: - arguments: ['@Geocoder\ProviderAggregator'] - tags: - - { name: 'console.command', command: 'geocoder:geocode', description: 'Geocode an address or a ip address' } - - Bazinga\GeocoderBundle\Validator\Constraint\AddressValidator: - arguments: ['@geocoder'] - tags: ['validator.constraint_validator'] - - # Keep these aliases for BC purpose - bazinga_geocoder.geocoder: - alias: "Geocoder\\ProviderAggregator" - - geocoder: - alias: "Geocoder\\ProviderAggregator" diff --git a/src/Command/GeocodeCommand.php b/src/Command/GeocodeCommand.php index e4de483..d17afa7 100644 --- a/src/Command/GeocodeCommand.php +++ b/src/Command/GeocodeCommand.php @@ -24,7 +24,7 @@ /** * @author Markus Bachmann */ -#[AsCommand(name: 'geocoder:geocode', description: 'Geocode an address or a ip address')] +#[AsCommand(name: 'geocoder:geocode', description: 'Geocode an address or an IP address')] class GeocodeCommand extends Command { private ProviderAggregator $geocoder; diff --git a/src/DependencyInjection/BazingaGeocoderExtension.php b/src/DependencyInjection/BazingaGeocoderExtension.php index 9ea854a..c9abda2 100644 --- a/src/DependencyInjection/BazingaGeocoderExtension.php +++ b/src/DependencyInjection/BazingaGeocoderExtension.php @@ -31,7 +31,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use Symfony\Component\DependencyInjection\Extension\Extension; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\DependencyInjection\Reference; /** @@ -50,11 +50,11 @@ public function load(array $configs, ContainerBuilder $container) $configuration = $this->getConfiguration($configs, $container); $config = $processor->processConfiguration($configuration, $configs); - $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../../config')); - $loader->load('services.yml'); + $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../config')); + $loader->load('services.php'); if (true === $config['profiling']['enabled']) { - $loader->load('profiling.yml'); + $loader->load('profiling.php'); } if ($config['fake_ip']['enabled']) { diff --git a/tests/Functional/BundleInitializationTest.php b/tests/Functional/BundleInitializationTest.php index 4e91031..705b303 100644 --- a/tests/Functional/BundleInitializationTest.php +++ b/tests/Functional/BundleInitializationTest.php @@ -160,28 +160,6 @@ public function testBundleWithPluginsYml(): void self::assertInstanceOf(LoggerPlugin::class, $plugins[0]); } - public function testBundleWithPluginXml(): 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/service_plugin.xml'); - }]); - - $container = self::getContainer(); - - self::assertTrue($container->has('bazinga_geocoder.provider.acme')); - $service = $container->get('bazinga_geocoder.provider.acme'); - self::assertInstanceOf(PluginProvider::class, $service); - $plugins = NSA::getProperty($service, 'plugins'); - self::assertNotEmpty($plugins); - self::assertInstanceOf(LoggerPlugin::class, $plugins[0]); - } - public function testBundleHasRegisteredDumpers(): void { self::bootKernel(['config' => static function (TestKernel $kernel) { diff --git a/tests/Functional/config/service_plugin.xml b/tests/Functional/config/service_plugin.xml deleted file mode 100644 index 67dbd80..0000000 --- a/tests/Functional/config/service_plugin.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - acme.logger - - - - - - - - - - - diff --git a/tests/baseline-ignore b/tests/baseline-ignore index 83bf6c9..d9f6ca3 100644 --- a/tests/baseline-ignore +++ b/tests/baseline-ignore @@ -88,3 +88,4 @@ %Not enabling native lazy objects is deprecated and will be impossible in Doctrine ORM 4.0% %Not setting "doctrine.orm.enable_native_lazy_objects" to true is deprecated% %Disabling native lazy objects is deprecated and will be impossible in Doctrine ORM 4.0% +%Class "Nyholm\\Psr7\\Factory\\HttplugFactory" is deprecated since version 1.8, use "Nyholm\\Psr7\\Factory\\Psr17Factory" instead%