diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index ac0010b8..00000000 --- a/.editorconfig +++ /dev/null @@ -1,25 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[.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/.gitattributes b/.gitattributes deleted file mode 100644 index 69a7d65d..00000000 --- a/.gitattributes +++ /dev/null @@ -1,12 +0,0 @@ -/.github/ export-ignore -/doc/ export-ignore -/tests/ export-ignore -/.editorconfig export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.php-cs-fixer.php export-ignore -/CODE_OF_CONDUCT.md export-ignore -/CONTRIBUTING.md export-ignore -/phpstan.neon.dist export-ignore -/phpstan-baseline.neon export-ignore -/phpunit.xml.dist export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 1838cdb2..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: CI -on: [ push, pull_request ] - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - phpstan: - name: PHPStan - runs-on: ubuntu-latest - env: - php-version: 8.4 - steps: - - name: "Setup PHP" - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ env.php-version }} - tools: flex - - - name: "Checkout code" - uses: actions/checkout@v4 - - - name: "Install Composer dependencies" - uses: "ramsey/composer-install@v3" - with: - composer-options: "--optimize-autoloader" - - - name: "Run PHPStan" - run: | - vendor/bin/simple-phpunit --version - vendor/bin/phpstan analyse --no-progress - - php-cs-fixer: - name: PHP-CS-Fixer - runs-on: ubuntu-latest - env: - php-version: 8.4 - PHP_CS_FIXER_IGNORE_ENV: 1 - steps: - - name: "Setup PHP" - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ env.php-version }} - tools: flex, cs2pr - - - name: "Checkout code" - uses: actions/checkout@v4 - - - name: "Install Composer dependencies" - uses: "ramsey/composer-install@v3" - with: - composer-options: "--optimize-autoloader" - - - name: "Run PHP-CS-Fixer" - run: vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no --format=checkstyle | cs2pr - - phpunit: - name: PHPUnit (PHP ${{ matrix.php }}) (Symfony ${{ matrix.sf_version }}) - runs-on: ubuntu-latest - strategy: - max-parallel: 10 - fail-fast: false - matrix: - php: [ '8.0', '8.1', '8.2', '8.3', '8.4' ] - sf_version: [ '6.4.*', '7.2.*', '7.3.*' ] - exclude: - - php: '8.0' - sf_version: '6.4.*' - - php: '8.0' - sf_version: '7.2.*' - - php: '8.1' - sf_version: '7.2.*' - - php: '8.0' - sf_version: '7.3.*' - - php: '8.1' - sf_version: '7.3.*' - - steps: - - name: "Checkout code" - uses: actions/checkout@v4 - - - name: "Setup PHP" - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - tools: flex - coverage: none - - - name: "Install Composer dependencies" - env: - SYMFONY_REQUIRE: ${{ matrix.sf_version }} - uses: "ramsey/composer-install@v3" - with: - composer-options: "--optimize-autoloader" - - - name: "Run tests" - env: - SYMFONY_DEPRECATIONS_HELPER: 'ignoreFile=./tests/baseline-ignore' - run: ./vendor/bin/simple-phpunit -v diff --git a/.gitignore b/.gitignore index b14d0dfa..c08f9add 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1 @@ -composer.lock -phpunit.xml -/config/reference.php -vendor/ -.php-cs-fixer.cache -.phpunit.result.cache +_site \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..7151fdc9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "geocoder-php.github.io"] + path = geocoder-php.github.io + url = https://github.com/geocoder-php/geocoder-php.github.io.git diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php deleted file mode 100644 index f22e0df0..00000000 --- a/.php-cs-fixer.php +++ /dev/null @@ -1,15 +0,0 @@ -in(__DIR__) - ->exclude(__DIR__.'/vendor') -; - -return (new PhpCsFixer\Config()) - ->setRules([ - '@Symfony' => true, - 'no_superfluous_phpdoc_tags' => false, - 'phpdoc_to_comment' => ['ignored_tags' => ['var']], // phpstan errors pops up without this - ]) - ->setFinder($finder) -; diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 249b534b..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,299 +0,0 @@ -# Changelog - -The changelog describes what have been "Added", "Changed", "Removed" or "Fixed" between versions. - -## Version 5.19.0 - -### Changed - -- Allow PSR-18 client -- Updated Geocoder Provider dependency requirements to the latest versions -- Deprecate `httplug_client` option in most provider factories in favour of `http_client`. - -### Fixed - -- Load fakeip plugin before cache - -## Version 5.18.0 - -### Added - -- Add OpenRouteService factory - -## Version 5.17.0 - -### Changed - -- Updated PHP requirement to ^7.4 -- Updated minimum required version for some dependencies -- Deprecate `Address::$errorNames` in favour of `Address::ERROR_NAMES`. - -## Version 5.16.2 - -### Fixed - -- Fix deprecations with Symfony 6.1 - -## Version 5.16.1 - -### Fixed - -- Allow Symfony 6 - -## Version 5.16.0 - -### Added - -- Allow Address validation constraint as php8 attribute usage -- Allow fake IP works for all IPs - -## Version 5.15.0 - -### Added - -- Add locationIQ provider -- Add support for PHP 8 attributes - -### Fixed - -- Fix annotation metadata driver with Doctrine proxies -- Fix ORM tests - -### Removed - -- Remove unnecessary version check for registerAliasForArgument - -## Version 5.14.0 - -### Added - -- Add support for PHP 8.0 - -### Changed - -- Upgrade dependencies to up to date versions - -### Removed - -- Remove PHP 7.2 support -- Remove Symfony 3.4 support - -## Version 5.13.0 - -### Added - -- Add support for api-key based authentication in here factory - -## Version 5.12.0 - -### Added - -- Allow configuring local IP when using FakeIpPlugin - -### Changed - -- Skip geocoding if address has not changed - -## Version 5.11.0 - -### Added - -- Allow an HTTP client to be injected via the constructor of providers -- Add MapboxFactory to docs - -### Fixed - -- replace empty() check - -## Version 5.10.0 - -### Added - -- Add MapboxFactory -- Add GoogleMapsPlacesFactory - -### Fixed - -- Fix tests/deprecations and Symfony 5 support - -## Version 5.9.2 - -### Fixed - -- Only trigger provider deprecation notices when they are explicitly configured - -## Version 5.9.1 - -### Fixed - -- Fix extension cannot replace non-defined argument - -## Version 5.9.0 - -### Added - -- Auto tag dumpers with `bazinga_geocoder.dumper` -- Add api_key for the YandexFactory -- Add option to use Faker library for FakeIpPlugin - -## Version 5.8.0 - -### Added - -- Add logger support to ChainFactory - -### Changed - -- Update FreeGeoIpFactory with freegeoip.app - -## Version 5.7.0 - -### Added - -- Add Algolia provider factory - -### Changed - -- Skip empty address values in listener -- Allow cache lifetime as null -- Update dev dependencies -- Make sure we run action on PRs - -## Version 5.6.0 - -### Added - -- Added missing step in Doctrine documentation -- Address annotation can be used over a getter -- Add docs about autowiring -- Integrate phpstan at level 2 -- Adding github actions - -### Changed - -- Deprecate MapzenFactory -- Deprecate GeoIPsFactory -- Rename Changelog.md to CHANGELOG.md - -### Removed - -- Remove useless phpdocs - -## Version 5.5.0 - -### Added - -- Add autowiring bindings by Provider interface + providerName -- Exposes Here provider to the bundle - -### Fixed - -- Add missing tag for AddressValidator constraint - -### Changed - -- Update readme -- Fix method name -- Drop unmaintained Symfony versions support - -## Version 5.4.0 - -### Added - -- Add address validator constraint - -### Fixed - -- SF 4.2 Compliance -- Fix another SF 4.2 deprecation -- Doc fixes -- Custom vendor location symfony 4 - -## Version 5.3.0 - -### Added - -- Support for Ipstack provider -- Support for adding precision argument for the Cache plugin. - -## Version 5.2.0 - -### Added - -- Support for Nominatim 5.0 - -### Fixed - -- Issue when defining plugins. -- Fixed invalid HTML profiler details table. - -## Version 5.1.2 - -### Fixed - -- Make sure commands not using the container. -- Fixed issue with using custom factories. We do not validate custom factories better. -- We are more relaxed in our requirements for HTTPClients. You may now use the option `http_client`. - -## Version 5.1.1 - -### Fixed - -- Adding commands as services -- Fixed twig paths for webprofiler - -## Version 5.1.0 - -### Added - -- `Collector::clear` to be compatible with Symfony 4. -- Added support for IpInfo. - -## Version 5.0.0 - -Version 5 does only support Symfony 3.3+ and PHP7. We dropped some complexity and added plenty of type hints. - -### Added - -- Support for Geocoder 4.0 -- Provider factories -- Support for plugins - -### Changed - -- Namespace changed from `Bazinga\Bundle\GeocoderBundle` to `Bazinga\GeocoderBundle` -- The "fake IP" feature does not change any environment or Symfony variables. -- Configuration for providers has been changed. We now use factories. - -Before: - -```yaml -bazinga_geocoder: - providers: - bing_maps: - api_key: "Foo" - locale: 'sv' -``` -After: - -```yaml -bazinga_geocoder: - providers: - acme: - factory: "Bazinga\GeocoderBundle\ProviderFactory\BingMapsFactory" - locale: 'sv' - options: - api_key: "foo" -``` - -### Removed - -- `DumperManager` -- `LoggableGeocoder`, use `LoggerPlugin` instead. -- Configuration for default provider (`default_provider`) -- `Bazinga\Bundle\GeocoderBundle\Provider\Cache` was removed, use `CachePlugin` instead. -- All services IDs was removed except `bazinga_geocoder.geocoder` and `geocoder`. - -## Version 4.1.0 - -No changelog before this version diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index fe12b3ba..00000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,29 +0,0 @@ - -Contributor Code of Conduct ---------------------------- - -As contributors and maintainers of this project, we pledge to respect all people -who contribute through reporting issues, posting feature requests, updating -documentation, submitting pull requests or patches, and other activities. - -We are committed to making participation in this project a harassment-free -experience for everyone, regardless of level of experience, gender, gender -identity and expression, sexual orientation, disability, personal appearance, -body size, race, age, or religion. - -Examples of unacceptable behavior by participants include the use of sexual -language or imagery, derogatory comments or personal attacks, trolling, public -or private harassment, insults, or other unprofessional conduct. - -Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct. Project maintainers who do not follow the -Code of Conduct may be removed from the project team. - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by opening an issue or contacting one or more of the project -maintainers. - -This Code of Conduct is adapted from the [Contributor -Covenant](http:contributor-covenant.org), version 1.0.0, available at -[http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index d993dd7d..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,30 +0,0 @@ -Contributing -============ - -First of all, **thank you** for contributing, **you are awesome**! - -Here are a few rules to follow in order to ease code reviews, and discussions before -maintainers accept and merge your work. - -You MUST follow the [PSR-1](http://www.php-fig.org/psr/1/) and -[PSR-2](http://www.php-fig.org/psr/2/). If you don't know about any of them, you -should really read the recommendations. Can't wait? Use the [PHP-CS-Fixer -tool](http://cs.sensiolabs.org/). - -You MUST run the test suite. - -You MUST write (or update) unit tests. - -You SHOULD write documentation. - -Please, write [commit messages that make -sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), -and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing) -before submitting your Pull Request. - -One may ask you to [squash your -commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) -too. This is used to "clean" your Pull Request before merging it (we don't want -commits such as `fix tests`, `fix 2`, `fix 3`, etc.). - -Thank you! diff --git a/LICENSE b/LICENSE deleted file mode 100644 index a6b7b809..00000000 --- a/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) Since 2011 — William Durand - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index ed2404d2..00000000 --- a/README.md +++ /dev/null @@ -1,60 +0,0 @@ -BazingaGeocoderBundle -===================== - -[![Build Status](https://github.com/geocoder-php/BazingaGeocoderBundle/actions/workflows/ci.yml/badge.svg)](https://github.com/geocoder-php/BazingaGeocoderBundle/actions/workflows/ci.yml) -[![Latest Stable Version](https://poser.pugx.org/willdurand/geocoder-bundle/v/stable)](https://packagist.org/packages/willdurand/geocoder-bundle) -[![Total Downloads](https://poser.pugx.org/willdurand/geocoder-bundle/downloads)](https://packagist.org/packages/willdurand/geocoder-bundle) -[![Monthly Downloads](https://poser.pugx.org/willdurand/geocoder-bundle/d/monthly.png)](https://packagist.org/packages/willdurand/geocoder-bundle) -[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/geocoder-php/BazingaGeocoderBundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/geocoder-php/BazingaGeocoderBundle) -[![Quality Score](https://img.shields.io/scrutinizer/g/geocoder-php/BazingaGeocoderBundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/geocoder-php/BazingaGeocoderBundle) -[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) - -Integration of the [**Geocoder**](http://github.com/geocoder-php/Geocoder) library -into Symfony. It integrates seamlessly with the Symfony profiler. You can -check number of queries executed by each provider, total execution time -and geocoding results. - -![Example Toolbar](doc/toolbar.png) - - -![Example Profiler page](doc/profiler-page.png) - - - -Documentation -------------- - -For documentation, see: - - doc/ - -[Read the documentation](doc/index.md) - - -Contributing ------------- - -See -[CONTRIBUTING](CONTRIBUTING.md) -file. - - -Credits -------- - -* William Durand -* Tobias Nyholm -* [All contributors](https://github.com/geocoder-php/BazingaGeocoderBundle/contributors) - - -Contributor Code of Conduct ---------------------------- - -Please note that this project is released with a Contributor Code of Conduct. -By participating in this project you agree to abide by its terms. - - -License -------- - -This bundle is released under the MIT license. See the complete license [here](LICENSE). diff --git a/_config.yml b/_config.yml new file mode 100644 index 00000000..1248076e --- /dev/null +++ b/_config.yml @@ -0,0 +1,10 @@ +pygments: true +markdown: redcarpet +layouts: ./geocoder-php.github.io/_layouts/ + +name: Geocoder +description: The almost missing Geocoder PHP library! +url: http://geocoder-php.org/ + +travis_base_url: https://travis-ci.org/geocoder-php/ +github_base_url: https://github.com/geocoder-php/ diff --git a/composer.json b/composer.json deleted file mode 100644 index 4fd3b90b..00000000 --- a/composer.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "name": "willdurand/geocoder-bundle", - "description": "Integration of Geocoder into Symfony", - "keywords": [ - "geocoding", - "geocoder" - ], - "type": "symfony-bundle", - "license": "MIT", - "authors": [ - { - "name": "William Durand", - "email": "will+git@drnd.me" - } - ], - "require": { - "php": "^8.1", - "geocoder-php/plugin": "^1.5", - "php-http/discovery": "^1.14", - "symfony/console": "^5.4 || ^6.4 || ^7.0", - "symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0", - "symfony/options-resolver": "^5.4 || ^6.4 || ^7.0", - "willdurand/geocoder": "^4.6|^5.0" - }, - "require-dev": { - "doctrine/doctrine-bundle": "^2.3", - "doctrine/orm": "^2.20 || ^3.0", - "fakerphp/faker": "^1.20", - "friendsofphp/php-cs-fixer": "^3.13", - "geocoder-php/algolia-places-provider": "^0.4", - "geocoder-php/arcgis-online-provider": "^4.4", - "geocoder-php/bing-maps-provider": "^4.3", - "geocoder-php/cache-provider": "^4.4.0", - "geocoder-php/chain-provider": "^4.5", - "geocoder-php/free-geoip-provider": "^4.5", - "geocoder-php/geo-plugin-provider": "^4.3", - "geocoder-php/geoip2-provider": "^4.3", - "geocoder-php/geoips-provider": "^4.0", - "geocoder-php/geonames-provider": "^4.4", - "geocoder-php/google-maps-places-provider": "^1.4", - "geocoder-php/google-maps-provider": "^4.7", - "geocoder-php/here-provider": "^0.7", - "geocoder-php/host-ip-provider": "^4.4", - "geocoder-php/ip-info-db-provider": "^4.3", - "geocoder-php/ip-info-provider": "^0.4", - "geocoder-php/ipstack-provider": "^0.4", - "geocoder-php/locationiq-provider": "^1.4", - "geocoder-php/mapbox-provider": "^1.4", - "geocoder-php/mapquest-provider": "^4.3", - "geocoder-php/mapzen-provider": "^4.0", - "geocoder-php/maxmind-binary-provider": "^4.3", - "geocoder-php/maxmind-provider": "^4.4", - "geocoder-php/nominatim-provider": "^5.6", - "geocoder-php/open-cage-provider": "^4.6", - "geocoder-php/openrouteservice-provider": "^1.3", - "geocoder-php/pickpoint-provider": "^4.3", - "geocoder-php/tomtom-provider": "^4.4", - "geocoder-php/yandex-provider": "^4.5", - "geoip/geoip": "~1.17", - "nyholm/nsa": "^1.3", - "nyholm/psr7": "^1.5", - "nyholm/symfony-bundle-test": "^2.0 || ^3.0", - "phpstan/phpstan": "^1.9.2", - "psr/http-client": "^1.0", - "psr/simple-cache": "^1.0 || ^2.0", - "symfony/cache": "^5.4 || ^6.4 || ^7.0", - "symfony/config": "^5.4 || ^6.4 || ^7.0", - "symfony/http-client": "^5.4 || ^6.4 || ^7.0", - "symfony/phpunit-bridge": "^5.4 || ^6.4 || ^7.0", - "symfony/validator": "^5.4 || ^6.4 || ^7.0", - "symfony/var-exporter": "^5.4 || ^6.4 || ^7.0", - "symfony/yaml": "^5.4 || ^6.4 || ^7.0" - }, - "autoload": { - "psr-4": { - "Bazinga\\GeocoderBundle\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Bazinga\\GeocoderBundle\\Tests\\": "tests" - } - }, - "scripts": { - "test": "SYMFONY_DEPRECATIONS_HELPER=ignoreFile='./tests/baseline-ignore' vendor/bin/simple-phpunit --testsuite main" - }, - "config": { - "allow-plugins": { - "symfony/flex": true, - "php-http/discovery": false - }, - "sort-packages": true - }, - "minimum-stability": "dev", - "prefer-stable": true, - "extra": { - "branch-alias": { - "dev-master": "6.0-dev" - } - } -} diff --git a/config/profiling.php b/config/profiling.php deleted file mode 100644 index 14608eb5..00000000 --- a/config/profiling.php +++ /dev/null @@ -1,14 +0,0 @@ -services(); - - $services->set(GeocoderDataCollector::class) - ->tag('data_collector', ['template' => '@BazingaGeocoder/Collector/geocoder.html.twig', 'id' => 'geocoder']); -}; diff --git a/config/services.php b/config/services.php deleted file mode 100644 index e8dce8c7..00000000 --- a/config/services.php +++ /dev/null @@ -1,53 +0,0 @@ -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/doc/cache.md b/doc/cache.md deleted file mode 100644 index f453821c..00000000 --- a/doc/cache.md +++ /dev/null @@ -1,98 +0,0 @@ -# Caching the geocoder response - -*[<< Back to documentation index](/doc/index.md)* - -It is quite rare that a location response gets updated. That is why it is a good idea to cache the responses. The second -request will be both quicker and free of charge. To get started with caching you may use the `CachePlugin` which is supported -by default in our configuration. - -```yaml -# config/packages/bazinga_geocoder.yaml -bazinga_geocoder: - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - cache: 'any.psr16.service' - cache_lifetime: 3600 - cache_precision: ~ -``` - -If you do a lot of reverse queries it can be useful to cache them with less precision. So if you are interested in only the city, -you don't want to query for every exact coordinate. Instead, you want to remove some precision of the coordinates. For example: -reversing `52.3705273, 4.891031` will be cached as `52.3705, 4.8910`. - -You may use any [PSR16](http://www.php-fig.org/psr/psr-16/) cache [implementation](https://packagist.org/providers/psr/simple-cache-implementation). -The `CachePlugin` helps you to cache all responses. - -## Decorator pattern - -If you do not like using the `CachePlugin` for some reason you may use the [`CacheProvider`](https://github.com/geocoder-php/cache-provider). -The `CacheProvider` is using the [Decorator pattern](https://en.wikipedia.org/wiki/Decorator_pattern) to do caching. Which -means that you wrap the `CacheProvider` around your existing provider. - -```bash -composer require geocoder-php/cache-provider -``` - -```yaml -# config/packages/bazinga_geocoder.yaml -bazinga_geocoder: - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory -``` - -```yaml -# config/services.yaml -services: - my_cached_geocoder: - class: Geocoder\Provider\Cache\ProviderCache - arguments: ['@bazinga_geocoder.provider.acme', '@any.psr16.service', 3600] -``` - -## Installing a PSR16 cache - -You may use any adapter from [PHP-cache.com](http://www.php-cache.com/en/latest/) or `symfony/cache`. - -## Using Symfony cache - -Symfony>=3.3 supports SimpleCache thanks to `Symfony\Component\Cache\Simple\Psr6Cache` adapter. -Thus a service can be registered like so: - -```yaml -# config/services.yaml -app.simple_cache: - class: Symfony\Component\Cache\Simple\Psr6Cache - arguments: ['@app.cache.acme'] -``` - -Then configure the framework and the bundle: - -```yaml -# config/packages/cache.yaml -framework: - cache: - app: cache.adapter.redis - pools: - app.cache.acme: - adapter: cache.app - default_lifetime: 600 - -# config/packages/bazinga_geocoder.yaml -bazinga_geocoder: - providers: - my_google_maps: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - cache: 'app.simple_cache' - cache_lifetime: 3600 - cache_precision: 4 -``` - -For older Symfony version, you can use a bridge between PSR-6 and PSR-16. Install the -[bridge](https://github.com/php-cache/simple-cache-bridge) by: - -```bash -composer require cache/simple-cache-bridge -``` - -Then, in the service declaration you can use `Cache\Bridge\SimpleCache\SimpleCacheBridge` instead of `Symfony\Component\Cache\Simple\Psr6Cache`. diff --git a/doc/custom-provider.md b/doc/custom-provider.md deleted file mode 100644 index abc1cfb5..00000000 --- a/doc/custom-provider.md +++ /dev/null @@ -1,49 +0,0 @@ -# Registering Your Own Providers - -*[<< Back to documentation index](/doc/index.md)* - -If you want to use your own provider in your application, create a service, and tag it as `bazinga_geocoder.provider`: - -```xml - - - - -``` - -The bundle will automatically register your provider into the`Geocoder\ProviderAggregator` service. However, it will not -show up the web profiler because it is not registered with the [PluginProvider](/doc/plugins.md). - -If you want your provider to show up the web profiler you have to create a custom factory for your provider. - -```php -namespace Acme\Demo\Geocoder\Factory; - -use Bazinga\GeocoderBundle\ProviderFactory\AbstractFactory; -use Acme\Demo\Geocoder\Provider\MyProvider; -use Acme\Demo\Service\Foo; - -final class MyFactory extends AbstractFactory -{ - private $fooService; - - public function __construct(Foo $service) - { - $this->someService = $service; - } - - protected function getProvider(array $config) - { - return new MyProvider($this->fooService); - } -} -``` - -```yaml -# config/packages/bazinga_geocoder.yaml -bazinga_geocoder: - providers: - acme: - factory: Acme\Demo\Geocoder\Factory\MyFactory - aliases: ['acme_demo.geocoder.my_provider'] -``` diff --git a/doc/doctrine.md b/doc/doctrine.md deleted file mode 100644 index ff123413..00000000 --- a/doc/doctrine.md +++ /dev/null @@ -1,79 +0,0 @@ -# Doctrine annotation support - -*[<< Back to documentation index](/doc/index.md)* - -Wouldn't it be great if you could automatically save the coordinates of a users -address every time it is updated? Wait not more here is the feature you been always -wanted. - -First of all, update your entity: - -```php - -use Bazinga\GeocoderBundle\Mapping\Attributes as Geocoder; - -#[Geocoder\Geocodeable()] -class User -{ - #[Geocoder\Address()] - private $address; - - #[Geocoder\Latitude()] - private $latitude; - - #[Geocoder\Longitude()] - private $longitude; -} -``` - -Instead of annotating a property, you can also annotate a getter: - -```php - -use Bazinga\GeocoderBundle\Mapping\Attributes as Geocoder; - -#[Geocoder\Geocodeable()] -class User -{ - #[Geocoder\Latitude()] - private $latitude; - - #[Geocoder\Longitude()] - private $longitude; - - #[Geocoder\Address()] - public function getAddress(): string - { - // Your code... - } -} -``` - -Secondly, register the Doctrine event listener and its dependencies in your `config/services.yaml` or `config/services.php` file. -You have to indicate which provider to use to reverse geocode the address. Here we use `acme` provider we declared in bazinga_geocoder configuration earlier. - -```yaml - Bazinga\GeocoderBundle\Mapping\Driver\AttributeDriver: ~ - - Bazinga\GeocoderBundle\Doctrine\ORM\GeocoderListener: - class: Bazinga\GeocoderBundle\Doctrine\ORM\GeocoderListener - arguments: - - '@bazinga_geocoder.provider.acme' - - '@Bazinga\GeocoderBundle\Mapping\Driver\AttributeDriver' - tags: - - { name: doctrine.event_listener, event: onFlush } -``` - -It is done! -Now you can use it: - -```php -$user = new User(); -$user->setAddress('Brandenburger Tor, Pariser Platz, Berlin'); - -$em->persist($event); -$em->flush(); - -echo $user->getLatitude(); // will output 52.516325 -echo $user->getLongitude(); // will output 13.377264 -``` diff --git a/doc/index.md b/doc/index.md deleted file mode 100644 index 1ff19b73..00000000 --- a/doc/index.md +++ /dev/null @@ -1,384 +0,0 @@ -BazingaGeocoderBundle -===================== - -Integration of the [**Geocoder**](http://github.com/geocoder-php/Geocoder) library into Symfony. - -Our documentation has the following sections: - -* [Index](index.md) (This page) -* [Public services](services.md) (Providers) -* [Registering Your Own Provider](custom-provider.md) -* [All about Cache](cache.md) -* [Plugins](plugins.md) -* [Doctrine support](doctrine.md) - -Table of contents ------------------ - -* [Installation](#installation) -* [Usage](#usage) - * [Chain providers](#chain-providers) - * [Fake local ip](#fake-local-ip) - * [Cache](#cache-results) - * [Dumpers](#dumpers) - * [Custom HTTP clients](#custom-http-clients) -* [Reference Configuration](#reference-configuration) -* [Backwards compatibility](#backwards-compatibility) -* [Testing](#testing) - -Installation ------------- - -To install this bundle you need to know how to [install the geocoder and providers](https://github.com/geocoder-php/Geocoder#installation) -and then you may just install the bundle like normal: - -```bash -composer require willdurand/geocoder-bundle:^5.0 -``` - -If you don't use [Symfony Flex](https://symfony.com/doc/current/setup/flex.html), you must enable the bundle manually in the application: - -```php -// config/bundles.php -// in older Symfony apps, enable the bundle in app/AppKernel.php -return [ - // ... - Bazinga\GeocoderBundle\BazingaGeocoderBundle::class => ['all' => true], -]; -``` - -Usage ------ - -The bundle helps you register your providers and to enable profiling support. To -configure a provider you must use a `ProviderFactory`. See the following example -using Google Maps. - -```yaml -bazinga_geocoder: - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory -``` - -This will create a service named `bazinga_geocoder.provider.acme` which is a -`GoogleMapsProvider`. - -You can also configure **all ``ProviderFactories``** to adjust the behavior of the -provider. - -```yaml -bazinga_geocoder: - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - cache: 'any.psr16.service' - cache_lifetime: 3600 - aliases: - - my_geocoder -``` - -This will create a service named `my_geocoder` that caches the responses for one -hour. - -**Most ``ProviderFactories``** do also take an array with options. This is usually -parameters to the constructor of the provider. In the example of Google Maps: - -```yaml -bazinga_geocoder: - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - options: - http_client: '@any.psr18.client' - region: 'Sweden' - api_key: 'xxyy' -``` - -### Chain providers - -Someone was thinking ahead here. Wouldn't it be nice if you could pass your request through different `ProviderFactories`? You can!! With the `ChainFactory`, see the configuration below. - -```yaml -bazinga_geocoder: - providers: - acme: - aliases: - - my_geocoder - cache: 'any.psr16.service' - cache_lifetime: 3600 - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - options: - api_key: 'xxxx' - acme_ii: - aliases: - - my_geocoder_ii - factory: Bazinga\GeocoderBundle\ProviderFactory\TomTomFactory - options: - api_key: 'xxyy' - http_client: '@any.psr18.client' - region: 'Sweden' - chain: - factory: Bazinga\GeocoderBundle\ProviderFactory\ChainFactory - options: - services: ['@bazinga_geocoder.provider.acme', '@bazinga_geocoder.provider.acme_ii'] -``` - -The `services` key could also be as follows `services: ['@my_geocoder', '@my_geocoder_ii']`. Notice these are the values from the `aliases` key. - -### Autowiring Providers - -If you're using autowiring you can use bindings provided the bundle. - -```yaml -bazinga_geocoder: - providers: - googleMaps: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory -``` - -```php -googleMapsGeocoder = $googleMapsGeocoder; - } -} -``` - -Each configured provider has a binding in the following format: -`providerName + Geocoder`. - -In the example we configured provider name as `googleMaps` so the argument is `$googleMapsGeocoder`. - -### Fake local ip - -You can fake your local IP through this bundle in order to get location -information in your development environment, for instance: - -```php -/** - * @Template() - */ -public function indexAction(Request $request) -{ - // Retrieve information from the current user (by its IP address) - $result = $this->container - ->get('bazinga_geocoder.provider.acme') - ->geocodeQuery(GeocodeQuery::create($request->server->get('REMOTE_ADDR'))); - - // Find the 5 nearest objects (15km) from the current user. - $coords = $result->first()->getCoordinates(); - $objects = ObjectQuery::create() - ->filterByDistanceFrom($coords->getLatitude(), $coords->getLongitude(), 15) - ->limit(5) - ->find(); - - return array( - 'geocoded' => $result, - 'nearest_objects' => $objects - ); -} -``` - -In the example above, we'll retrieve information from the user's IP address, and 5 -objects nears him. -But it won't work on your local environment, that's why this bundle provides -an easy way to fake this behavior by using a `fake_ip` configuration. - -```yaml -# config/packages/bazinga_geocoder.yaml - -when@dev: - bazinga_geocoder: - fake_ip: 123.123.123.123 -``` - -If set, the parameter will replace all instances of "127.0.0.1" in your queries and replace them with the given one. -If you'd like to replace other ip instead of "127.0.0.1" (e.g. when using localhost inside a VM) you can set the optional `local_ip` parameter: - -```yaml -when@dev: - bazinga_geocoder: - fake_ip: - local_ip: 192.168.99.1 # default 127.0.0.1 - ip: 123.123.123.123 -``` - -You can also let [Faker](https://github.com/fakerphp/faker) generate fake ip for you. - -```yaml -when@dev: - bazinga_geocoder: - fake_ip: - use_faker: true # default false -``` - -### Cache Results - -Sometimes you have to cache the results from a provider. For this case the bundle provides -simple configuration. You only need to provide a service name for you SimpleCache (PSR-16) -service and you are good to go. - -```yaml -bazinga_geocoder: - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - cache: 'any.psr16.service' - cache_lifetime: 3600 -``` - -Read more about cache [here](cache.md). - -### Dumpers - -If you need to dump your geocoded data to a specific format, you can use the -__Dumper__ component. The following dumper's are supported: - - * GeoArray - * GeoJson - * GPX - * KML - * WKB - * WKT - -Here is an example if you are using autowiring: - -```php -acmeGeocoder = $acmeGeocoder; - $this->geoJsonDumper = $dumper; - } - - public function geocodeAction(Request $request) - { - $result = $this->acmeGeocoder->geocodeQuery(GeocodeQuery::create($request->server->get('REMOTE_ADDR'))); - - $body = $this->geoJsonDumper->dump($result); - - return new JsonResponse($body); - } -} -``` - -Each dumper service if it implements `Geocoder\Dumper\Dumper` interface will be -tagged with `bazinga_geocoder.dumper` tag. Each dumper can be used with autowiring -providing the dumper class name as the argument. -Also If you want to inject all the tagged dumpers to your service you can provide -your service argument as: `!tagged bazinga_geocoder.dumper`. - -### Custom HTTP Clients - -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: - -```bash -composer require guzzlehttp/guzzle http-interop/http-factory-guzzle -``` - -And configure your provider to use it: - -```yaml -services: - guzzle.client: - class: GuzzleHttp\Client - -bazinga_geocoder: - providers: - acme: - factory: ... - options: - http_client: '@guzzle.client' -``` - -Reference Configuration ------------------------ - -You'll find the reference configuration below: - -```yaml -# config/packages/bazinga_geocoder.yaml -bazinga_geocoder: - profiling: - enabled: ~ # Default is same as kernel.debug - fake_ip: - enabled: true - ip: null - providers: - # ... - acme: - factory: ~ # Required - cache: 'app.cache' - cache_lifetime: 3600 - cache_precision: 4 # Precision of the coordinates to cache. - limit: 5 - locale: 'sv' - logger: 'logger' - plugins: - - my_custom_plugin - aliases: - - acme - - acme_geocoder - options: - foo: bar - biz: baz - # ... - free_chain: - aliases: - - free_geo_chain - factory: Bazinga\GeocoderBundle\ProviderFactory\ChainFactory - options: - services: ['@acme', '@acme_ii'] -``` - -Backwards compatibility ------------------------ - -The BazingaGeocoderBundle is just a Symfony integration for Geocoder-PHP and it -does not have any classes which falls under the BC promise. The backwards compatibility -of the bundle is only the configuration and its values (and of course the behavior -of those values). - -The public service names (excluding the ones related to profiling/DataCollector) -falls under the backwards compatibility promise. - -Bottom line is, that you can trust that your configuration will not break and that -the services you use will still be working. - -Testing -------- - -Setup the test suite using [Composer](http://getcomposer.org/): - - -```bash -composer update -composer test -``` diff --git a/doc/plugins.md b/doc/plugins.md deleted file mode 100644 index 79748fe1..00000000 --- a/doc/plugins.md +++ /dev/null @@ -1,47 +0,0 @@ -# Plugins - -*[<< Back to documentation index](/doc/index.md)* - -Plugins lets you modify or take actions the `Query` or the result. There are a few plugins from the `geocoder-php/plugin` -package like `LimitPlugin`, `LoggerPlugin` and `CachePlugin`. Some of them are supported in the configuration. - -```yaml -# config/packages/bazinga_geocoder.yaml -bazinga_geocoder: - fake_ip: - ip: '123.123.123.123' # Uses the FakeIpPlugin - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - cache: 'app.cache' # Uses the CachePlugin - limit: 5 # Uses the LimitPlugin - locale: 'sv' # Uses the LocalePlugin - logger: 'logger' # Uses the LoggerPlugin -``` - -To use a any other plugins you must first register them as a service. Say you want to add some data to each query. You -may then use the `QueryDataPlugin`. - -```yaml -# config/services.yaml -services: - app.query_data_plugin: - class: Geocoder\Plugin\Plugin\QueryDataPlugin - arguments: - - ['foo': 'bar'] - - true -``` - -```yaml -# config/packages/bazinga_geocoder.yaml -bazinga_geocoder: - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - plugins: - - 'app.query_data_plugin' -``` - -This will execute `$query = $query->withData('foo', 'bar');` on all queries executed by the acme provider. - -Read more about plugins at the [Geocoder's documentation](https://github.com/geocoder-php/Geocoder). diff --git a/doc/profiler-page.png b/doc/profiler-page.png deleted file mode 100644 index 5bf74611..00000000 Binary files a/doc/profiler-page.png and /dev/null differ diff --git a/doc/services.md b/doc/services.md deleted file mode 100644 index 8335bafe..00000000 --- a/doc/services.md +++ /dev/null @@ -1,53 +0,0 @@ -# Public services - -*[<< Back to documentation index](/doc/index.md)* - -This is a list of our public services. They are all part of [BC promise](/doc/index.md#backwards-compatibility). - -### Provider Factories - -Here is a list of all provider factories and their options. - -| Service | Options | -| ------- | ------- | -| `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` | 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` | 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` | 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 - -Except for the provider factories, here is a list of services this bundle exposes are: - -* `Geocoder\ProviderAggregator` -* `Geocoder\Dumper\GeoArray` -* `Geocoder\Dumper\GeoJson` -* `Geocoder\Dumper\Gpx` -* `Geocoder\Dumper\Kml` -* `Geocoder\Dumper\Wkb` -* `Geocoder\Dumper\Wkt` diff --git a/doc/toolbar.png b/doc/toolbar.png deleted file mode 100644 index a243ed6a..00000000 Binary files a/doc/toolbar.png and /dev/null differ diff --git a/geocoder-php.github.io b/geocoder-php.github.io new file mode 160000 index 00000000..2d46569b --- /dev/null +++ b/geocoder-php.github.io @@ -0,0 +1 @@ +Subproject commit 2d46569b05b1f9ffc3053e4ae9b37c6116990336 diff --git a/index.markdown b/index.markdown new file mode 100644 index 00000000..a6cbd521 --- /dev/null +++ b/index.markdown @@ -0,0 +1,304 @@ +--- +layout: project +title: BazingaGeocoderBundle +project_name: BazingaGeocoderBundle +--- + +BazingaGeocoderBundle +===================== + +[![Build +Status](https://secure.travis-ci.org/geocoder-php/BazingaGeocoderBundle.png)](http://travis-ci.org/geocoder-php/BazingaGeocoderBundle) + +Integration of the [**Geocoder**](http://github.com/geocoder-php/Geocoder) library +into Symfony2. + + +Installation +------------ + +Require [`willdurand/geocoder-bundle`](https://packagist.org/packages/willdurand/geocoder-bundle) +to your `composer.json` file: + + +```json +{ + "require": { + "willdurand/geocoder-bundle": "@stable" + } +} +``` + +Register the bundle in `app/AppKernel.php`: + +```php +// app/AppKernel.php +public function registerBundles() +{ + return array( + // ... + new Bazinga\Bundle\GeocoderBundle\BazingaGeocoderBundle(), + ); +} +``` + +Enable the bundle's configuration in `app/config/config.yml`: + +``` yaml +# app/config/config.yml +bazinga_geocoder: ~ +``` + +Usage +----- + +This bundle registers a `bazinga_geocoder.geocoder` service which is an instance +of `Geocoder`. You'll be able to do whatever you want with it but be sure to +configure at least **one provider** first. + +**NOTE:** When using `Request::getClientIp()` with Symfony 2.1+, ensure you have +a trusted proxy set in your `config.yml`: + +``` yaml +# app/config/config.yml +framework: + trusted_proxies: ['127.0.0.1'] + # ... +``` + +### Killer Feature + +You can fake the `REMOTE_ADDR` HTTP parameter through this bundle in order to get +information in your development environment, for instance: + +``` php +container + ->get('bazinga_geocoder.geocoder') + ->using('google_maps') + ->geocode($request->server->get('REMOTE_ADDR')); + + // Find the 5 nearest objects (15km) from the current user. + $objects = ObjectQuery::create() + ->filterByDistanceFrom($result->getLatitude(), $result->getLongitude(), 15) + ->limit(5) + ->find(); + + return array( + 'geocoded' => $result, + 'nearest_objects' => $objects + ); + } +``` + +In the example, we'll retrieve information from the user's IP address, and 5 +objects nears him. +But it won't work on your local environment, that's why this bundle provides +an easy way to fake this behavior by using a `fake_ip` configuration. + +``` yaml +# app/config/config_dev.yml +bazinga_geocoder: + fake_ip: 123.345.643.133 +``` + +If set, the parameter will replace the `REMOTE_ADDR` value by the given one. + + +Additionally if it interferes with your current +listeners, You can set up different fake ip listener priority. + + +``` yaml +# app/config/config_dev.yml +bazinga_geocoder: + fake_ip: + ip: 123.345.643.133 + priority: 128 +``` + +### Dumpers + +If you need to dump your geocoded data to a specific format, you can use the +__Dumper__ component. The following dumper's are supported: + + * Geojson + * GPX + * KMP + * WKB + * WKT + +Here is an example: + +```php +container + ->get('bazinga_geocoder.geocoder') + ->geocode($request->server->get('REMOTE_ADDR')); + + $body = $this->container + ->get('bazinga_geocoder.dumper_manager') + ->get('geojson') + ->dump($result); + + $response = new Response(); + $response->setContent($body); + + return $response; +} +``` + +To register a new dumper, you must tag it with _geocoder.dumper_. +Geocoder detect and register it automatically. + +A little example: + +```xml + + + +``` + +### Cache Provider + +Sometimes you have to cache the results from a provider. For this case the bundle provides +a cache provider. The cache provider wraps another provider and delegate all calls +to this provider and cache the return value. + +__Configuration example:__ + +```yaml +# app/config/config*.yml +services: + acme_cache_adapter: + class: "Doctrine\\Common\\Cache\\ApcCache" + +bazinga_geocoder: + providers: + cache: + adapter: acme_cache_adapter + provider: google_maps + google_maps: ~ +``` + +> **Tip:** If you want to configure the cache adapter, +> we recommend the [liip/doctrine-cache-bundle](https://github.com/liip/LiipDoctrineCacheBundle). + + +### Symfony2 Profiler Integration + +Geocoder bundle additionally integrates with Symfony2 profiler. You can +check number of queries executed by each provider, total execution time +and geocoding results. + +![Example +Toolbar](https://raw.github.com/geocoder-php/BazingaGeocoderBundle/master/Resources/doc/toolbar.png) + + +Reference Configuration +----------------------- + +You MUST define the providers you want to use in your configuration. Some of +them need information (API key for instance). + +You'll find the reference configuration below: + +``` yaml +# app/config/config*.yml +bazinga_geocoder: + fake_ip: + enabled: true + ip: ~ + priority: 0 + adapter: + class: ~ + providers: + bing_maps: + api_key: ~ # Required + locale: ~ + cache: + adapter: ~ # Required + provider: ~ # Required + locale: ~ + lifetime: 86400 + ip_info_db: + api_key: ~ # Required + cloudmade: + api_key: ~ # Required + google_maps: + locale: ~ + region: ~ + use_ssl: false + google_maps_business: + client_id: ~ # Required + api_key: ~ + region: ~ + use_ssl: false + openstreetmap: + locale: ~ + host_ip: [] + geoip: [] + free_geo_ip: [] + mapquest: + api_key: ~ # Required + oiorest: [] + geocoder_ca: [] + geocoder_us: [] + ign_openls: + api_key: ~ # Required + data_science_toolkit: [] + yandex: + locale: ~ + toponym: ~ + geo_ips: + api_key: ~ + geo_plugin: [] + maxmind: + api_key: ~ # Required + maxmind_binary: + binary_file: ~ # Required + open_flag: ~ + chain: + providers: [] +``` + + +Testing +------- + +Setup the test suite using [Composer](http://getcomposer.org/): + + $ composer install --dev + +Run it using PHPUnit: + + $ phpunit + + +Credits +------- + +* William Durand +* [All + contributors](https://github.com/geocoder-php/BazingaGeocoderBundle/contributors) + + +License +------- + +This bundle is released under the MIT license. See the complete license in the +bundle: + + Resources/meta/LICENSE diff --git a/phpstan-baseline.php b/phpstan-baseline.php deleted file mode 100644 index a833970d..00000000 --- a/phpstan-baseline.php +++ /dev/null @@ -1,211 +0,0 @@ - '#^Parameter \\#1 \\$name of method Geocoder\\\\ProviderAggregator\\:\\:using\\(\\) expects string, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/Command/GeocodeCommand.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$string of function strtolower expects string, string\\|null given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/Command/GeocodeCommand.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$text of static method Geocoder\\\\Query\\\\GeocodeQuery\\:\\:create\\(\\) expects string, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/Command/GeocodeCommand.php', -]; -$ignoreErrors[] = [ - // identifier: foreach.nonIterable - 'message' => '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#', - 'count' => 3, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: offsetAccess.nonOffsetAccessible - 'message' => '#^Cannot access offset \'aliases\' on mixed\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: offsetAccess.nonOffsetAccessible - 'message' => '#^Cannot access offset \'enabled\' on mixed\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: offsetAccess.nonOffsetAccessible - 'message' => '#^Cannot access offset \'factory\' on mixed\\.$#', - 'count' => 5, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: offsetAccess.nonOffsetAccessible - 'message' => '#^Cannot access offset \'id\' on mixed\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: offsetAccess.nonOffsetAccessible - 'message' => '#^Cannot access offset \'options\' on mixed\\.$#', - 'count' => 4, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: offsetAccess.nonOffsetAccessible - 'message' => '#^Cannot access offset \'reference\' on mixed\\.$#', - 'count' => 2, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: staticMethod.nonObject - 'message' => '#^Cannot call static method validate\\(\\) on mixed\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: cast.string - 'message' => '#^Cannot cast mixed to string\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$alias of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:setAlias\\(\\) expects string, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: Symfony\\\\Component\\\\DependencyInjection\\\\Reference given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$factoryServiceId of static method Bazinga\\\\GeocoderBundle\\\\DependencyInjection\\\\Compiler\\\\FactoryValidatorPass\\:\\:addFactoryServiceId\\(\\) expects string, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$id of class Symfony\\\\Component\\\\DependencyInjection\\\\Reference constructor expects string, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$id of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:getDefinition\\(\\) expects string, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$object_or_class of function class_implements expects object\\|string, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$options of method Bazinga\\\\GeocoderBundle\\\\DependencyInjection\\\\BazingaGeocoderExtension\\:\\:findReferences\\(\\) expects array\\, mixed given\\.$#', - 'count' => 2, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$string of function ltrim expects string, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#2 \\$config of method Bazinga\\\\GeocoderBundle\\\\DependencyInjection\\\\BazingaGeocoderExtension\\:\\:configureProviderPlugins\\(\\) expects array\\, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: encapsedStringPart.nonString - 'message' => '#^Part \\$providerName \\(mixed\\) of encapsed string cannot be cast to string\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/DependencyInjection/BazingaGeocoderExtension.php', -]; -$ignoreErrors[] = [ - // identifier: method.nonObject - 'message' => '#^Cannot call method getLatitude\\(\\) on Geocoder\\\\Model\\\\Coordinates\\|null\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/Doctrine/ORM/GeocoderListener.php', -]; -$ignoreErrors[] = [ - // identifier: method.nonObject - 'message' => '#^Cannot call method getLongitude\\(\\) on Geocoder\\\\Model\\\\Coordinates\\|null\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/Doctrine/ORM/GeocoderListener.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$text of method Geocoder\\\\Query\\\\GeocodeQuery\\:\\:withText\\(\\) expects string, string\\|null given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/Plugin/FakeIpPlugin.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#2 \\$replace of function str_replace expects array\\|string, string\\|null given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/Plugin/FakeIpPlugin.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$accountId of class GeoIp2\\\\WebService\\\\Client constructor expects int, int\\|null given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/ProviderFactory/GeoIP2Factory.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$filename of class GeoIp2\\\\Database\\\\Reader constructor expects string, string\\|null given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/ProviderFactory/GeoIP2Factory.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#1 \\$geoIpProvider of class Geocoder\\\\Provider\\\\GeoIP2\\\\GeoIP2Adapter constructor expects GeoIp2\\\\ProviderInterface, GeoIp2\\\\ProviderInterface\\|null given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/ProviderFactory/GeoIP2Factory.php', -]; -$ignoreErrors[] = [ - // identifier: argument.type - 'message' => '#^Parameter \\#2 \\$licenseKey of class GeoIp2\\\\WebService\\\\Client constructor expects string, string\\|null given\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/ProviderFactory/GeoIP2Factory.php', -]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Class Geocoder\\\\Provider\\\\Geoip\\\\Geoip not found\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/ProviderFactory/GeoipFactory.php', -]; -$ignoreErrors[] = [ - // identifier: class.notFound - 'message' => '#^Instantiated class Geocoder\\\\Provider\\\\Geoip\\\\Geoip not found\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/ProviderFactory/GeoipFactory.php', -]; -$ignoreErrors[] = [ - // identifier: return.type - 'message' => '#^Method Bazinga\\\\GeocoderBundle\\\\ProviderFactory\\\\GeoipFactory\\:\\:getProvider\\(\\) should return Geocoder\\\\Provider\\\\Provider but returns Geocoder\\\\Provider\\\\Geoip\\\\Geoip\\.$#', - 'count' => 1, - 'path' => __DIR__.'/src/ProviderFactory/GeoipFactory.php', -]; - -return ['parameters' => ['ignoreErrors' => $ignoreErrors]]; diff --git a/phpstan.dist.neon b/phpstan.dist.neon deleted file mode 100644 index b03a2139..00000000 --- a/phpstan.dist.neon +++ /dev/null @@ -1,10 +0,0 @@ -includes: - - phpstan-baseline.php - -parameters: - bootstrapFiles: - - vendor/bin/.phpunit/phpunit/vendor/autoload.php - paths: - - src/ - #- tests/ - level: 9 diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index 5d36cb52..00000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - src - - - - - - ./tests - - - - - - - diff --git a/src/BazingaGeocoderBundle.php b/src/BazingaGeocoderBundle.php deleted file mode 100644 index afbbf8b5..00000000 --- a/src/BazingaGeocoderBundle.php +++ /dev/null @@ -1,42 +0,0 @@ - - */ -class BazingaGeocoderBundle extends Bundle -{ - /** - * @return void - */ - public function build(ContainerBuilder $container): void - { - parent::build($container); - - $container->addCompilerPass(new ProfilerPass()); - $container->addCompilerPass(new AddProvidersPass()); - $container->addCompilerPass(new FactoryValidatorPass()); - } - - public function getPath(): string - { - return \dirname(__DIR__); - } -} diff --git a/src/Command/GeocodeCommand.php b/src/Command/GeocodeCommand.php deleted file mode 100644 index d17afa70..00000000 --- a/src/Command/GeocodeCommand.php +++ /dev/null @@ -1,97 +0,0 @@ - - */ -#[AsCommand(name: 'geocoder:geocode', description: 'Geocode an address or an IP address')] -class GeocodeCommand extends Command -{ - private ProviderAggregator $geocoder; - - public function __construct(ProviderAggregator $geocoder) - { - $this->geocoder = $geocoder; - - parent::__construct(); - } - - /** - * @return void - */ - protected function configure() - { - $this - ->addArgument('address', InputArgument::REQUIRED, 'The address') - ->addOption('provider', null, InputOption::VALUE_OPTIONAL) - ->setHelp(<<<'HELP' -The geocoder:geocoder command will fetch the latitude -and longitude from the given address. - -You can force a provider with the "provider" option. - -php bin/console geocoder:geocoder "Eiffel Tower" --provider=yahoo -HELP - ); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - if ($input->getOption('provider')) { - $this->geocoder->using($input->getOption('provider')); - } - - $results = $this->geocoder->geocodeQuery(GeocodeQuery::create($input->getArgument('address'))); - $data = $results->first()->toArray(); - - $max = 0; - - foreach ($data as $key => $value) { - $length = strlen($key); - if ($max < $length) { - $max = $length; - } - } - - $max += 2; - - foreach ($data as $key => $value) { - $key = $this->humanize($key); - - $output->writeln(sprintf( - '%s: %s', - str_pad($key, $max, ' ', STR_PAD_RIGHT), - is_array($value) ? json_encode($value) : $value - )); - } - - return 0; - } - - private function humanize(string $text): string - { - $text = preg_replace('/([A-Z][a-z]+)|([A-Z][A-Z]+)|([^A-Za-z ]+)/', ' \1', $text); - - return ucfirst(strtolower($text)); - } -} diff --git a/src/DataCollector/GeocoderDataCollector.php b/src/DataCollector/GeocoderDataCollector.php deleted file mode 100644 index d9bfe536..00000000 --- a/src/DataCollector/GeocoderDataCollector.php +++ /dev/null @@ -1,116 +0,0 @@ - - */ -class GeocoderDataCollector extends DataCollector -{ - /** - * @var ProfilingPlugin[] - */ - private array $instances = []; - - public function __construct() - { - $this->data['queries'] = []; - $this->data['providers'] = []; - } - - public function reset(): void - { - $this->instances = []; - $this->data['queries'] = []; - $this->data['providers'] = []; - } - - public function collect(Request $request, Response $response, ?\Throwable $exception = null): void - { - if (!empty($this->data['queries'])) { - // To avoid collection more that once. - return; - } - - $instances = $this->instances; - - foreach ($instances as $instance) { - foreach ($instance->getQueries() as $query) { - $query['query'] = $this->cloneVar($query['query']); - $query['result'] = $this->cloneVar($query['result']); - $this->data['queries'][] = $query; - } - } - } - - /** - * Returns an array of collected requests. - * - * @return list - */ - public function getQueries(): array - { - return $this->data['queries']; - } - - /** - * Returns the execution time of all collected requests in seconds. - */ - public function getTotalDuration(): float - { - $time = 0; - foreach ($this->data['queries'] as $command) { - $time += $command['duration']; - } - - return $time; - } - - /** - * @return string[] - */ - public function getProviders(): array - { - return $this->data['providers']; - } - - /** - * @return list - */ - public function getProviderQueries(string $provider): array - { - return array_filter($this->data['queries'], static function ($data) use ($provider) { - return $data['providerName'] === $provider; - }); - } - - /** - * @return void - */ - public function addInstance(ProfilingPlugin $instance) - { - $this->instances[] = $instance; - $this->data['providers'][] = $instance->getName(); - } - - public function getName(): string - { - return 'geocoder'; - } -} diff --git a/src/DependencyInjection/BazingaGeocoderExtension.php b/src/DependencyInjection/BazingaGeocoderExtension.php deleted file mode 100644 index c9abda29..00000000 --- a/src/DependencyInjection/BazingaGeocoderExtension.php +++ /dev/null @@ -1,227 +0,0 @@ -. - */ -class BazingaGeocoderExtension extends Extension -{ - /** - * @param array $configs - * - * @return void - */ - public function load(array $configs, ContainerBuilder $container) - { - $processor = new Processor(); - $configuration = $this->getConfiguration($configs, $container); - $config = $processor->processConfiguration($configuration, $configs); - - $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../config')); - $loader->load('services.php'); - - if (true === $config['profiling']['enabled']) { - $loader->load('profiling.php'); - } - - if ($config['fake_ip']['enabled']) { - $definition = $container->getDefinition(FakeIpPlugin::class); - $definition->replaceArgument(0, $config['fake_ip']['local_ip']); - $definition->replaceArgument(1, $config['fake_ip']['ip']); - $definition->replaceArgument(2, $config['fake_ip']['use_faker']); - - if ($config['fake_ip']['use_faker'] && !class_exists(Generator::class)) { - throw new \LogicException('To enable this option, you must install fakerphp/faker package.'); - } - } else { - $container->removeDefinition(FakeIpPlugin::class); - } - - $this->loadProviders($container, $config); - - $container->registerForAutoconfiguration(Dumper::class) - ->addTag('bazinga_geocoder.dumper'); - } - - /** - * @param array $config - * - * @return void - */ - private function loadProviders(ContainerBuilder $container, array $config) - { - foreach ($config['providers'] as $providerName => $providerConfig) { - try { - $factoryService = $container->getDefinition($providerConfig['factory']); - $factoryClass = $factoryService->getClass() ?: $providerConfig['factory']; - if (!$this->implementsProviderFactory($factoryClass)) { - throw new \LogicException(sprintf('Provider factory "%s" must implement ProviderFactoryInterface', $providerConfig['factory'])); - } - // See if any option has a service reference - $providerConfig['options'] = $this->findReferences($providerConfig['options']); - $factoryClass::validate($providerConfig['options'], $providerName); - } catch (ServiceNotFoundException $e) { - // Assert: We are using a custom factory. If invalid config, it will be caught in FactoryValidatorPass - $providerConfig['options'] = $this->findReferences($providerConfig['options']); - FactoryValidatorPass::addFactoryServiceId($providerConfig['factory']); - } - - $serviceId = 'bazinga_geocoder.provider.'.$providerName; - $plugins = $this->configureProviderPlugins($container, $providerConfig, $serviceId); - - $def = $container->register($serviceId, PluginProvider::class) - ->setFactory([PluginProviderFactory::class, 'createPluginProvider']) - ->addArgument($plugins) - ->addArgument(new Reference($providerConfig['factory'])) - ->addArgument($providerConfig['options']); - - $def->addTag('bazinga_geocoder.provider'); - foreach ($providerConfig['aliases'] as $alias) { - $container->setAlias($alias, $serviceId); - } - - $container->registerAliasForArgument($serviceId, Provider::class, "{$providerName}Geocoder"); - } - } - - /** - * Configure plugins for a client. - * - * @param array $config - * - * @return Reference[] - */ - public function configureProviderPlugins(ContainerBuilder $container, array $config, string $providerServiceId): array - { - $plugins = []; - foreach ($config['plugins'] as $plugin) { - if ($plugin['reference']['enabled']) { - $plugins[] = $plugin['reference']['id']; - } - } - - if ($container->has(FakeIpPlugin::class)) { - $plugins[] = FakeIpPlugin::class; - } - - if (isset($config['cache']) || isset($config['cache_lifetime']) || isset($config['cache_precision'])) { - $cacheLifetime = isset($config['cache_lifetime']) ? (int) $config['cache_lifetime'] : null; - - if (null === $cacheServiceId = $config['cache']) { - if (!$container->has('app.cache')) { - throw new \LogicException('You need to specify a service for cache.'); - } - $cacheServiceId = 'app.cache'; - } - $plugins[] = $providerServiceId.'.cache'; - $container->register($providerServiceId.'.cache', CachePlugin::class) - ->setPublic(false) - ->setArguments([new Reference($cacheServiceId), $cacheLifetime, $config['cache_precision']]); - } - - if (isset($config['limit'])) { - $plugins[] = $providerServiceId.'.limit'; - $container->register($providerServiceId.'.limit', LimitPlugin::class) - ->setPublic(false) - ->setArguments([(int) $config['limit']]); - } - - if (isset($config['locale'])) { - $plugins[] = $providerServiceId.'.locale'; - $container->register($providerServiceId.'.locale', LocalePlugin::class) - ->setPublic(false) - ->setArguments([$config['locale']]); - } - - if (isset($config['logger'])) { - $plugins[] = $providerServiceId.'.logger'; - $container->register($providerServiceId.'.logger', LoggerPlugin::class) - ->setPublic(false) - ->setArguments([new Reference($config['logger'])]); - } - - if ($container->has(GeocoderDataCollector::class)) { - $plugins[] = $providerServiceId.'.profiler'; - $container->register($providerServiceId.'.profiler', ProfilingPlugin::class) - ->setPublic(false) - ->setArguments([substr($providerServiceId, strlen('bazinga_geocoder.provider.'))]) - ->addTag('bazinga_geocoder.profiling_plugin'); - } - - return array_map(static fn (string $id) => new Reference($id), $plugins); - } - - /** - * @param array $config - */ - public function getConfiguration(array $config, ContainerBuilder $container): Configuration - { - /** @var bool $debug */ - $debug = $container->getParameter('kernel.debug'); - - return new Configuration($debug); - } - - /** - * @param array $options - * - * @return array - */ - 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) { - $options[$key] = new Reference(ltrim($value, '@')); - } - } - - return $options; - } - - /** - * @param mixed $factoryClass - */ - private function implementsProviderFactory($factoryClass): bool - { - if (false === $interfaces = class_implements($factoryClass)) { - return false; - } - - return in_array(ProviderFactoryInterface::class, $interfaces, true); - } -} diff --git a/src/DependencyInjection/Compiler/AddProvidersPass.php b/src/DependencyInjection/Compiler/AddProvidersPass.php deleted file mode 100644 index 526a94c1..00000000 --- a/src/DependencyInjection/Compiler/AddProvidersPass.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -class AddProvidersPass implements CompilerPassInterface -{ - /** - * Get all providers based on their tag (`bazinga_geocoder.provider`) and - * register them. - * - * @return void - */ - public function process(ContainerBuilder $container) - { - if (!$container->hasDefinition(ProviderAggregator::class)) { - return; - } - - $providers = []; - foreach ($container->findTaggedServiceIds('bazinga_geocoder.provider') as $providerId => $attributes) { - $providers[] = new Reference($providerId); - } - - $geocoderDefinition = $container->getDefinition(ProviderAggregator::class); - $geocoderDefinition->addMethodCall('registerProviders', [$providers]); - } -} diff --git a/src/DependencyInjection/Compiler/FactoryValidatorPass.php b/src/DependencyInjection/Compiler/FactoryValidatorPass.php deleted file mode 100644 index 6f54fba5..00000000 --- a/src/DependencyInjection/Compiler/FactoryValidatorPass.php +++ /dev/null @@ -1,52 +0,0 @@ - - */ -class FactoryValidatorPass implements CompilerPassInterface -{ - /** - * @var string[] - */ - private static $factoryServiceIds = []; - - /** - * @return void - */ - public function process(ContainerBuilder $container) - { - foreach (self::$factoryServiceIds as $id) { - if (!$container->hasAlias($id) && !$container->hasDefinition($id)) { - throw new ServiceNotFoundException(sprintf('Factory with ID "%s" could not be found', $id)); - } - } - } - - /** - * @param string $factoryServiceId - * - * @return void - */ - public static function addFactoryServiceId($factoryServiceId) - { - self::$factoryServiceIds[] = $factoryServiceId; - } -} diff --git a/src/DependencyInjection/Compiler/ProfilerPass.php b/src/DependencyInjection/Compiler/ProfilerPass.php deleted file mode 100644 index 3ba985db..00000000 --- a/src/DependencyInjection/Compiler/ProfilerPass.php +++ /dev/null @@ -1,42 +0,0 @@ - - */ -class ProfilerPass implements CompilerPassInterface -{ - /** - * @return void - */ - public function process(ContainerBuilder $container) - { - if (!$container->hasDefinition(GeocoderDataCollector::class)) { - return; - } - - $dataCollector = $container->getDefinition(GeocoderDataCollector::class); - - foreach ($container->findTaggedServiceIds('bazinga_geocoder.profiling_plugin') as $providerId => $attributes) { - $dataCollector->addMethodCall('addInstance', [new Reference($providerId)]); - } - } -} diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php deleted file mode 100644 index ca4d3da1..00000000 --- a/src/DependencyInjection/Configuration.php +++ /dev/null @@ -1,164 +0,0 @@ - - */ -class Configuration implements ConfigurationInterface -{ - private bool $debug; - - public function __construct(bool $debug) - { - $this->debug = $debug; - } - - /** - * Generates the configuration tree builder. - */ - public function getConfigTreeBuilder(): TreeBuilder - { - $treeBuilder = new TreeBuilder('bazinga_geocoder'); - $rootNode = $treeBuilder->getRootNode(); - assert($rootNode instanceof ArrayNodeDefinition); - - $rootNode - ->children() - ->append($this->getProvidersNode()) - ->arrayNode('profiling') - ->addDefaultsIfNotSet() - ->treatFalseLike(['enabled' => false]) - ->treatTrueLike(['enabled' => true]) - ->treatNullLike(['enabled' => $this->debug]) - ->info('Extend the debug profiler with information about requests.') - ->children() - ->booleanNode('enabled') - ->info('Turn the toolbar on or off. Defaults to kernel debug mode.') - ->defaultValue($this->debug) - ->end() - ->end() - ->end() - ->arrayNode('fake_ip') - ->beforeNormalization() - ->ifString() - ->then(function ($value) { - return ['ip' => $value]; - }) - ->end() - ->canBeEnabled() - ->children() - ->scalarNode('local_ip') - ->defaultValue('127.0.0.1') - ->end() - ->scalarNode('ip')->defaultNull()->end() - ->booleanNode('use_faker')->defaultFalse()->end() - ->end() - ->end(); - - return $treeBuilder; - } - - /** - * @return ArrayNodeDefinition - */ - private function getProvidersNode() - { - $treeBuilder = new TreeBuilder('providers'); - $rootNode = $treeBuilder->getRootNode(); - assert($rootNode instanceof ArrayNodeDefinition); - - $rootNode - ->requiresAtLeastOneElement() - ->useAttributeAsKey('name') - ->arrayPrototype() - ->fixXmlConfig('plugin') - ->children() - ->scalarNode('factory')->isRequired()->cannotBeEmpty()->end() - ->variableNode('options')->defaultValue([])->end() - ->scalarNode('cache')->defaultNull()->end() - ->scalarNode('cache_lifetime')->defaultNull()->end() - ->scalarNode('cache_precision') - ->defaultNull() - ->info('Precision of the coordinates to cache.') - ->end() - ->scalarNode('limit')->defaultNull()->end() - ->scalarNode('locale')->defaultNull()->end() - ->scalarNode('logger')->defaultNull()->end() - ->arrayNode('aliases') - ->scalarPrototype()->end() - ->end() - ->append($this->createClientPluginNode()) - ->end() - ->end(); - - return $rootNode; - } - - /** - * Create plugin node of a client. - * - * @return ArrayNodeDefinition The plugin node - */ - private function createClientPluginNode() - { - $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() - ; - $pluginList - // support having just a service id in the list - ->beforeNormalization() - ->always(function ($plugin) { - if (is_string($plugin)) { - return [ - 'reference' => [ - 'enabled' => true, - 'id' => $plugin, - ], - ]; - } - - return $plugin; - }) - ->end() - ; - - $pluginList - ->children() - ->arrayNode('reference') - ->canBeEnabled() - ->info('Reference to a plugin service') - ->children() - ->scalarNode('id') - ->info('Service id of a plugin') - ->isRequired() - ->cannotBeEmpty() - ->end() - ->end() - ->end() - ->end() - ->end(); - - return $rootNode; - } -} diff --git a/src/Doctrine/ORM/GeocoderListener.php b/src/Doctrine/ORM/GeocoderListener.php deleted file mode 100644 index 7df6b1c6..00000000 --- a/src/Doctrine/ORM/GeocoderListener.php +++ /dev/null @@ -1,118 +0,0 @@ - - */ -class GeocoderListener implements EventSubscriber -{ - public function __construct( - private readonly Provider $geocoder, - private readonly DriverInterface $driver, - ) { - } - - /** - * @return list - */ - public function getSubscribedEvents(): array - { - return [ - Events::onFlush, - ]; - } - - public function onFlush(OnFlushEventArgs $args): void - { - $em = $args->getObjectManager(); - $uow = $em->getUnitOfWork(); - - foreach ($uow->getScheduledEntityInsertions() as $entity) { - if (!$this->driver->isGeocodeable($entity)) { - continue; - } - - $metadata = $this->driver->loadMetadataFromObject($entity); - - $this->geocodeEntity($metadata, $entity); - - $uow->recomputeSingleEntityChangeSet( - $em->getClassMetadata(get_class($entity)), - $entity - ); - } - - foreach ($uow->getScheduledEntityUpdates() as $entity) { - if (!$this->driver->isGeocodeable($entity)) { - continue; - } - - $metadata = $this->driver->loadMetadataFromObject($entity); - - if (!$this->shouldGeocode($metadata, $uow, $entity)) { - continue; - } - - $this->geocodeEntity($metadata, $entity); - - $uow->recomputeSingleEntityChangeSet( - $em->getClassMetadata(get_class($entity)), - $entity - ); - } - } - - private function geocodeEntity(ClassMetadata $metadata, object $entity): void - { - if (null !== $metadata->addressGetter) { - $address = $metadata->addressGetter->invoke($entity); - } elseif (null !== $metadata->addressProperty) { - $address = $metadata->addressProperty->getValue($entity); - } else { - $address = ''; - } - - if (empty($address) || !is_string($address)) { - return; - } - - $results = $this->geocoder->geocodeQuery(GeocodeQuery::create($address)); - - if (!$results->isEmpty()) { - $result = $results->first(); - $metadata->latitudeProperty?->setValue($entity, $result->getCoordinates()->getLatitude()); - $metadata->longitudeProperty?->setValue($entity, $result->getCoordinates()->getLongitude()); - } - } - - private function shouldGeocode(ClassMetadata $metadata, UnitOfWork $unitOfWork, object $entity): bool - { - if (null !== $metadata->addressGetter) { - return true; - } - - $changeSet = $unitOfWork->getEntityChangeSet($entity); - - return isset($changeSet[$metadata->addressProperty?->getName() ?? '']); - } -} diff --git a/src/Mapping/Attributes/Address.php b/src/Mapping/Attributes/Address.php deleted file mode 100644 index 71375682..00000000 --- a/src/Mapping/Attributes/Address.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD)] -class Address -{ -} diff --git a/src/Mapping/Attributes/Geocodeable.php b/src/Mapping/Attributes/Geocodeable.php deleted file mode 100644 index 64a121c1..00000000 --- a/src/Mapping/Attributes/Geocodeable.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -#[\Attribute(\Attribute::TARGET_CLASS)] -class Geocodeable -{ -} diff --git a/src/Mapping/Attributes/Latitude.php b/src/Mapping/Attributes/Latitude.php deleted file mode 100644 index b399ffd4..00000000 --- a/src/Mapping/Attributes/Latitude.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -#[\Attribute(\Attribute::TARGET_PROPERTY)] -class Latitude -{ -} diff --git a/src/Mapping/Attributes/Longitude.php b/src/Mapping/Attributes/Longitude.php deleted file mode 100644 index 24d6c9d4..00000000 --- a/src/Mapping/Attributes/Longitude.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -#[\Attribute(\Attribute::TARGET_PROPERTY)] -class Longitude -{ -} diff --git a/src/Mapping/ClassMetadata.php b/src/Mapping/ClassMetadata.php deleted file mode 100644 index 07fbdbf8..00000000 --- a/src/Mapping/ClassMetadata.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ -final class ClassMetadata -{ - public function __construct( - public readonly ?\ReflectionProperty $addressProperty = null, - public readonly ?\ReflectionProperty $latitudeProperty = null, - public readonly ?\ReflectionProperty $longitudeProperty = null, - public readonly ?\ReflectionMethod $addressGetter = null, - ) { - } -} diff --git a/src/Mapping/Driver/AttributeDriver.php b/src/Mapping/Driver/AttributeDriver.php deleted file mode 100644 index b3dd63a5..00000000 --- a/src/Mapping/Driver/AttributeDriver.php +++ /dev/null @@ -1,90 +0,0 @@ - - */ -final class AttributeDriver implements DriverInterface -{ - public function isGeocodeable(object $object): bool - { - $reflection = self::getReflection($object); - - return [] !== $reflection->getAttributes(Attributes\Geocodeable::class); - } - - /** - * @throws MappingException - */ - public function loadMetadataFromObject(object $object): ClassMetadata - { - $reflection = self::getReflection($object); - - $attributes = $reflection->getAttributes(Attributes\Geocodeable::class); - - if ([] === $attributes) { - throw new MappingException(sprintf('The class "%s" is not geocodeable', get_class($object))); - } - - $args = []; - - foreach ($reflection->getProperties() as $property) { - foreach ($property->getAttributes() as $attribute) { - if (Attributes\Latitude::class === $attribute->getName()) { - $args['latitudeProperty'] = $property; - } elseif (Attributes\Longitude::class === $attribute->getName()) { - $args['longitudeProperty'] = $property; - } elseif (Attributes\Address::class === $attribute->getName()) { - $args['addressProperty'] = $property; - } - } - } - - foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { - if ([] !== $method->getAttributes(Attributes\Address::class)) { - if (0 !== $method->getNumberOfRequiredParameters()) { - throw new MappingException('You can not use a method requiring parameters with #[Address] attribute!'); - } - - $args['addressGetter'] = $method; - } - } - - return new ClassMetadata(...$args); - } - - /** - * @template T of object - * - * @param T $object - * - * @return \ReflectionClass - */ - private static function getReflection(object $object): \ReflectionClass - { - if (class_exists(ClassUtils::class)) { - /** @var \ReflectionClass */ - return ClassUtils::newReflectionObject($object); - } - - /** @var \ReflectionClass */ - return new \ReflectionClass(DefaultProxyClassNameResolver::getClass($object)); - } -} diff --git a/src/Mapping/Driver/DriverInterface.php b/src/Mapping/Driver/DriverInterface.php deleted file mode 100644 index 8d06209c..00000000 --- a/src/Mapping/Driver/DriverInterface.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ -class MappingException extends \Exception -{ -} diff --git a/src/Plugin/FakeIpPlugin.php b/src/Plugin/FakeIpPlugin.php deleted file mode 100644 index e45ff2d1..00000000 --- a/src/Plugin/FakeIpPlugin.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -class FakeIpPlugin implements Plugin -{ - private ?string $needle; - private ?string $replacement; - private ?Generator $faker = null; - - public function __construct(?string $needle, ?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) - { - if (!$query instanceof GeocodeQuery) { - return $next($query); - } - - $replacement = $this->replacement; - - if (null !== $this->faker) { - $replacement = $this->faker->ipv4(); - } - - if (null !== $this->needle && '' !== $this->needle) { - $text = str_replace($this->needle, $replacement, $query->getText(), $count); - - if ($count > 0) { - $query = $query->withText($text); - } - } else { - $query = $query->withText($replacement); - } - - return $next($query); - } -} diff --git a/src/Plugin/ProfilingPlugin.php b/src/Plugin/ProfilingPlugin.php deleted file mode 100644 index c2290779..00000000 --- a/src/Plugin/ProfilingPlugin.php +++ /dev/null @@ -1,101 +0,0 @@ - - */ -class ProfilingPlugin implements Plugin -{ - /** - * @var list - */ - private $queries = []; - - /** - * @var string service id of the provider - */ - private $name; - - public function __construct(string $name) - { - $this->name = $name; - } - - /** - * @return Promise - */ - public function handleQuery(Query $query, callable $next, callable $first) - { - $startTime = microtime(true); - - return $next($query)->then(function (Collection $result) use ($query, $startTime) { - $duration = (microtime(true) - $startTime) * 1000; - $this->logQuery($query, $duration, $result); - - return $result; - }, function (Exception $exception) use ($query, $startTime) { - $duration = (microtime(true) - $startTime) * 1000; - $this->logQuery($query, $duration, $exception); - - throw $exception; - }); - } - - /** - * @param mixed $result - * - * @return void - */ - private function logQuery(Query $query, float $duration, $result = null) - { - if ($query instanceof GeocodeQuery) { - $queryString = $query->getText(); - } elseif ($query instanceof ReverseQuery) { - $queryString = sprintf('(%s, %s)', $query->getCoordinates()->getLongitude(), $query->getCoordinates()->getLatitude()); - } else { - throw new LogicException('First parameter to ProfilingProvider::logQuery must be a Query'); - } - - $this->queries[] = [ - 'query' => $query, - 'queryString' => $queryString, - 'duration' => $duration, - 'providerName' => $this->getName(), - 'result' => $result, - 'resultCount' => $result instanceof Collection ? $result->count() : 0, - ]; - } - - /** - * @return list - */ - public function getQueries(): array - { - return $this->queries; - } - - public function getName(): string - { - return $this->name; - } -} diff --git a/src/ProviderFactory/AbstractFactory.php b/src/ProviderFactory/AbstractFactory.php deleted file mode 100644 index 83da203e..00000000 --- a/src/ProviderFactory/AbstractFactory.php +++ /dev/null @@ -1,102 +0,0 @@ - - */ -abstract class AbstractFactory implements ProviderFactoryInterface -{ - /** - * @var list - */ - protected static $dependencies = []; - - protected ?ClientInterface $httpClient; - - public function __construct(?ClientInterface $httpClient = null) - { - $this->httpClient = $httpClient; - } - - /** - * @param array $config - */ - abstract protected function getProvider(array $config): Provider; - - public function createProvider(array $options = []): Provider - { - $this->verifyDependencies(); - - $resolver = new OptionsResolver(); - static::configureOptionResolver($resolver); - $config = $resolver->resolve($options); - - return $this->getProvider($config); - } - - public static function validate(array $options, $providerName) - { - static::verifyDependencies(); - - $resolver = new OptionsResolver(); - static::configureOptionResolver($resolver); - - try { - $resolver->resolve($options); - } catch (\Exception $e) { - $message = sprintf( - 'Error while configure provider "%s". Verify your configuration at "bazinga_geocoder.providers.%s.options". %s', - $providerName, - $providerName, - $e->getMessage() - ); - - throw new InvalidConfigurationException($message, $e->getCode(), $e); - } - } - - /** - * Make sure that we have the required class and throw and exception if we don't. - * - * @return void - * - * @throws \LogicException - */ - protected static function verifyDependencies() - { - foreach (static::$dependencies as $dependency) { - if (!class_exists($dependency['requiredClass'])) { - throw new \LogicException(sprintf('You must install the "%s" package to use the "%s" factory.', $dependency['packageName'], static::class)); - } - } - } - - /** - * 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) - { - } -} diff --git a/src/ProviderFactory/AlgoliaFactory.php b/src/ProviderFactory/AlgoliaFactory.php deleted file mode 100644 index d88639ee..00000000 --- a/src/ProviderFactory/AlgoliaFactory.php +++ /dev/null @@ -1,49 +0,0 @@ - AlgoliaPlaces::class, 'packageName' => 'geocoder-php/algolia-places-provider'], - ]; - - /** - * @param array{api_key: ?string, app_id: ?string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new AlgoliaPlaces($httpClient, $config['api_key'], $config['app_id']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'api_key' => null, - 'app_id' => null, - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string', 'null']); - $resolver->setAllowedTypes('app_id', ['string', 'null']); - } -} diff --git a/src/ProviderFactory/ArcGISOnlineFactory.php b/src/ProviderFactory/ArcGISOnlineFactory.php deleted file mode 100644 index a51aeb00..00000000 --- a/src/ProviderFactory/ArcGISOnlineFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - ArcGISOnline::class, 'packageName' => 'geocoder-php/arcgis-online-provider'], - ]; - - /** - * @param array{source_country: ?string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new ArcGISOnline($httpClient, $config['source_country']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'source_country' => null, - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('source_country', ['string', 'null']); - } -} diff --git a/src/ProviderFactory/BingMapsFactory.php b/src/ProviderFactory/BingMapsFactory.php deleted file mode 100644 index ce141b98..00000000 --- a/src/ProviderFactory/BingMapsFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - BingMaps::class, 'packageName' => 'geocoder-php/bing-maps-provider'], - ]; - - /** - * @param array{api_key: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new BingMaps($httpClient, $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - } -} diff --git a/src/ProviderFactory/ChainFactory.php b/src/ProviderFactory/ChainFactory.php deleted file mode 100644 index 77eb4404..00000000 --- a/src/ProviderFactory/ChainFactory.php +++ /dev/null @@ -1,52 +0,0 @@ - - */ -final class ChainFactory extends AbstractFactory implements LoggerAwareInterface -{ - use LoggerAwareTrait; - - protected static $dependencies = [ - ['requiredClass' => Chain::class, 'packageName' => 'geocoder-php/chain-provider'], - ]; - - /** - * @param array{services: Provider[]} $config - */ - protected function getProvider(array $config): Provider - { - $provider = new Chain($config['services']); - if (null !== $this->logger) { - $provider->setLogger($this->logger); - } - - return $provider; - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - parent::configureOptionResolver($resolver); - - $resolver->setRequired('services'); - $resolver->setAllowedTypes('services', ['array']); - } -} diff --git a/src/ProviderFactory/FreeGeoIpFactory.php b/src/ProviderFactory/FreeGeoIpFactory.php deleted file mode 100644 index d4884615..00000000 --- a/src/ProviderFactory/FreeGeoIpFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - FreeGeoIp::class, 'packageName' => 'geocoder-php/free-geoip-provider'], - ]; - - /** - * @param array{base_url: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new FreeGeoIp($httpClient, $config['base_url']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'base_url' => 'https://freegeoip.app/json/%s', - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('base_url', ['string']); - } -} diff --git a/src/ProviderFactory/GeoIP2Factory.php b/src/ProviderFactory/GeoIP2Factory.php deleted file mode 100644 index 77dfdbce..00000000 --- a/src/ProviderFactory/GeoIP2Factory.php +++ /dev/null @@ -1,75 +0,0 @@ - GeoIP2::class, 'packageName' => 'geocoder-php/geoip2-provider'], - ]; - - /** - * @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 - */ - protected function getProvider(array $config): Provider - { - $provider = $config['provider']; - if ('webservice' === $provider) { - $userId = isset($config['user_id']) ? (int) $config['user_id'] : null; - - $provider = new Client($userId, $config['license_key'], $config['locales'], $config['webservice_options']); - } elseif ('database' === $provider) { - $provider = new Reader($config['database_filename'], $config['locales']); - } else { - $provider = $config['provider_service']; - } - - $adapter = new GeoIP2Adapter($provider, $config['model']); - - return new GeoIP2($adapter); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'model' => GeoIP2Adapter::GEOIP2_MODEL_CITY, - 'database_filename' => null, - 'user_id' => null, - 'license_key' => null, - 'webservice_options' => [], - 'locales' => ['en'], - 'provider_service' => null, - ]); - - $resolver->setRequired('provider'); - $resolver->setAllowedTypes('provider', ['string']); - $resolver->setAllowedTypes('provider_service', [ProviderInterface::class, 'null']); - $resolver->setAllowedTypes('model', ['string']); - $resolver->setAllowedTypes('user_id', ['string', 'int', 'null']); - $resolver->setAllowedTypes('license_key', ['string', 'null']); - $resolver->setAllowedTypes('locales', ['array']); - $resolver->setAllowedTypes('webservice_options', ['array']); - $resolver->setAllowedTypes('database_filename', ['string', 'null']); - - $resolver->setAllowedValues('model', [GeoIP2Adapter::GEOIP2_MODEL_CITY, GeoIP2Adapter::GEOIP2_MODEL_COUNTRY]); - $resolver->setAllowedValues('provider', ['webservice', 'database', 'service']); - } -} diff --git a/src/ProviderFactory/GeoPluginFactory.php b/src/ProviderFactory/GeoPluginFactory.php deleted file mode 100644 index ec77677b..00000000 --- a/src/ProviderFactory/GeoPluginFactory.php +++ /dev/null @@ -1,45 +0,0 @@ - GeoPlugin::class, 'packageName' => 'geocoder-php/geo-plugin-provider'], - ]; - - /** - * @param array{http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new GeoPlugin($httpClient); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - } -} diff --git a/src/ProviderFactory/GeoipFactory.php b/src/ProviderFactory/GeoipFactory.php deleted file mode 100644 index 03a874a7..00000000 --- a/src/ProviderFactory/GeoipFactory.php +++ /dev/null @@ -1,36 +0,0 @@ - Geoip::class, 'packageName' => 'geocoder-php/geoip-provider'], - ]; - - /** - * @param array{} $config - */ - protected function getProvider(array $config): Provider - { - return new Geoip(); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - } -} diff --git a/src/ProviderFactory/GeonamesFactory.php b/src/ProviderFactory/GeonamesFactory.php deleted file mode 100644 index 284f97ac..00000000 --- a/src/ProviderFactory/GeonamesFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - Geonames::class, 'packageName' => 'geocoder-php/geonames-provider'], - ]; - - /** - * @param array{username: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new Geonames($httpClient, $config['username']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setRequired('username'); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('username', ['string']); - } -} diff --git a/src/ProviderFactory/GoogleMapsFactory.php b/src/ProviderFactory/GoogleMapsFactory.php deleted file mode 100644 index 01339d19..00000000 --- a/src/ProviderFactory/GoogleMapsFactory.php +++ /dev/null @@ -1,49 +0,0 @@ - GoogleMaps::class, 'packageName' => 'geocoder-php/google-maps-provider'], - ]; - - /** - * @param array{api_key: ?string, region: ?string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new GoogleMaps($httpClient, $config['region'], $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'region' => null, - 'api_key' => null, - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('region', ['string', 'null']); - $resolver->setAllowedTypes('api_key', ['string', 'null']); - } -} diff --git a/src/ProviderFactory/GoogleMapsPlacesFactory.php b/src/ProviderFactory/GoogleMapsPlacesFactory.php deleted file mode 100644 index ceaf9b0b..00000000 --- a/src/ProviderFactory/GoogleMapsPlacesFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - GoogleMapsPlaces::class, 'packageName' => 'geocoder-php/google-maps-places-provider'], - ]; - - /** - * @param array{api_key: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new GoogleMapsPlaces($httpClient, $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setRequired(['api_key']); - $resolver->setAllowedTypes('api_key', ['string']); - } -} diff --git a/src/ProviderFactory/HereFactory.php b/src/ProviderFactory/HereFactory.php deleted file mode 100644 index 6b723f46..00000000 --- a/src/ProviderFactory/HereFactory.php +++ /dev/null @@ -1,65 +0,0 @@ - Here::class, 'packageName' => 'geocoder-php/here-provider'], - ]; - - /** - * @param array{app_key: ?string, app_id: ?string, app_code: ?string, use_cit: bool, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - if (empty($config['app_key']) && empty($config['app_id']) && empty($config['app_code'])) { - throw new \InvalidArgumentException('No authentication key provided. Here requires app_key or app_code and app_id.'); - } - - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - if (!empty($config['app_key'])) { - if (!method_exists(Here::class, 'createUsingApiKey')) { - throw new \InvalidArgumentException('Here provider has no support for `creatingUsingApiKey` method.'); - } - - return Here::createUsingApiKey($httpClient, $config['app_key'], $config['use_cit']); - } - - return new Here($httpClient, $config['app_id'], $config['app_code'], $config['use_cit']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'use_cit' => false, - 'app_key' => null, - 'app_id' => null, - 'app_code' => 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']); - } -} diff --git a/src/ProviderFactory/HostIpFactory.php b/src/ProviderFactory/HostIpFactory.php deleted file mode 100644 index 3585478e..00000000 --- a/src/ProviderFactory/HostIpFactory.php +++ /dev/null @@ -1,45 +0,0 @@ - HostIp::class, 'packageName' => 'geocoder-php/host-ip-provider'], - ]; - - /** - * @param array{http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new HostIp($httpClient); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - } -} diff --git a/src/ProviderFactory/IpInfoDbFactory.php b/src/ProviderFactory/IpInfoDbFactory.php deleted file mode 100644 index 105648cb..00000000 --- a/src/ProviderFactory/IpInfoDbFactory.php +++ /dev/null @@ -1,49 +0,0 @@ - IpInfoDb::class, 'packageName' => 'geocoder-php/ip-info-db-provider'], - ]; - - /** - * @param array{api_key: string, precision: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new IpInfoDb($httpClient, $config['api_key'], $config['precision']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'precision' => 'city', - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - $resolver->setAllowedTypes('precision', ['string']); - } -} diff --git a/src/ProviderFactory/IpInfoFactory.php b/src/ProviderFactory/IpInfoFactory.php deleted file mode 100644 index ea11dd50..00000000 --- a/src/ProviderFactory/IpInfoFactory.php +++ /dev/null @@ -1,45 +0,0 @@ - IpInfo::class, 'packageName' => 'geocoder-php/ip-info-provider'], - ]; - - /** - * @param array{http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new IpInfo($httpClient); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - } -} diff --git a/src/ProviderFactory/IpstackFactory.php b/src/ProviderFactory/IpstackFactory.php deleted file mode 100644 index 5706fbd8..00000000 --- a/src/ProviderFactory/IpstackFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - Ipstack::class, 'packageName' => 'geocoder-php/ipstack-provider'], - ]; - - /** - * @param array{api_key: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new Ipstack($httpClient, $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - } -} diff --git a/src/ProviderFactory/LocationIQFactory.php b/src/ProviderFactory/LocationIQFactory.php deleted file mode 100644 index d8081fe1..00000000 --- a/src/ProviderFactory/LocationIQFactory.php +++ /dev/null @@ -1,45 +0,0 @@ - LocationIQ::class, 'packageName' => 'geocoder-php/locationiq-provider'], - ]; - - /** - * @param array{api_key: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new LocationIQ($httpClient, $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setRequired(['api_key']); - $resolver->setAllowedTypes('api_key', ['string']); - } -} diff --git a/src/ProviderFactory/MapQuestFactory.php b/src/ProviderFactory/MapQuestFactory.php deleted file mode 100644 index d376f2ff..00000000 --- a/src/ProviderFactory/MapQuestFactory.php +++ /dev/null @@ -1,49 +0,0 @@ - MapQuest::class, 'packageName' => 'geocoder-php/mapquest-provider'], - ]; - - /** - * @param array{api_key: string, licensed: bool, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new MapQuest($httpClient, $config['api_key'], $config['licensed']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'licensed' => false, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - $resolver->setAllowedTypes('licensed', ['boolean']); - } -} diff --git a/src/ProviderFactory/MapboxFactory.php b/src/ProviderFactory/MapboxFactory.php deleted file mode 100644 index 04ba1db7..00000000 --- a/src/ProviderFactory/MapboxFactory.php +++ /dev/null @@ -1,49 +0,0 @@ - Mapbox::class, 'packageName' => 'geocoder-php/mapbox-provider'], - ]; - - /** - * @param array{api_key: string, country: ?string, mode: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new Mapbox($httpClient, $config['api_key'], $config['country'], $config['mode']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'country' => null, - 'mode' => Mapbox::GEOCODING_MODE_PLACES, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('api_key', ['string']); - $resolver->setAllowedTypes('mode', ['string']); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('country', ['string', 'null']); - } -} diff --git a/src/ProviderFactory/MaxMindBinaryFactory.php b/src/ProviderFactory/MaxMindBinaryFactory.php deleted file mode 100644 index 009792f7..00000000 --- a/src/ProviderFactory/MaxMindBinaryFactory.php +++ /dev/null @@ -1,43 +0,0 @@ - MaxMindBinary::class, 'packageName' => 'geocoder-php/maxmind-binary-provider'], - ]; - - /** - * @param array{dat_file: string, open_flag: ?int} $config - */ - protected function getProvider(array $config): Provider - { - return new MaxMindBinary($config['dat_file'], $config['open_flag']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'open_flag' => null, - ]); - - $resolver->setRequired('dat_file'); - $resolver->setAllowedTypes('dat_file', ['string']); - $resolver->setAllowedTypes('open_flag', ['int', 'null']); - } -} diff --git a/src/ProviderFactory/MaxMindFactory.php b/src/ProviderFactory/MaxMindFactory.php deleted file mode 100644 index a3b3043b..00000000 --- a/src/ProviderFactory/MaxMindFactory.php +++ /dev/null @@ -1,49 +0,0 @@ - MaxMind::class, 'packageName' => 'geocoder-php/maxmind-provider'], - ]; - - /** - * @param array{api_key: string, endpoint: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new MaxMind($httpClient, $config['api_key'], $config['endpoint']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'endpoint' => MaxMind::CITY_EXTENDED_SERVICE, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - $resolver->setAllowedValues('endpoint', [MaxMind::CITY_EXTENDED_SERVICE, MaxMind::OMNI_SERVICE]); - } -} diff --git a/src/ProviderFactory/NominatimFactory.php b/src/ProviderFactory/NominatimFactory.php deleted file mode 100644 index f86ea220..00000000 --- a/src/ProviderFactory/NominatimFactory.php +++ /dev/null @@ -1,50 +0,0 @@ - Nominatim::class, 'packageName' => 'geocoder-php/nominatim-provider'], - ]; - - /** - * @param array{root_url: string, user_agent: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new Nominatim($httpClient, $config['root_url'], $config['user_agent']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'root_url' => 'https://nominatim.openstreetmap.org', - 'user_agent' => 'BazingaGeocoderBundle', - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('root_url', ['string']); - $resolver->setAllowedTypes('user_agent', ['string']); - $resolver->setRequired('user_agent'); - } -} diff --git a/src/ProviderFactory/OpenCageFactory.php b/src/ProviderFactory/OpenCageFactory.php deleted file mode 100644 index fb21b7fa..00000000 --- a/src/ProviderFactory/OpenCageFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - OpenCage::class, 'packageName' => 'geocoder-php/open-cage-provider'], - ]; - - /** - * @param array{api_key: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new OpenCage($httpClient, $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - } -} diff --git a/src/ProviderFactory/OpenRouteServiceFactory.php b/src/ProviderFactory/OpenRouteServiceFactory.php deleted file mode 100644 index f53e96d0..00000000 --- a/src/ProviderFactory/OpenRouteServiceFactory.php +++ /dev/null @@ -1,48 +0,0 @@ - OpenRouteService::class, 'packageName' => 'geocoder-php/openrouteservice-provider'], - ]; - - /** - * @param array{api_key: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new OpenRouteService($httpClient, $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'api_key' => null, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - } -} diff --git a/src/ProviderFactory/PickPointFactory.php b/src/ProviderFactory/PickPointFactory.php deleted file mode 100644 index f7fdc9f4..00000000 --- a/src/ProviderFactory/PickPointFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - PickPoint::class, 'packageName' => 'geocoder-php/pickpoint-provider'], - ]; - - /** - * @param array{api_key: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new PickPoint($httpClient, $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - } -} diff --git a/src/ProviderFactory/PluginProviderFactory.php b/src/ProviderFactory/PluginProviderFactory.php deleted file mode 100644 index af1a2ce7..00000000 --- a/src/ProviderFactory/PluginProviderFactory.php +++ /dev/null @@ -1,43 +0,0 @@ - - */ -final class PluginProviderFactory -{ - /** - * @param Plugin[] $plugins - * @param ProviderFactoryInterface|callable $factory - * @param array $config config to the client factory - * @param array{max_restarts?: int<0, max>} $pluginProviderOptions config forwarded to the PluginProvider - */ - public static function createPluginProvider(array $plugins, $factory, array $config, array $pluginProviderOptions = []): PluginProvider - { - if ($factory instanceof ProviderFactoryInterface) { - $client = $factory->createProvider($config); - } elseif (is_callable($factory)) { - $client = $factory($config); - } else { - throw new \RuntimeException(sprintf('Second argument to PluginProviderFactory::createPluginProvider must be a "%s" or a callable.', ProviderFactoryInterface::class)); - } - - return new PluginProvider($client, $plugins, $pluginProviderOptions); - } -} diff --git a/src/ProviderFactory/ProviderFactoryInterface.php b/src/ProviderFactory/ProviderFactoryInterface.php deleted file mode 100644 index 5f96dbaf..00000000 --- a/src/ProviderFactory/ProviderFactoryInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - */ -interface ProviderFactoryInterface -{ - /** - * @param array $options - */ - public function createProvider(array $options = []): Provider; - - /** - * Make sure the options are valid and the dependencies are met. - * - * @param array $options the options the user has provided - * @param string $providerName the name the user has chosen for this provider - * - * @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 - * @throws \Symfony\Component\OptionsResolver\Exception\MissingOptionsException If a required option is missing - * @throws \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException If there is a cyclic dependency between lazy options and/or normalizers - * @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); -} diff --git a/src/ProviderFactory/TomTomFactory.php b/src/ProviderFactory/TomTomFactory.php deleted file mode 100644 index 4f57151f..00000000 --- a/src/ProviderFactory/TomTomFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - TomTom::class, 'packageName' => 'geocoder-php/tomtom-provider'], - ]; - - /** - * @param array{api_key: string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new TomTom($httpClient, $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - ]); - - $resolver->setRequired('api_key'); - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('api_key', ['string']); - } -} diff --git a/src/ProviderFactory/YandexFactory.php b/src/ProviderFactory/YandexFactory.php deleted file mode 100644 index 77b2a6d2..00000000 --- a/src/ProviderFactory/YandexFactory.php +++ /dev/null @@ -1,49 +0,0 @@ - Yandex::class, 'packageName' => 'geocoder-php/yandex-provider'], - ]; - - /** - * @param array{toponym: ?string, api_key: ?string, http_client: ?ClientInterface} $config - */ - protected function getProvider(array $config): Provider - { - $httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find(); - - return new Yandex($httpClient, $config['toponym'], $config['api_key']); - } - - protected static function configureOptionResolver(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'http_client' => null, - 'toponym' => null, - 'api_key' => null, - ]); - - $resolver->setAllowedTypes('http_client', ['object', 'null']); - $resolver->setAllowedTypes('toponym', ['string', 'null']); - $resolver->setAllowedTypes('api_key', ['string', 'null']); - } -} diff --git a/src/Validator/Constraint/Address.php b/src/Validator/Constraint/Address.php deleted file mode 100644 index 7ceb4480..00000000 --- a/src/Validator/Constraint/Address.php +++ /dev/null @@ -1,56 +0,0 @@ - - */ -#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] -class Address extends Constraint -{ - public const INVALID_ADDRESS_ERROR = '2243aa07-2ea7-4eb7-962c-6a9586593f2c'; - - protected const ERROR_NAMES = [ - self::INVALID_ADDRESS_ERROR => 'INVALID_ADDRESS_ERROR', - ]; - - /** - * @var string - */ - public $service = AddressValidator::class; - - /** - * @var string - */ - public $message = 'Address {{ address }} is not valid.'; - - /** - * @param string[]|null $options - */ - public function __construct(?array $options = null, ?string $message = null, ?array $groups = null, $payload = null) - { - parent::__construct($options, $groups, $payload); - - $this->message = $message ?? $this->message; - } - - public function validatedBy(): string - { - return $this->service; - } -} diff --git a/src/Validator/Constraint/AddressValidator.php b/src/Validator/Constraint/AddressValidator.php deleted file mode 100644 index a01ff13a..00000000 --- a/src/Validator/Constraint/AddressValidator.php +++ /dev/null @@ -1,81 +0,0 @@ - - */ -class AddressValidator extends ConstraintValidator -{ - /** - * @var Provider - */ - protected $addressGeocoder; - - public function __construct(Provider $addressGeocoder) - { - $this->addressGeocoder = $addressGeocoder; - } - - /** - * @param mixed $value - * - * @return void - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof Address) { - throw new UnexpectedTypeException($constraint, Address::class); - } - - if (null === $value || '' === $value) { - return; - } - - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { - throw new UnexpectedValueException($value, 'string'); - } - - $value = (string) $value; - - try { - $collection = $this->addressGeocoder->geocodeQuery(GeocodeQuery::create($value)); - - if ($collection->isEmpty()) { - $this->buildViolation($constraint, $value); - } - } catch (Exception $e) { - $this->buildViolation($constraint, $value); - } - } - - /** - * @return void - */ - private function buildViolation(Address $constraint, string $address) - { - $this->context->buildViolation($constraint->message) - ->setParameter('{{ address }}', $this->formatValue($address)) - ->setInvalidValue($address) - ->setCode(Address::INVALID_ADDRESS_ERROR) - ->addViolation(); - } -} diff --git a/templates/Collector/geocoder.html.twig b/templates/Collector/geocoder.html.twig deleted file mode 100644 index 3618d968..00000000 --- a/templates/Collector/geocoder.html.twig +++ /dev/null @@ -1,136 +0,0 @@ -{% extends '@WebProfiler/Profiler/layout.html.twig' %} - -{% block toolbar %} - {% set queryLabel = collector.queries|length == 1 ? 'query' : 'queries' %} - {% if collector.queries|length > 0 %} - {% set icon %} - {{ include('@BazingaGeocoder/Collector/icon.svg') }} - {{ collector.queries|length }} - {{ queryLabel }} in - {{ collector.totalDuration|number_format }} - ms - {% endset %} - {% set text %} -
- {{ collector.queries|length }} {{ queryLabel }} -
-
- - - - - - - - - - {% for query in collector.queries %} - - - - - - {% endfor %} - -
ProviderQueryTime
{{ query.providerName }}{{ query.queryString }}{{ query.duration == 0 ? 'n/a' : query.duration|number_format ~ ' ms'}}
-
- {% endset %} - - {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url } %} -{% endif %} -{% endblock %} - -{% block menu %} - {# This left-hand menu appears when using the full-screen profiler. #} - - - {{ include('@BazingaGeocoder/Collector/icon.svg') }} - - Geocoder - -{% endblock %} - -{% block panel %} - -

Geocoder

- -
- {% for provider in collector.providers %} -
-

{{ provider }} {{ collector.providerQueries(provider)|length }}

- -
-

- These queries are executed by a provider named "{{ provider }}". -

- - - - - - - - - - - - - {% for query in collector.providerQueries(provider) %} - - - - - - - - - - - - {% if query.result.message is defined %} - - {% else %} - - {% endif %} - - - {% endfor %} - -
QueryLocaleResultDuration
- # {{ loop.index }} - - - {{ query.queryString }} - - - - {{ query.query.locale is not null ? query.query.locale : 'null' }} - - - - {% if query.result.message is defined %} - Exception - {% else %} - {{ query.resultCount }} Result(s) - {% endif %} - - - - {{ query.duration|number_format }} ms -
{{ profiler_dump(query.query, maxDepth=1) }}{{ profiler_dump(query.result, maxDepth=1) }}{{ profiler_dump(query.result, maxDepth=3) }}
- -
-
- {% else %} -
-

No queries were executed.

-
- {% endfor %} -
-{% endblock %} diff --git a/templates/Collector/icon.svg b/templates/Collector/icon.svg deleted file mode 100644 index 4ca756dc..00000000 --- a/templates/Collector/icon.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/tests/Command/GeocodeCommandTest.php b/tests/Command/GeocodeCommandTest.php deleted file mode 100644 index 203ef8e9..00000000 --- a/tests/Command/GeocodeCommandTest.php +++ /dev/null @@ -1,79 +0,0 @@ - - */ -final class GeocodeCommandTest extends TestCase -{ - private static $address = '10 rue Gambetta, Paris, France'; - - public function testExecute(): void - { - $coordinates = new Coordinates(1, 2); - $country = new Country('France', 'FR'); - $address = Address::createFromArray([ - 'coordinates' => $coordinates, - 'streetNumber' => '10', - 'streetName' => 'rue Gambetta', - 'zipCode' => '75020', - 'locality' => 'Paris', - 'countryName' => $country->getName(), - 'countryCode' => $country->getCode(), - ]); - - $geocoder = $this->createMock(ProviderAggregator::class); - $query = GeocodeQuery::create(self::$address); - $geocoder->expects($this->once()) - ->method('geocodeQuery') - ->with($query) - ->willReturn(new AddressCollection([$address])); - - $container = $this->createMock(Container::class); - - $kernel = $this->createMock(Kernel::class); - - $kernel->expects($this->any()) - ->method('getContainer') - ->willReturn($container); - - $kernel->expects($this->any()) - ->method('getBundles') - ->willReturn([]); - - $app = new Application($kernel); - $app->add((new GeocodeCommand($geocoder))->setName('geocoder:geocode')); - - $command = $app->find('geocoder:geocode'); - - $tester = new CommandTester($command); - $tester->execute([ - 'command' => 'geocoder:geocode', - 'address' => self::$address, - ]); - } -} diff --git a/tests/DependencyInjection/Compiler/AddProvidersPassTest.php b/tests/DependencyInjection/Compiler/AddProvidersPassTest.php deleted file mode 100644 index 97f9ed24..00000000 --- a/tests/DependencyInjection/Compiler/AddProvidersPassTest.php +++ /dev/null @@ -1,50 +0,0 @@ -compilerPass = new AddProvidersPass(); - } - - public function testRegistersProviders(): void - { - $containerBuilder = new ContainerBuilder(); - $containerBuilder->setDefinition(ProviderAggregator::class, new Definition(ProviderAggregator::class)); - - $bing = $containerBuilder->setDefinition('bing_maps', new Definition(BingMaps::class, [new Psr18Client(new MockHttpClient()), 'apikey'])); - $bing->addTag('bazinga_geocoder.provider'); - - $this->compilerPass->process($containerBuilder); - - /** @var ProviderAggregator $providerAggregator */ - $providerAggregator = $containerBuilder->get(ProviderAggregator::class); - $providers = $providerAggregator->getProviders(); - - self::assertArrayHasKey('bing_maps', $providers); - self::assertInstanceOf(BingMaps::class, $providers['bing_maps']); - } -} diff --git a/tests/DependencyInjection/Compiler/FactoryValidatorPassTest.php b/tests/DependencyInjection/Compiler/FactoryValidatorPassTest.php deleted file mode 100644 index 0b7f3f7f..00000000 --- a/tests/DependencyInjection/Compiler/FactoryValidatorPassTest.php +++ /dev/null @@ -1,87 +0,0 @@ -compilerPass = new FactoryValidatorPass(); - $this->factoryId = 'dummy_factory_id'; - $this->compilerPass::addFactoryServiceId($this->factoryId); - } - - protected function tearDown(): void - { - $reflection = new \ReflectionObject($this->compilerPass); - $prop = $reflection->getProperty('factoryServiceIds'); - $prop->setAccessible(true); - $prop->setValue(null, []); - } - - public function testProcessThrows(): void - { - $this->expectException(ServiceNotFoundException::class); - $this->expectExceptionMessage("Factory with ID \"$this->factoryId\" could not be found"); - - $container = $this->createMock(ContainerBuilder::class); - $container->expects($this->once()) - ->method('hasAlias') - ->with($this->factoryId) - ->willReturn(false); - $container->expects($this->once()) - ->method('hasDefinition') - ->with($this->factoryId) - ->willReturn(false); - - $this->compilerPass->process($container); - } - - public function testProcessDoesntThrowIfAliasExists(): void - { - $container = $this->createMock(ContainerBuilder::class); - $container->expects($this->once()) - ->method('hasAlias') - ->with($this->factoryId) - ->willReturn(true); - $container->expects($this->never()) - ->method('hasDefinition') - ->with($this->factoryId) - ->willReturn(false); - - $this->compilerPass->process($container); - } - - public function testProcessDoesntThrowIfDefinitionExists(): void - { - $container = $this->createMock(ContainerBuilder::class); - $container->expects($this->once()) - ->method('hasAlias') - ->with($this->factoryId) - ->willReturn(false); - $container->expects($this->once()) - ->method('hasDefinition') - ->with($this->factoryId) - ->willReturn(true); - - $this->compilerPass->process($container); - } -} diff --git a/tests/DependencyInjection/Compiler/ProfilerPassTest.php b/tests/DependencyInjection/Compiler/ProfilerPassTest.php deleted file mode 100644 index 05bba924..00000000 --- a/tests/DependencyInjection/Compiler/ProfilerPassTest.php +++ /dev/null @@ -1,47 +0,0 @@ -compilerPass = new ProfilerPass(); - } - - public function testRegistersProviders(): void - { - $geocoderDataCollectorDefinition = new Definition(GeocoderDataCollector::class); - - $containerBuilder = new ContainerBuilder(); - $containerBuilder->setDefinition(GeocoderDataCollector::class, $geocoderDataCollectorDefinition); - - $bing = $containerBuilder->setDefinition('geocoder_profiling', new Definition(ProfilingPlugin::class, ['provider_id'])); - $bing->addTag('bazinga_geocoder.profiling_plugin'); - - $this->compilerPass->process($containerBuilder); - - self::assertTrue($geocoderDataCollectorDefinition->hasMethodCall('addInstance')); - self::assertInstanceOf(Reference::class, $geocoderDataCollectorDefinition->getMethodCalls()[0][1][0]); - } -} diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php deleted file mode 100644 index 858f259d..00000000 --- a/tests/DependencyInjection/ConfigurationTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ -final class ConfigurationTest extends TestCase -{ - public function testGetConfigTreeBuilder(): void - { - $config = Yaml::parseFile(__DIR__.'/Fixtures/config.yml'); - - $configuration = new Configuration(true); - $treeBuilder = $configuration->getConfigTreeBuilder(); - $processor = new Processor(); - - $config = $processor->process($treeBuilder->buildTree(), $config); - - self::assertTrue($config['profiling']['enabled']); - self::assertTrue($config['fake_ip']['enabled']); - self::assertSame('192.168.99.1', $config['fake_ip']['local_ip']); - self::assertSame('33.33.33.11', $config['fake_ip']['ip']); - } - - public function testGetConfigTreeBuilderNoDebug(): void - { - $config = Yaml::parseFile(__DIR__.'/Fixtures/config.yml'); - - $configuration = new Configuration(false); - $treeBuilder = $configuration->getConfigTreeBuilder(); - $processor = new Processor(); - - $config = $processor->process($treeBuilder->buildTree(), $config); - - self::assertFalse($config['profiling']['enabled']); - } -} diff --git a/tests/DependencyInjection/Fixtures/config.yml b/tests/DependencyInjection/Fixtures/config.yml deleted file mode 100644 index 87de3cc4..00000000 --- a/tests/DependencyInjection/Fixtures/config.yml +++ /dev/null @@ -1,10 +0,0 @@ -bazinga_geocoder: - fake_ip: - local_ip: 192.168.99.1 - ip: 33.33.33.11 - providers: - bing_maps: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - options: - api_key: 123 - locale: en_US diff --git a/tests/DependencyInjection/Fixtures/maxmind.dat b/tests/DependencyInjection/Fixtures/maxmind.dat deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Functional/BundleInitializationTest.php b/tests/Functional/BundleInitializationTest.php deleted file mode 100644 index 705b303e..00000000 --- a/tests/Functional/BundleInitializationTest.php +++ /dev/null @@ -1,182 +0,0 @@ -addTestBundle(BazingaGeocoderBundle::class); - $kernel->handleOptions($options); - - return $kernel; - } - - public function testInitBundle(): 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'); - } - }]); - - $container = self::getContainer(); - - // Test if services exists - self::assertTrue($container->has(ProviderAggregator::class)); - $service = $container->get(ProviderAggregator::class); - self::assertInstanceOf(ProviderAggregator::class, $service); - } - - public function testBundleWithOneProviderConfiguration(): 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/simple.yml'); - }]); - - $container = self::getContainer(); - - self::assertTrue($container->has('bazinga_geocoder.provider.acme')); - $service = $container->get('bazinga_geocoder.provider.acme'); - self::assertInstanceOf(PluginProvider::class, $service); - self::assertInstanceOf(GoogleMaps::class, NSA::getProperty($service, 'provider')); - } - - public function testBundleWithCachedProvider(): 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/cache.yml'); - }]); - - $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(CachePlugin::class, $plugins[0]); - } - - public function testCacheLifetimeCanBeNull(): 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/cache_without_lifetime.yml'); - }]); - - $container = self::getContainer(); - - self::assertTrue($container->has('bazinga_geocoder.provider.acme')); - - /** @var PluginProvider $service */ - $service = $container->get('bazinga_geocoder.provider.acme'); - self::assertInstanceOf(PluginProvider::class, $service); - - $plugins = NSA::getProperty($service, 'plugins'); - self::assertCount(1, $plugins); - - $cachePlugin = array_shift($plugins); - self::assertInstanceOf(CachePlugin::class, $cachePlugin); - - $cacheLifeTime = NSA::getProperty($cachePlugin, 'lifetime'); - self::assertNull($cacheLifeTime); - } - - public function testBundleWithPluginsYml(): 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.yml'); - }]); - - $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::assertCount(3, $plugins); - self::assertInstanceOf(LoggerPlugin::class, $plugins[0]); - } - - public function testBundleHasRegisteredDumpers(): 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'); - } - }]); - - $container = self::getContainer(); - - self::assertTrue($container->has(GeoArray::class)); - self::assertTrue($container->has(GeoJson::class)); - self::assertTrue($container->has(Gpx::class)); - self::assertTrue($container->has(Kml::class)); - self::assertTrue($container->has(Wkb::class)); - self::assertTrue($container->has(Wkt::class)); - } -} diff --git a/tests/Functional/CustomTestKernel.php b/tests/Functional/CustomTestKernel.php deleted file mode 100644 index 5af8981f..00000000 --- a/tests/Functional/CustomTestKernel.php +++ /dev/null @@ -1,245 +0,0 @@ -shutdown(); - $this->warmupDir = $warmupDir; - $this->boot(); - } - - /* - * Needed, otherwise the used cache is different on each kernel boot, which is a big issue in PluginInteractionTest - */ - public function getCacheDir(): string - { - return realpath(sys_get_temp_dir()).'/NyholmBundleTest/cachePluginInteractionTest'; - } - - public function getShareDir(): ?string - { - return $this->getCacheDir(); - } - - /** - * Returns the kernel parameters. - */ - protected function getKernelParameters(): array - { - $bundles = []; - $bundlesMetadata = []; - - foreach ($this->bundles as $name => $bundle) { - $bundles[$name] = \get_class($bundle); - $bundlesMetadata[$name] = [ - 'path' => $bundle->getPath(), - 'namespace' => $bundle->getNamespace(), - ]; - } - - return [ - 'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(), - 'kernel.environment' => $this->environment, - 'kernel.runtime_environment' => '%env(default:kernel.environment:APP_RUNTIME_ENV)%', - 'kernel.runtime_mode' => '%env(query_string:default:container.runtime_mode:APP_RUNTIME_MODE)%', - 'kernel.runtime_mode.web' => '%env(bool:default::key:web:default:kernel.runtime_mode:)%', - 'kernel.runtime_mode.cli' => '%env(not:default:kernel.runtime_mode.web:)%', - 'kernel.runtime_mode.worker' => '%env(bool:default::key:worker:default:kernel.runtime_mode:)%', - 'kernel.debug' => $this->debug, - 'kernel.build_dir' => realpath($buildDir = $this->warmupDir ?: $this->getBuildDir()) ?: $buildDir, - 'kernel.cache_dir' => realpath($cacheDir = ($this->getCacheDir() === $this->getBuildDir() ? ($this->warmupDir ?: $this->getCacheDir()) : $this->getCacheDir())) ?: $cacheDir, - 'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(), - 'kernel.bundles' => $bundles, - 'kernel.bundles_metadata' => $bundlesMetadata, - 'kernel.charset' => $this->getCharset(), - 'kernel.container_class' => $this->getContainerClass(), - ] + (null !== ($dir = $this->getShareDir()) ? ['kernel.share_dir' => realpath($dir) ?: $dir] : []); - } - - /** - * @internal - */ - public function setAnnotatedClassCache(array $annotatedClasses): void - { - file_put_contents(($this->warmupDir ?: $this->getBuildDir()).'/annotations.map', sprintf('getDefinition('http_client') - ->setPublic(true); - } - - protected function build(ContainerBuilder $container): void - { - parent::build($container); - - $container->addCompilerPass($this); - } - - /** - * Initializes the service container. - * - * The built version of the service container is used when fresh, otherwise the - * container is built. - */ - protected function initializeContainer(): void - { - $class = $this->getContainerClass(); - $buildDir = $this->warmupDir ?: $this->getBuildDir(); - $cache = new ConfigCache($buildDir.'/'.$class.'.php', $this->debug); - $cachePath = $cache->getPath(); - - // Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors - $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); - - try { - if (false && \is_object($this->container = include $cachePath) - && (!$this->debug || (self::$freshCache[$cachePath] ?? $cache->isFresh())) - ) { - self::$freshCache[$cachePath] = true; - $this->container->set('kernel', $this); - error_reporting($errorLevel); - - return; - } - } catch (\Throwable $e) { - } - - try { - is_dir($buildDir) || mkdir($buildDir, 0777, true); - - if ($lock = fopen($cachePath.'.lock', 'w')) { - if (!flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock) && !flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) { - fclose($lock); - $lock = null; - } else { - $this->container = null; - } - } - } catch (\Throwable $e) { - } finally { - error_reporting($errorLevel); - } - - if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) { - $collectedLogs = []; - $previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) { - if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type) { - return $previousHandler ? $previousHandler($type, $message, $file, $line) : false; - } - - if (isset($collectedLogs[$message])) { - ++$collectedLogs[$message]['count']; - - return null; - } - - $backtrace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 5); - // Clean the trace by removing first frames added by the error handler itself. - for ($i = 0; isset($backtrace[$i]); ++$i) { - if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) { - $backtrace = \array_slice($backtrace, 1 + $i); - break; - } - } - for ($i = 0; isset($backtrace[$i]); ++$i) { - if (!isset($backtrace[$i]['file'], $backtrace[$i]['line'], $backtrace[$i]['function'])) { - continue; - } - if (!isset($backtrace[$i]['class']) && 'trigger_deprecation' === $backtrace[$i]['function']) { - $file = $backtrace[$i]['file']; - $line = $backtrace[$i]['line']; - $backtrace = \array_slice($backtrace, 1 + $i); - break; - } - } - - // Remove frames added by DebugClassLoader. - for ($i = \count($backtrace) - 2; 0 < $i; --$i) { - if ($backtrace[$i]['class'] ?? null === DebugClassLoader::class) { - $backtrace = [$backtrace[$i + 1]]; - break; - } - } - - $collectedLogs[$message] = [ - 'type' => $type, - 'message' => $message, - 'file' => $file, - 'line' => $line, - 'trace' => [$backtrace[0]], - 'count' => 1, - ]; - - return null; - }); - } - - try { - $container = null; - $container = $this->buildContainer(); - $container->compile(); - } finally { - if ($collectDeprecations) { - restore_error_handler(); - - @file_put_contents($buildDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs))); - @file_put_contents($buildDir.'/'.$class.'Compiler.log', null !== $container ? implode("\n", $container->getCompiler()->getLog()) : ''); - } - } - - $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); - - if ($lock) { - flock($lock, \LOCK_UN); - fclose($lock); - } - - $this->container = require $cachePath; - $this->container->set('kernel', $this); - - $preload = $this instanceof WarmableInterface ? (array) $this->warmUp($this->container->getParameter('kernel.cache_dir')) : []; - - if ($this->container->has('cache_warmer')) { - $preload = array_merge($preload, (array) $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir'))); - } - - if ($preload && method_exists(Preloader::class, 'append') && file_exists($preloadFile = $buildDir.'/'.$class.'.preload.php')) { - Preloader::append($preloadFile, $preload); - } - } -} diff --git a/tests/Functional/Fixtures/Entity/DummyWithEmptyProperty.php b/tests/Functional/Fixtures/Entity/DummyWithEmptyProperty.php deleted file mode 100644 index aa036c19..00000000 --- a/tests/Functional/Fixtures/Entity/DummyWithEmptyProperty.php +++ /dev/null @@ -1,45 +0,0 @@ -_address = $address; - } - - #[Address] - public function getAddress() - { - return $this->_address; - } - - public function getLatitude() - { - return $this->latitude; - } - - public function setLatitude($latitude): void - { - $this->latitude = $latitude; - } - - public function getLongitude() - { - return $this->longitude; - } - - public function setLongitude($longitude): void - { - $this->longitude = $longitude; - } -} diff --git a/tests/Functional/Fixtures/Entity/DummyWithInvalidGetter.php b/tests/Functional/Fixtures/Entity/DummyWithInvalidGetter.php deleted file mode 100644 index 1739bf7e..00000000 --- a/tests/Functional/Fixtures/Entity/DummyWithInvalidGetter.php +++ /dev/null @@ -1,75 +0,0 @@ -_address = $address; - } - - #[Address] - public function getAddress($requiredParameter) - { - return $this->_address; - } - - public function getLatitude() - { - return $this->latitude; - } - - public function setLatitude($latitude): void - { - $this->latitude = $latitude; - } - - public function getLongitude() - { - return $this->longitude; - } - - public function setLongitude($longitude): void - { - $this->longitude = $longitude; - } -} diff --git a/tests/Functional/Fixtures/Entity/DummyWithProperty.php b/tests/Functional/Fixtures/Entity/DummyWithProperty.php deleted file mode 100644 index f58b0293..00000000 --- a/tests/Functional/Fixtures/Entity/DummyWithProperty.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -final class GeocoderListenerTest extends KernelTestCase -{ - protected function tearDown(): void - { - $em = self::getContainer()->get('doctrine.orm.entity_manager'); - - $tool = new SchemaTool($em); - $tool->dropSchema($em->getMetadataFactory()->getAllMetadata()); - } - - protected static function getKernelClass(): string - { - return TestKernel::class; - } - - protected static function createKernel(array $options = []): KernelInterface - { - /** - * @var TestKernel $kernel - */ - $kernel = parent::createKernel($options); - $kernel->addTestBundle(DoctrineBundle::class); - $kernel->addTestBundle(BazingaGeocoderBundle::class); - $kernel->addTestCompilerPass(new class implements CompilerPassInterface { - public function process(ContainerBuilder $container): void - { - $container - ->getDefinition('http_client') - ->setPublic(true); - } - }); - if (defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) { - $kernel->addTestConfig(static function (ContainerBuilder $container) { - $container->prependExtensionConfig('doctrine', [ - 'orm' => [ - 'report_fields_where_declared' => true, - ], - ]); - - if (method_exists(Configuration::class, 'setLazyGhostObjectEnabled') && Kernel::VERSION_ID >= 60100) { - $container->prependExtensionConfig('doctrine', [ - 'orm' => [ - 'enable_lazy_ghost_objects' => true, - ], - ]); - } - - if (class_exists(EntityValueResolver::class)) { - $container->prependExtensionConfig('doctrine', [ - 'orm' => [ - 'controller_resolver' => [ - 'auto_mapping' => false, - ], - ], - ]); - } - }); - } - $kernel->handleOptions($options); - - return $kernel; - } - - public function testPersistForProperty(): 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/listener.yml'); - $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); - }]); - - $container = self::getContainer(); - $container->set('http_client', self::createHttpClientForBerlinQuery()); - - $dummy = new DummyWithProperty(); - $dummy->address = 'Berlin, Germany'; - - $em = $container->get('doctrine.orm.entity_manager'); - - $tool = new SchemaTool($em); - $tool->createSchema($em->getMetadataFactory()->getAllMetadata()); - - $em->persist($dummy); - $em->flush(); - - self::assertNotNull($dummy->latitude); - self::assertNotNull($dummy->longitude); - - $clone = clone $dummy; - $dummy->address = 'Paris, France'; - - $em->persist($dummy); - $em->flush(); - - self::assertNotEquals($clone->latitude, $dummy->latitude); - self::assertNotEquals($clone->longitude, $dummy->longitude); - } - - public function testPersistForGetter(): 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/listener.yml'); - $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); - }]); - - $container = self::getContainer(); - $container->set('http_client', self::createHttpClientForBerlinQuery()); - - $em = $container->get('doctrine.orm.entity_manager'); - - $tool = new SchemaTool($em); - $tool->createSchema($em->getMetadataFactory()->getAllMetadata()); - - $dummy = new DummyWithGetter(); - $dummy->setAddress('Berlin, Germany'); - - $em->persist($dummy); - $em->flush(); - - self::assertNotNull($dummy->getLatitude()); - self::assertNotNull($dummy->getLongitude()); - - $clone = clone $dummy; - $dummy->setAddress('Paris, France'); - - $em->persist($dummy); - $em->flush(); - - self::assertNotEquals($clone->getLatitude(), $dummy->getLatitude()); - self::assertNotEquals($clone->getLongitude(), $dummy->getLongitude()); - } - - public function testPersistForInvalidGetter(): 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/listener.yml'); - $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); - }]); - - $container = self::getContainer(); - $container->set('http_client', new MockHttpClient(static function () { - self::fail('I shall not be called'); - })); - - $em = $container->get('doctrine.orm.entity_manager'); - - $tool = new SchemaTool($em); - $tool->createSchema($em->getMetadataFactory()->getAllMetadata()); - - $dummy = new DummyWithInvalidGetter(); - $dummy->setAddress('Berlin, Germany'); - - $em->persist($dummy); - - $this->expectException(\Exception::class); - - $em->flush(); - } - - public function testPersistForEmptyProperty(): 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/listener.yml'); - $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); - }]); - - $container = self::getContainer(); - $container->set('http_client', new MockHttpClient(static function () { - self::fail('I shall not be called'); - })); - - $em = $container->get('doctrine.orm.entity_manager'); - - $tool = new SchemaTool($em); - $tool->createSchema($em->getMetadataFactory()->getAllMetadata()); - - $dummy = new DummyWithEmptyProperty(); - $dummy->address = ''; - - $em->persist($dummy); - $em->flush(); - - self::assertNull($dummy->latitude); - self::assertNull($dummy->longitude); - } - - public function testDoesNotGeocodeIfAddressNotChanged(): 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/listener.yml'); - $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); - }]); - - $httpRequests = 0; - - $container = self::getContainer(); - $container->set('http_client', self::createHttpClientForFrankfurtQuery($httpRequests)); - - $em = $container->get('doctrine.orm.entity_manager'); - - $tool = new SchemaTool($em); - $tool->createSchema($em->getMetadataFactory()->getAllMetadata()); - - $dummy = new DummyWithProperty(); - $dummy->address = 'Frankfurt, Germany'; - - $em->persist($dummy); - $em->flush(); - - $dummy->latitude = 0; - $dummy->longitude = 0; - - $em->flush(); - - self::assertSame('Frankfurt, Germany', $dummy->address); - self::assertSame(0, $dummy->latitude); - self::assertSame(0, $dummy->longitude); - self::assertSame(1, $httpRequests); - } - - private static function createHttpClientForBerlinQuery(): MockHttpClient - { - return new MockHttpClient(static function (string $method, string $url): MockResponse { - if ('https://nominatim.openstreetmap.org/search?format=jsonv2&q=Berlin%2C%20Germany&addressdetails=1&extratags=1&limit=5' === $url) { - self::assertSame('GET', $method); - - return new MockResponse('[{"place_id":159647018,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"relation","osm_id":62422,"lat":"52.5170365","lon":"13.3888599","category":"boundary","type":"administrative","place_rank":8,"importance":0.7875390282491362,"addresstype":"city","name":"Berlin","display_name":"Berlin, Deutschland","address":{"city":"Berlin","ISO3166-2-lvl4":"DE-BE","country":"Deutschland","country_code":"de"},"extratags":{"ele": "35", "email": "info@berlin.de", "place": "city", "capital": "yes", "website": "http://www.berlin.de", "de:place": "city", "ref:nuts": "DE3;DE30;DE300", "wikidata": "Q64", "wikipedia": "de:Berlin", "population": "3769962", "ref:LOCODE": "DEBER", "ref:nuts:1": "DE3", "ref:nuts:2": "DE30", "ref:nuts:3": "DE300", "state_code": "BE", "name:prefix": "Land und Kreisfreie Stadt", "linked_place": "city", "official_status": "Land", "contact:facebook": "http://www.facebook.com/Berlin", "name:prefix:city": "Kreisfreie Stadt", "openGeoDB:loc_id": "14356", "capital_ISO3166-1": "yes", "name:prefix:state": "Land", "source:population": "https://download.statistik-berlin-brandenburg.de/fa93e3bd19a2e885/a5ecfb2fff6a/SB_A01-05-00_2020h02_BE.pdf", "license_plate_code": "B", "official_status:de": "Land", "official_status:en": "State", "official_status:ru": "земля", "geographical_region": "Barnim;Berliner Urstromtal;Teltow;Nauener Platte", "blind:description:de": "Auf www.berlinfuerblinde.de gibt es einen kostenlosen Audioguide und weitere Informationen.", "de:regionalschluessel": "110000000000", "openGeoDB:postal_codes": "10178,10115,10117,10119,10179,10243,10245,10247,10249,10315,10317,10318,10319,10365,10367,10369,10405,10407,10409,10435,10437,10439,10551,10553,10555,10557,10559,10585,10587,10589,10623,10625,10627,10629,10707,10709,10711,10713,10715,10717,10719,10777,10", "report_problems:website": "https://ordnungsamt.berlin.de/", "TMC:cid_58:tabcd_1:Class": "Area", "openGeoDB:license_plate_code": "B", "TMC:cid_58:tabcd_1:LCLversion": "12.0", "openGeoDB:telephone_area_code": "030", "TMC:cid_58:tabcd_1:LocationCode": "266", "de:amtlicher_gemeindeschluessel": "11000000", "openGeoDB:community_identification_number": "11000000"},"boundingbox":["52.3382448","52.6755087","13.0883450","13.7611609"]}]', ['response_headers' => ['content-type' => 'application/json']]); - } - - if ('https://nominatim.openstreetmap.org/search?format=jsonv2&q=Paris%2C%20France&addressdetails=1&extratags=1&limit=5' === $url) { - self::assertSame('GET', $method); - - return new MockResponse('[{"place_id":115350921,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"relation","osm_id":7444,"lat":"48.8588897","lon":"2.3200410217200766","category":"boundary","type":"administrative","place_rank":15,"importance":0.8317101715588673,"addresstype":"suburb","name":"Paris","display_name":"Paris, Île-de-France, France métropolitaine, France","address":{"suburb":"Paris","city_district":"Paris","city":"Paris","ISO3166-2-lvl6":"FR-75","state":"Île-de-France","ISO3166-2-lvl4":"FR-IDF","region":"France métropolitaine","country":"France","country_code":"fr"},"extratags":{"capital": "yes", "wikidata": "Q90", "ref:INSEE": "75056", "wikipedia": "fr:Paris", "population": "2187526", "ref:FR:MGP": "T1", "source:population": "INSEE 2020"},"boundingbox":["48.8155755","48.9021560","2.2241220","2.4697602"]},{"place_id":114827617,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"relation","osm_id":71525,"lat":"48.8534951","lon":"2.3483915","category":"boundary","type":"administrative","place_rank":12,"importance":0.8317101715588673,"addresstype":"city","name":"Paris","display_name":"Paris, Île-de-France, France métropolitaine, France","address":{"city":"Paris","ISO3166-2-lvl6":"FR-75","state":"Île-de-France","ISO3166-2-lvl4":"FR-IDF","region":"France métropolitaine","country":"France","country_code":"fr"},"extratags":{"rank": "0", "capital": "yes", "ref:nuts": "FR101", "wikidata": "Q90", "ref:INSEE": "75", "wikipedia": "fr:Paris", "is_capital": "country", "population": "2165423", "ref:nuts:3": "FR101", "linked_place": "city", "source:name:oc": "ieo-bdtopoc", "contact:website": "http://www.paris.fr", "population:date": "2019", "capital_ISO3166-1": "yes", "source:population": "INSEE 2022"},"boundingbox":["48.8155755","48.9021560","2.2241220","2.4697602"]},{"place_id":114994164,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"relation","osm_id":1641193,"lat":"48.8588897","lon":"2.3200410217200766","category":"boundary","type":"administrative","place_rank":14,"importance":0.4283953917728152,"addresstype":"city_district","name":"Paris","display_name":"Paris, Île-de-France, France métropolitaine, France","address":{"city_district":"Paris","city":"Paris","ISO3166-2-lvl6":"FR-75","state":"Île-de-France","ISO3166-2-lvl4":"FR-IDF","region":"France métropolitaine","country":"France","country_code":"fr"},"extratags":{"wikidata": "Q2863958", "ref:INSEE": "751", "wikipedia": "fr:Arrondissement de Paris"},"boundingbox":["48.8155755","48.9021560","2.2241220","2.4697602"]}]', ['response_headers' => ['content-type' => 'application/json']]); - } - - self::fail(sprintf('Unexpected http call "%s %s".', $method, $url)); - }); - } - - private static function createHttpClientForFrankfurtQuery(int &$requestCount): MockHttpClient - { - return new MockHttpClient(static function (string $method, string $url) use (&$requestCount): MockResponse { - if ('https://nominatim.openstreetmap.org/search?format=jsonv2&q=Frankfurt%2C%20Germany&addressdetails=1&extratags=1&limit=5' === $url) { - self::assertSame('GET', $method); - - ++$requestCount; - - return new MockResponse('[{"place_id":152571305,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"relation","osm_id":62400,"lat":"50.1106444","lon":"8.6820917","category":"boundary","type":"administrative","place_rank":12,"importance":0.6941325622496303,"addresstype":"city","name":"Frankfurt am Main","display_name":"Frankfurt am Main, Hessen, Deutschland","address":{"city":"Frankfurt am Main","state":"Hessen","ISO3166-2-lvl4":"DE-HE","country":"Deutschland","country_code":"de"},"extratags":{"ele": "112", "flag": "File:Flag of Frankfurt am Main.svg", "logo": "File:Frankfurt am Main logo.svg", "de:place": "city", "nickname": "Europastadt", "wikidata": "Q1794", "wikipedia": "de:Frankfurt am Main", "population": "701350", "ref:LOCODE": "DEFRA", "ref:nuts:3": "DE712", "border_type": "county", "name:prefix": "Stadt", "nickname:de": "Europastadt", "nickname:la": "Urbem Europaeam", "nickname:nl": "Bankfurt", "coat_of_arms": "File:Wappen Frankfurt am Main.svg", "linked_place": "city", "wikimedia_commons": "Category:Frankfurt am Main", "license_plate_code": "F", "de:regionalschluessel": "064120000000", "TMC:cid_58:tabcd_1:Class": "Area", "TMC:cid_58:tabcd_1:LCLversion": "9.00", "TMC:cid_58:tabcd_1:LocationCode": "414", "de:amtlicher_gemeindeschluessel": "06412000"},"boundingbox":["50.0153529","50.2271424","8.4727605","8.8004049"]},{"place_id":160849350,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"relation","osm_id":62523,"lat":"52.3412273","lon":"14.549452","category":"boundary","type":"administrative","place_rank":12,"importance":0.5626903004005709,"addresstype":"city","name":"Frankfurt (Oder)","display_name":"Frankfurt (Oder), Brandenburg, Deutschland","address":{"city":"Frankfurt (Oder)","state":"Brandenburg","ISO3166-2-lvl4":"DE-BB","country":"Deutschland","country_code":"de"},"extratags":{"ele": "28", "place": "city", "website": "https://www.frankfurt-oder.de/", "de:place": "city", "wikidata": "Q4024", "wikipedia": "de:Frankfurt (Oder)", "population": "61969", "ref:LOCODE": "DEFFO", "ref:nuts:3": "DE403", "name:prefix": "Kreisfreie Stadt", "linked_place": "town", "license_plate_code": "FF", "telephone_area_code": "0335", "de:regionalschluessel": "120530000000", "TMC:cid_58:tabcd_1:Class": "Area", "TMC:cid_58:tabcd_1:LCLversion": "8.00", "TMC:cid_58:tabcd_1:LocationCode": "415", "de:amtlicher_gemeindeschluessel": "12053000"},"boundingbox":["52.2528709","52.3980721","14.3948254","14.6013644"]}]', ['response_headers' => ['content-type' => 'application/json']]); - } - - self::fail(sprintf('Unexpected http call "%s %s".', $method, $url)); - }); - } -} diff --git a/tests/Functional/Helper/CacheHelper.php b/tests/Functional/Helper/CacheHelper.php deleted file mode 100644 index 67df280a..00000000 --- a/tests/Functional/Helper/CacheHelper.php +++ /dev/null @@ -1,37 +0,0 @@ -= 80000) { - /** - * @internal - * - * @author Tobias Nyholm - */ - class CacheHelper implements CacheInterface - { - use CacheHelperV8; - } -} else { - /** - * @internal - * - * @author Tobias Nyholm - */ - class CacheHelper implements CacheInterface - { - use CacheHelperV7; - } -} diff --git a/tests/Functional/Helper/CacheHelperV7.php b/tests/Functional/Helper/CacheHelperV7.php deleted file mode 100644 index fb50fb0d..00000000 --- a/tests/Functional/Helper/CacheHelperV7.php +++ /dev/null @@ -1,84 +0,0 @@ - - */ -trait CacheHelperV7 -{ - /** - * @return mixed - */ - public function get($key, $default = null) - { - } - - /** - * @return bool - */ - public function set($key, $value, $ttl = null) - { - return true; - } - - /** - * @return bool - */ - public function delete($key) - { - return true; - } - - /** - * @return bool - */ - public function clear() - { - return true; - } - - /** - * @return iterable - */ - public function getMultiple($keys, $default = null) - { - return []; - } - - /** - * @return bool - */ - public function setMultiple($values, $ttl = null) - { - return true; - } - - /** - * @return bool - */ - public function deleteMultiple($keys) - { - return true; - } - - /** - * @return bool - */ - public function has($key) - { - return false; - } -} diff --git a/tests/Functional/Helper/CacheHelperV8.php b/tests/Functional/Helper/CacheHelperV8.php deleted file mode 100644 index 939ef94a..00000000 --- a/tests/Functional/Helper/CacheHelperV8.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ -trait CacheHelperV8 -{ - public function get(string $key, mixed $default = null): mixed - { - } - - public function set(string $key, mixed $value, int|\DateInterval|null $ttl = null): bool - { - return true; - } - - public function delete(string $key): bool - { - return true; - } - - public function clear(): bool - { - return true; - } - - public function getMultiple(iterable $keys, mixed $default = null): iterable - { - return []; - } - - public function setMultiple(iterable $values, int|\DateInterval|null $ttl = null): bool - { - return true; - } - - public function deleteMultiple(iterable $keys): bool - { - return true; - } - - public function has(string $key): bool - { - return false; - } -} diff --git a/tests/Functional/PluginInteractionTest.php b/tests/Functional/PluginInteractionTest.php deleted file mode 100644 index 2a15b6bf..00000000 --- a/tests/Functional/PluginInteractionTest.php +++ /dev/null @@ -1,109 +0,0 @@ -addTestBundle(BazingaGeocoderBundle::class); - $kernel->addTestCompilerPass(new class implements CompilerPassInterface { - public function process(ContainerBuilder $container): void - { - $container - ->getDefinition('http_client') - ->setPublic(true); - } - }); - $kernel->handleOptions($options); - - return $kernel; - } - - public function testCachePluginUsesIpFromFakeIpPlugin(): void - { - $kernel = self::bootKernel(['config' => static function (TestKernel $kernel) { - $kernel->setClearCacheAfterShutdown(false); - $kernel->addTestConfig(__DIR__.'/config/framework.yml'); - - if ($kernel::VERSION_ID >= 60000) { - $kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml'); - } - - $kernel->addTestConfig(__DIR__.'/config/cache_symfony.yml'); - $kernel->addTestConfig(__DIR__.'/config/fakeip_with_cache_cn.yml'); - }]); - $kernel->setClearCacheAfterShutdown(false); - $container = self::getContainer(); - - $container->set('http_client', new MockHttpClient(static function (string $method, string $url): MockResponse { - self::assertSame('GET', $method); - self::assertSame('https://freegeoip.app/json/123.123.123.128', $url); - - return new MockResponse('{"ip":"123.123.123.128","country_code":"CN","country_name":"China","region_code":"CN-BJ","region_name":"Beijing","city":"Beijing","zip_code":"100006","time_zone":"Asia\/Shanghai","latitude":39.907501220703125,"longitude":116.39710235595703,"metro_code":0}', ['response_headers' => ['content-type' => 'application-json']]); - })); - - $geoPluginGeocoder = $container->get('bazinga_geocoder.provider.geoPlugin'); - $result = $geoPluginGeocoder->geocodeQuery(GeocodeQuery::create('::1')); - $country = $result->first()->getCountry()->getCode(); - self::assertEquals('CN', $country); - - $kernel = self::bootKernel(['config' => static function (TestKernel $kernel) { - $kernel->setClearCacheAfterShutdown(false); - $kernel->addTestConfig(__DIR__.'/config/framework.yml'); - - if ($kernel::VERSION_ID >= 60000) { - $kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml'); - } - - $kernel->addTestConfig(__DIR__.'/config/cache_symfony.yml'); - $kernel->addTestConfig(__DIR__.'/config/fakeip_with_cache_fr.yml'); - }]); - $kernel->setClearCacheAfterShutdown(false); - $container = self::getContainer(); - - $container->set('http_client', new MockHttpClient(static function (string $method, string $url): MockResponse { - self::assertSame('GET', $method); - self::assertSame('https://freegeoip.app/json/87.98.128.10', $url); - - return new MockResponse('{"ip":"87.98.128.10","country_code":"FR","country_name":"France","region_code":null,"region_name":"Nord","city":"Roubaix","zip_code":"59100","time_zone":"Europe\/Paris","latitude":50.69371032714844,"longitude":3.174438953399658,"metro_code":0}', ['response_headers' => ['content-type' => 'application-json']]); - })); - - $geoPluginGeocoder = $container->get('bazinga_geocoder.provider.geoPlugin'); - $result = $geoPluginGeocoder->geocodeQuery(GeocodeQuery::create('::1')); - $country = $result->first()->getCountry()->getCode(); - self::assertEquals('FR', $country); - } -} diff --git a/tests/Functional/ProviderFactoryTest.php b/tests/Functional/ProviderFactoryTest.php deleted file mode 100644 index 64489d66..00000000 --- a/tests/Functional/ProviderFactoryTest.php +++ /dev/null @@ -1,128 +0,0 @@ -addTestBundle(BazingaGeocoderBundle::class); - $kernel->handleOptions($options); - - return $kernel; - } - - /** - * @param class-string $class - * @param list $serviceNames - * - * @dataProvider getProviders - */ - public function testProviderConfiguration(string $class, array $serviceNames): void - { - self::bootKernel(['config' => static function (TestKernel $kernel) use ($class) { - $kernel->addTestConfig(__DIR__.'/config/framework.yml'); - - if ($kernel::VERSION_ID >= 60000) { - $kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml'); - } - - $kernel->addTestConfig(__DIR__.'/config/provider/'.strtolower(substr($class, strrpos($class, '\\') + 1)).'.yml'); - }]); - - $container = self::getContainer(); - - foreach ($serviceNames as $name) { - self::assertTrue($container->has('bazinga_geocoder.provider.'.$name)); - $service = $container->get('bazinga_geocoder.provider.'.$name); - self::assertInstanceOf($class, NSA::getProperty($service, 'provider')); - } - } - - /** - * @return iterable}> - */ - public function getProviders(): iterable - { - yield [AlgoliaPlaces::class, ['empty', 'acme']]; - yield [ArcGISOnline::class, ['empty', 'acme']]; - yield [BingMaps::class, ['acme']]; - yield [Chain::class, ['acme']]; - yield [FreeGeoIp::class, ['empty', 'acme']]; - // yield [Geoip::class, ['empty']]; - yield [GeoIP2::class, ['acme']]; - yield [Geonames::class, ['acme']]; - yield [GeoPlugin::class, ['empty']]; - yield [GoogleMaps::class, ['empty']]; - yield [GoogleMapsPlaces::class, ['acme']]; - yield [Here::class, ['acme']]; - yield [HostIp::class, ['empty']]; - yield [IpInfo::class, ['acme']]; - yield [IpInfoDb::class, ['empty', 'acme']]; - yield [Ipstack::class, ['acme']]; - yield [LocationIQ::class, ['acme']]; - yield [Mapbox::class, ['acme']]; - yield [MapQuest::class, ['acme']]; - yield [MaxMind::class, ['acme']]; - yield [MaxMindBinary::class, ['acme']]; - yield [Nominatim::class, ['empty', 'acme']]; - yield [OpenCage::class, ['acme']]; - yield [PickPoint::class, ['acme']]; - yield [TomTom::class, ['acme']]; - yield [Yandex::class, ['empty', 'acme']]; - } -} diff --git a/tests/Functional/config/cache.yml b/tests/Functional/config/cache.yml deleted file mode 100644 index e291985c..00000000 --- a/tests/Functional/config/cache.yml +++ /dev/null @@ -1,13 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - cache_lifetime: 10 - cache_precision: 4 - cache: acme.cache - -services: - acme.cache: - class: Bazinga\GeocoderBundle\Tests\Functional\Helper\CacheHelper diff --git a/tests/Functional/config/cache_symfony.yml b/tests/Functional/config/cache_symfony.yml deleted file mode 100644 index 419c11d6..00000000 --- a/tests/Functional/config/cache_symfony.yml +++ /dev/null @@ -1,12 +0,0 @@ -framework: - cache: - app: cache.adapter.filesystem - system: cache.adapter.system - pools: - app.cache.geoPlugin: - adapter: cache.app - default_lifetime: 600 -services: - app.simple_cache: - class: Symfony\Component\Cache\Psr16Cache - arguments: ['@app.cache.geoPlugin'] \ No newline at end of file diff --git a/tests/Functional/config/cache_without_lifetime.yml b/tests/Functional/config/cache_without_lifetime.yml deleted file mode 100644 index 1c11bb00..00000000 --- a/tests/Functional/config/cache_without_lifetime.yml +++ /dev/null @@ -1,12 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - cache_precision: 4 - cache: acme.cache - -services: - acme.cache: - class: Bazinga\GeocoderBundle\Tests\Functional\Helper\CacheHelper diff --git a/tests/Functional/config/fakeip_with_cache_cn.yml b/tests/Functional/config/fakeip_with_cache_cn.yml deleted file mode 100644 index 4c88e956..00000000 --- a/tests/Functional/config/fakeip_with_cache_cn.yml +++ /dev/null @@ -1,14 +0,0 @@ -# See the docs at https://github.com/geocoder-php/BazingaGeocoderBundle -bazinga_geocoder: - # The local IP (127.0.0.1) will be replaced by the fake_ip - # see https://github.com/geocoder-php/BazingaGeocoderBundle/blob/5.0.0/Resources/doc/index.md#fake-local-ip - fake_ip: - local_ip: ::1 - ip: 123.123.123.128 - # this ip is in china - providers: - geoPlugin: - factory: Bazinga\GeocoderBundle\ProviderFactory\FreeGeoIpFactory - cache: 'app.simple_cache' - cache_lifetime: 42 - cache_precision: ~ diff --git a/tests/Functional/config/fakeip_with_cache_fr.yml b/tests/Functional/config/fakeip_with_cache_fr.yml deleted file mode 100644 index 4aa35993..00000000 --- a/tests/Functional/config/fakeip_with_cache_fr.yml +++ /dev/null @@ -1,14 +0,0 @@ -# See the docs at https://github.com/geocoder-php/BazingaGeocoderBundle -bazinga_geocoder: - # The local IP (127.0.0.1) will be replaced by the fake_ip - # see https://github.com/geocoder-php/BazingaGeocoderBundle/blob/5.0.0/Resources/doc/index.md#fake-local-ip - fake_ip: - local_ip: ::1 - ip: 87.98.128.10 - # this ip is in france - providers: - geoPlugin: - factory: Bazinga\GeocoderBundle\ProviderFactory\FreeGeoIpFactory - cache: 'app.simple_cache' - cache_lifetime: 42 - cache_precision: ~ diff --git a/tests/Functional/config/framework.yml b/tests/Functional/config/framework.yml deleted file mode 100644 index 97d232e1..00000000 --- a/tests/Functional/config/framework.yml +++ /dev/null @@ -1,12 +0,0 @@ -framework: - http_method_override: false - secret: 6825c711ef47cfc1530d322b62adac3e2c43844c - session: - cookie_secure: auto - cookie_samesite: lax - handler_id: null - storage_factory_id: session.storage.factory.native - router: - utf8: true - http_client: - enabled: true diff --git a/tests/Functional/config/framework_sf6.yml b/tests/Functional/config/framework_sf6.yml deleted file mode 100644 index 25f5a5b0..00000000 --- a/tests/Functional/config/framework_sf6.yml +++ /dev/null @@ -1,5 +0,0 @@ -framework: - annotations: false - handle_all_throwables: true - php_errors: - log: true diff --git a/tests/Functional/config/listener.yml b/tests/Functional/config/listener.yml deleted file mode 100644 index 500d501a..00000000 --- a/tests/Functional/config/listener.yml +++ /dev/null @@ -1,20 +0,0 @@ -doctrine: - dbal: - default_connection: default - connections: - default: - driver: pdo_sqlite - path: '%kernel.cache_dir%/test.sqlite' - orm: - auto_generate_proxy_classes: true - validate_xml_mapping: true - report_fields_where_declared: true - naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware - auto_mapping: false - -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory diff --git a/tests/Functional/config/listener_php7.yml b/tests/Functional/config/listener_php7.yml deleted file mode 100644 index d13fa8ca..00000000 --- a/tests/Functional/config/listener_php7.yml +++ /dev/null @@ -1,33 +0,0 @@ -doctrine: - orm: - mappings: - App: - is_bundle: false - type: annotation - dir: '%kernel.project_dir%/tests/Functional/Fixtures/Entity' - prefix: 'Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity' - alias: App - -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory - options: - root_url: 'https://nominatim.openstreetmap.org' - user_agent: 'geocoder-php test_suite' - -services: - Bazinga\GeocoderBundle\Mapping\Driver\AnnotationDriver: - class: Bazinga\GeocoderBundle\Mapping\Driver\AnnotationDriver - arguments: - - '@annotations.reader' - - Bazinga\GeocoderBundle\Doctrine\ORM\GeocoderListener: - class: Bazinga\GeocoderBundle\Doctrine\ORM\GeocoderListener - arguments: - - '@bazinga_geocoder.provider.acme' - - '@Bazinga\GeocoderBundle\Mapping\Driver\AnnotationDriver' - tags: - - { name: doctrine.event_listener, event: onFlush } diff --git a/tests/Functional/config/listener_php8.yml b/tests/Functional/config/listener_php8.yml deleted file mode 100644 index 6057f6c6..00000000 --- a/tests/Functional/config/listener_php8.yml +++ /dev/null @@ -1,30 +0,0 @@ -doctrine: - orm: - mappings: - App: - is_bundle: false - type: attribute - dir: '%kernel.project_dir%/tests/Functional/Fixtures/Entity' - prefix: 'Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity' - alias: App - -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory - options: - root_url: 'https://nominatim.openstreetmap.org' - user_agent: 'geocoder-php test_suite' - -services: - Bazinga\GeocoderBundle\Mapping\Driver\AttributeDriver: ~ - - Bazinga\GeocoderBundle\Doctrine\ORM\GeocoderListener: - class: Bazinga\GeocoderBundle\Doctrine\ORM\GeocoderListener - arguments: - - '@bazinga_geocoder.provider.acme' - - '@Bazinga\GeocoderBundle\Mapping\Driver\AttributeDriver' - tags: - - { name: doctrine.event_listener, event: onFlush } diff --git a/tests/Functional/config/provider/algoliaplaces.yml b/tests/Functional/config/provider/algoliaplaces.yml deleted file mode 100644 index e354b6d2..00000000 --- a/tests/Functional/config/provider/algoliaplaces.yml +++ /dev/null @@ -1,11 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - empty: - factory: Bazinga\GeocoderBundle\ProviderFactory\AlgoliaFactory - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\AlgoliaFactory - options: - api_key: 'foo' - app_id: 'bar' diff --git a/tests/Functional/config/provider/arcgisonline.yml b/tests/Functional/config/provider/arcgisonline.yml deleted file mode 100644 index 9dc82140..00000000 --- a/tests/Functional/config/provider/arcgisonline.yml +++ /dev/null @@ -1,10 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - empty: - factory: Bazinga\GeocoderBundle\ProviderFactory\ArcGISOnlineFactory - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\ArcGISOnlineFactory - options: - source_country: 'bar' diff --git a/tests/Functional/config/provider/bingmaps.yml b/tests/Functional/config/provider/bingmaps.yml deleted file mode 100644 index 6a042fe2..00000000 --- a/tests/Functional/config/provider/bingmaps.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\BingMapsFactory - options: - api_key: 'bar' diff --git a/tests/Functional/config/provider/chain.yml b/tests/Functional/config/provider/chain.yml deleted file mode 100644 index f74378ef..00000000 --- a/tests/Functional/config/provider/chain.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\ChainFactory - options: - services: ['foo'] diff --git a/tests/Functional/config/provider/freegeoip.yml b/tests/Functional/config/provider/freegeoip.yml deleted file mode 100644 index 3e2e859f..00000000 --- a/tests/Functional/config/provider/freegeoip.yml +++ /dev/null @@ -1,10 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - empty: - factory: Bazinga\GeocoderBundle\ProviderFactory\FreeGeoIpFactory - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\FreeGeoIpFactory - options: - base_url: 'foo' diff --git a/tests/Functional/config/provider/geoip.yml b/tests/Functional/config/provider/geoip.yml deleted file mode 100644 index 2ede9cd2..00000000 --- a/tests/Functional/config/provider/geoip.yml +++ /dev/null @@ -1,6 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - empty: - factory: Bazinga\GeocoderBundle\ProviderFactory\GeoipFactory diff --git a/tests/Functional/config/provider/geoip2.yml b/tests/Functional/config/provider/geoip2.yml deleted file mode 100644 index 349fc74b..00000000 --- a/tests/Functional/config/provider/geoip2.yml +++ /dev/null @@ -1,11 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GeoIP2Factory - options: - provider: 'webservice' - user_id: 'foo' - license_key: 'bar' - diff --git a/tests/Functional/config/provider/geonames.yml b/tests/Functional/config/provider/geonames.yml deleted file mode 100644 index 28418df2..00000000 --- a/tests/Functional/config/provider/geonames.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GeonamesFactory - options: - username: 'foo' diff --git a/tests/Functional/config/provider/geoplugin.yml b/tests/Functional/config/provider/geoplugin.yml deleted file mode 100644 index 4aa8ff7a..00000000 --- a/tests/Functional/config/provider/geoplugin.yml +++ /dev/null @@ -1,6 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - empty: - factory: Bazinga\GeocoderBundle\ProviderFactory\GeoPluginFactory diff --git a/tests/Functional/config/provider/googlemaps.yml b/tests/Functional/config/provider/googlemaps.yml deleted file mode 100644 index 9a0e5d80..00000000 --- a/tests/Functional/config/provider/googlemaps.yml +++ /dev/null @@ -1,11 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - empty: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory - options: - region: 'foo' - api_key: 'bar' diff --git a/tests/Functional/config/provider/googlemapsplaces.yml b/tests/Functional/config/provider/googlemapsplaces.yml deleted file mode 100644 index 2b83b619..00000000 --- a/tests/Functional/config/provider/googlemapsplaces.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsPlacesFactory - options: - api_key: 'bar' diff --git a/tests/Functional/config/provider/here.yml b/tests/Functional/config/provider/here.yml deleted file mode 100644 index a943e82b..00000000 --- a/tests/Functional/config/provider/here.yml +++ /dev/null @@ -1,9 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\HereFactory - options: - app_id: 'foo' - app_code: 'bar' diff --git a/tests/Functional/config/provider/hostip.yml b/tests/Functional/config/provider/hostip.yml deleted file mode 100644 index 9ccaecb6..00000000 --- a/tests/Functional/config/provider/hostip.yml +++ /dev/null @@ -1,6 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - empty: - factory: Bazinga\GeocoderBundle\ProviderFactory\HostIpFactory diff --git a/tests/Functional/config/provider/ipinfo.yml b/tests/Functional/config/provider/ipinfo.yml deleted file mode 100644 index e8c7c0a8..00000000 --- a/tests/Functional/config/provider/ipinfo.yml +++ /dev/null @@ -1,6 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\IpInfoFactory diff --git a/tests/Functional/config/provider/ipinfodb.yml b/tests/Functional/config/provider/ipinfodb.yml deleted file mode 100644 index aa0de471..00000000 --- a/tests/Functional/config/provider/ipinfodb.yml +++ /dev/null @@ -1,13 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - empty: - factory: Bazinga\GeocoderBundle\ProviderFactory\IpInfoDbFactory - options: - api_key: 'bar' - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\IpInfoDbFactory - options: - precision: 'country' - api_key: 'bar' diff --git a/tests/Functional/config/provider/ipstack.yml b/tests/Functional/config/provider/ipstack.yml deleted file mode 100644 index 9835e5ab..00000000 --- a/tests/Functional/config/provider/ipstack.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\IpstackFactory - options: - api_key: 'foo' diff --git a/tests/Functional/config/provider/locationiq.yml b/tests/Functional/config/provider/locationiq.yml deleted file mode 100644 index 6fbfb367..00000000 --- a/tests/Functional/config/provider/locationiq.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\LocationIQFactory - options: - api_key: 'foo' diff --git a/tests/Functional/config/provider/mapbox.yml b/tests/Functional/config/provider/mapbox.yml deleted file mode 100644 index 99980699..00000000 --- a/tests/Functional/config/provider/mapbox.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\MapboxFactory - options: - api_key: 'bar' diff --git a/tests/Functional/config/provider/mapquest.yml b/tests/Functional/config/provider/mapquest.yml deleted file mode 100644 index 32a621c7..00000000 --- a/tests/Functional/config/provider/mapquest.yml +++ /dev/null @@ -1,9 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\MapQuestFactory - options: - api_key: 'bar' - licensed: true diff --git a/tests/Functional/config/provider/maxmind.yml b/tests/Functional/config/provider/maxmind.yml deleted file mode 100644 index 115302f0..00000000 --- a/tests/Functional/config/provider/maxmind.yml +++ /dev/null @@ -1,9 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\MaxMindFactory - options: - api_key: 'bar' - endpoint: 'f' diff --git a/tests/Functional/config/provider/maxmindbinary.yml b/tests/Functional/config/provider/maxmindbinary.yml deleted file mode 100644 index 068994d0..00000000 --- a/tests/Functional/config/provider/maxmindbinary.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\MaxMindBinaryFactory - options: - dat_file: '%kernel.project_dir%/tests/DependencyInjection/Fixtures/maxmind.dat' diff --git a/tests/Functional/config/provider/nominatim.yml b/tests/Functional/config/provider/nominatim.yml deleted file mode 100644 index 628b09aa..00000000 --- a/tests/Functional/config/provider/nominatim.yml +++ /dev/null @@ -1,11 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - empty: - factory: Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory - options: - root_url: 'https://nominatim.openstreetmap.org' - user_agent: 'geocoder-php test_suite' diff --git a/tests/Functional/config/provider/opencage.yml b/tests/Functional/config/provider/opencage.yml deleted file mode 100644 index de117fa1..00000000 --- a/tests/Functional/config/provider/opencage.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\OpenCageFactory - options: - api_key: 'foo' diff --git a/tests/Functional/config/provider/pickpoint.yml b/tests/Functional/config/provider/pickpoint.yml deleted file mode 100644 index 83938009..00000000 --- a/tests/Functional/config/provider/pickpoint.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\PickPointFactory - options: - api_key: 'foo' diff --git a/tests/Functional/config/provider/tomtom.yml b/tests/Functional/config/provider/tomtom.yml deleted file mode 100644 index 16fd7300..00000000 --- a/tests/Functional/config/provider/tomtom.yml +++ /dev/null @@ -1,8 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\TomTomFactory - options: - api_key: 'foo' diff --git a/tests/Functional/config/provider/yandex.yml b/tests/Functional/config/provider/yandex.yml deleted file mode 100644 index 62c2370e..00000000 --- a/tests/Functional/config/provider/yandex.yml +++ /dev/null @@ -1,10 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - empty: - factory: Bazinga\GeocoderBundle\ProviderFactory\YandexFactory - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\YandexFactory - options: - toponym: 'city' diff --git a/tests/Functional/config/service_plugin.yml b/tests/Functional/config/service_plugin.yml deleted file mode 100644 index 07bcdffb..00000000 --- a/tests/Functional/config/service_plugin.yml +++ /dev/null @@ -1,35 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory - plugins: - - acme.logger - - acme.2nd_logger - - { 'reference': { 'enabled': false, 'id': acme.3d_logger } } - - { 'reference': { 'enabled': true, 'id': acme.4th_logger } } - -services: - logger: - class: Psr\Log\NullLogger - - acme.logger: - class: Geocoder\Plugin\Plugin\LoggerPlugin - arguments: - - '@logger' - - acme.2nd_logger: - class: Geocoder\Plugin\Plugin\LoggerPlugin - arguments: - - '@logger' - - acme.3d_logger: - class: Geocoder\Plugin\Plugin\LoggerPlugin - arguments: - - '@logger' - - acme.4th_logger: - class: Geocoder\Plugin\Plugin\LoggerPlugin - arguments: - - '@logger' diff --git a/tests/Functional/config/simple.yml b/tests/Functional/config/simple.yml deleted file mode 100644 index 4398900f..00000000 --- a/tests/Functional/config/simple.yml +++ /dev/null @@ -1,6 +0,0 @@ -bazinga_geocoder: - profiling: - enabled: false - providers: - acme: - factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory diff --git a/tests/Mapping/Driver/AttributeDriverTest.php b/tests/Mapping/Driver/AttributeDriverTest.php deleted file mode 100644 index fae06aac..00000000 --- a/tests/Mapping/Driver/AttributeDriverTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - */ -final class AttributeDriverTest extends TestCase -{ - private AttributeDriver $driver; - - protected function setUp(): void - { - $this->driver = new AttributeDriver(); - } - - public function testLoadMetadata(): void - { - $metadata = $this->driver->loadMetadataFromObject(new Dummy()); - - self::assertNotNull($metadata->addressProperty); - self::assertSame('address', $metadata->addressProperty->getName()); - self::assertNotNull($metadata->latitudeProperty); - self::assertSame('latitude', $metadata->latitudeProperty->getName()); - self::assertNotNull($metadata->longitudeProperty); - self::assertSame('longitude', $metadata->longitudeProperty->getName()); - } - - public function testLoadMetadataWithAddressGetter(): void - { - $metadata = $this->driver->loadMetadataFromObject(new DummyWithAddressGetter()); - - self::assertNotNull($metadata->addressGetter); - self::assertSame('getAddress', $metadata->addressGetter->getName()); - } - - public function testLoadMetadataFromWrongObject(): void - { - $this->expectException(MappingException::class); - $this->expectExceptionMessage('The class "'.DummyNonGeocodable::class.'" is not geocodeable'); - - $this->driver->loadMetadataFromObject(new DummyNonGeocodable()); - } - - public function testIsGeocodable(): void - { - self::assertTrue($this->driver->isGeocodeable(new Dummy())); - } -} diff --git a/tests/Mapping/Driver/Fixtures/Dummy.php b/tests/Mapping/Driver/Fixtures/Dummy.php deleted file mode 100644 index 9745d985..00000000 --- a/tests/Mapping/Driver/Fixtures/Dummy.php +++ /dev/null @@ -1,31 +0,0 @@ -handleQuery($query, function (Query $query) { return $query; }, function () {}); - - self::assertSame($query->getText(), '123.123.123.123'); - } - - /** - * @testWith [null] - * [""] - */ - public function testEmptyLocalIpQuery(?string $localIp): void - { - $fakeIpPlugin = new FakeIpPlugin($localIp, '123.123.123.123'); - $query = GeocodeQuery::create('124.124.124.124'); - - /** @var Query $query */ - $query = $fakeIpPlugin->handleQuery($query, function (Query $query) { return $query; }, function () {}); - - self::assertSame($query->getText(), '123.123.123.123'); - } - - public function testHandleQueryUsingFaker(): void - { - $fakeIpPlugin = new FakeIpPlugin('127.0.0.1', '192.168.1.1', true); - $query = GeocodeQuery::create('127.0.0.1'); - - /** @var Query $query */ - $query = $fakeIpPlugin->handleQuery($query, function (Query $query) { return $query; }, function () {}); - - self::assertNotSame($query->getText(), '192.168.1.1'); - } -} diff --git a/tests/Validator/Constraint/AddressValidatorTest.php b/tests/Validator/Constraint/AddressValidatorTest.php deleted file mode 100644 index be211351..00000000 --- a/tests/Validator/Constraint/AddressValidatorTest.php +++ /dev/null @@ -1,93 +0,0 @@ - ['content-type' => 'application-json']]); - } - - if ('https://nominatim.openstreetmap.org/search?format=jsonv2&q=Bifrost%2C%20Nine%20Realms&addressdetails=1&extratags=1&limit=5' === $url) { - self::assertSame('GET', $method); - - return new MockResponse('[]', ['response_headers' => ['content-type' => 'application-json']]); - } - - self::fail(sprintf('Unexpected http call "%s %s".', $method, $url)); - }); - - $geocoder = Nominatim::withOpenStreetMapServer(new Psr18Client($httpClient), 'BazingaGeocoderBundle/Test'); - - return new AddressValidator($geocoder); - } - - public function testNullIsValid(): void - { - $this->validator->validate(null, new Address()); - - $this->assertNoViolation(); - } - - public function testEmptyStringIsValid(): void - { - $this->validator->validate('', new Address()); - - $this->assertNoViolation(); - } - - public function testExpectsStringCompatibleType(): void - { - $this->expectException(UnexpectedValueException::class); - - $this->validator->validate(new \stdClass(), new Address()); - } - - public function testValidAddress(): void - { - $this->validator->validate('Berlin, Germany', new Address()); - - $this->assertNoViolation(); - } - - public function testInvalidAddress(): void - { - $address = 'Bifrost, Nine Realms'; - - $constraint = new Address([ - 'message' => 'myMessage {{ address }}', - ]); - - $this->validator->validate($address, $constraint); - - $this->buildViolation('myMessage {{ address }}') - ->setParameter('{{ address }}', '"'.$address.'"') - ->setInvalidValue($address) - ->setCode(Address::INVALID_ADDRESS_ERROR) - ->assertRaised(); - } -} diff --git a/tests/baseline-ignore b/tests/baseline-ignore deleted file mode 100644 index d9f6ca3c..00000000 --- a/tests/baseline-ignore +++ /dev/null @@ -1,91 +0,0 @@ -%Since doctrine/doctrine-bundle 2.11: Not setting "enable_lazy_ghost_objects" to true is deprecated% -%Not configuring a schema manager factory is deprecated. Use Doctrine\\DBAL\\Schema\\DefaultSchemaManagerFactory which is going to be the default in DBAL 4% -%Doctrine\\DBAL\\Configuration::setSQLLogger is deprecated, use setMiddlewares\(\) and Logging\\Middleware instead% -%Accessing Doctrine\\Common\\Lexer\\Token properties via ArrayAccess is deprecated, use the value, type or position property instead% -%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% -%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% -%Geocoder\\Model\\AdminLevel::__construct\(\): Implicitly marking parameter \$code as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\AdminLevelCollection::slice\(\): Implicitly marking parameter \$length as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\ProviderAggregator::getProvider\(\): Implicitly marking parameter \$currentProvider as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\AddressCollection::slice\(\): Implicitly marking parameter \$length as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Collection::slice\(\): Implicitly marking parameter \$length as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\BingMaps\\BingMaps::executeQuery\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\GoogleMaps\\GoogleMaps::__construct\(\): Implicitly marking parameter \$region as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\GoogleMaps\\GoogleMaps::__construct\(\): Implicitly marking parameter \$apiKey as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\GoogleMaps\\GoogleMaps::business\(\): Implicitly marking parameter \$privateKey as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\GoogleMaps\\GoogleMaps::business\(\): Implicitly marking parameter \$region as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\GoogleMaps\\GoogleMaps::business\(\): Implicitly marking parameter \$apiKey as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\GoogleMaps\\GoogleMaps::business\(\): Implicitly marking parameter \$channel as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\GoogleMaps\\GoogleMaps::buildQuery\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\GoogleMaps\\GoogleMaps::buildQuery\(\): Implicitly marking parameter \$region as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\GoogleMaps\\GoogleMaps::fetchUrl\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\GoogleMaps\\GoogleMaps::fetchUrl\(\): Implicitly marking parameter \$region as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Nominatim::executeQuery\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Plugin\\Promise\\GeocoderFulfilledPromise::then\(\): Implicitly marking parameter \$onFulfilled as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Plugin\\Promise\\GeocoderFulfilledPromise::then\(\): Implicitly marking parameter \$onRejected as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Plugin\\Plugin\\CachePlugin::__construct\(\): Implicitly marking parameter \$lifetime as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Plugin\\Plugin\\CachePlugin::__construct\(\): Implicitly marking parameter \$precision as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\AddressBuilder::addAdminLevel\(\): Implicitly marking parameter \$code as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withAttribution\(\): Implicitly marking parameter \$attribution as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withClass\(\): Implicitly marking parameter \$category as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withCategory\(\): Implicitly marking parameter \$category as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withDisplayName\(\): Implicitly marking parameter \$displayName as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withOSMId\(\): Implicitly marking parameter \$osmId as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withOSMType\(\): Implicitly marking parameter \$osmType as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withType\(\): Implicitly marking parameter \$type as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withQuarter\(\): Implicitly marking parameter \$quarter as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withDetails\(\): Implicitly marking parameter \$details as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withTags\(\): Implicitly marking parameter \$tags as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Nominatim\\Model\\NominatimAddress::withNeighbourhood\(\): Implicitly marking parameter \$neighbourhood as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\AlgoliaPlaces\\AlgoliaPlaces::__construct\(\): Implicitly marking parameter \$apiKey as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\AlgoliaPlaces\\AlgoliaPlaces::__construct\(\): Implicitly marking parameter \$appId as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\AlgoliaPlaces\\AlgoliaPlaces::buildResult\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\AlgoliaPlaces\\AlgoliaPlaces::getResultAttribute\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\ArcGISOnline\\ArcGISOnline::__construct\(\): Implicitly marking parameter \$sourceCountry as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\ArcGISOnline\\ArcGISOnline::__construct\(\): Implicitly marking parameter \$token as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\ArcGISOnline\\ArcGISOnline::token\(\): Implicitly marking parameter \$sourceCountry as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Geonames\\Geonames::getCountryInfo\(\): Implicitly marking parameter \$country as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Geonames\\Geonames::getCountryInfo\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Geonames\\Geonames::executeQuery\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Here\\Here::__construct\(\): Implicitly marking parameter \$appId as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Here\\Here::__construct\(\): Implicitly marking parameter \$appCode as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\LocationIQ\\LocationIQ::__construct\(\): Implicitly marking parameter \$region as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\LocationIQ\\LocationIQ::executeQuery\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Mapbox\\Mapbox::__construct\(\): Implicitly marking parameter \$country as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Mapbox\\Mapbox::buildQuery\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Mapbox\\Mapbox::buildQuery\(\): Implicitly marking parameter \$country as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Mapbox\\Mapbox::fetchUrl\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Mapbox\\Mapbox::fetchUrl\(\): Implicitly marking parameter \$country as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\OpenCage\\OpenCage::executeQuery\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\PickPoint\\PickPoint::executeQuery\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Yandex\\Yandex::__construct\(\): Implicitly marking parameter \$toponym as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Yandex\\Yandex::__construct\(\): Implicitly marking parameter \$apiKey as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Provider\\Yandex\\Yandex::executeQuery\(\): Implicitly marking parameter \$locale as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Http\\Provider\\AbstractHttpProvider::__construct\(\): Implicitly marking parameter \$factory as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Country::__construct\(\): Implicitly marking parameter \$name as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Country::__construct\(\): Implicitly marking parameter \$code as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Address::__construct\(\): Implicitly marking parameter \$coordinates as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Address::__construct\(\): Implicitly marking parameter \$bounds as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Address::__construct\(\): Implicitly marking parameter \$streetNumber as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Address::__construct\(\): Implicitly marking parameter \$streetName as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Address::__construct\(\): Implicitly marking parameter \$postalCode as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Address::__construct\(\): Implicitly marking parameter \$locality as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Address::__construct\(\): Implicitly marking parameter \$subLocality as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Address::__construct\(\): Implicitly marking parameter \$country as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\Model\\Address::__construct\(\): Implicitly marking parameter \$timezone as nullable is deprecated, the explicit nullable type must be used instead% -%Geocoder\\ProviderAggregator::__construct\(\): Implicitly marking parameter \$decider as nullable is deprecated, the explicit nullable type must be used instead% -%Since symfony/var-exporter 7.3: The "Symfony\\Component\\VarExporter\\LazyGhostTrait" trait is deprecated, use native lazy objects instead.% -%Method "Http\\Promise\\Promise::wait\(\)" might add " Resolved value, null if \$unwrap is set to false" as a native return type declaration in the future. Do the same in implementation "Geocoder\\Plugin\\Promise\\GeocoderFulfilledPromise" now to avoid errors or add an explicit @return annotation to suppress this message.% -%The "Symfony\\Component\\HttpKernel\\Kernel::setAnnotatedClassCache\(\)" method is considered internal. It may change without further notice. You should not extend it from "Bazinga\\GeocoderBundle\\Tests\\Functional\\CustomTestKernel".% -%The "report_fields_where_declared" configuration option is deprecated and will be removed in DoctrineBundle 3.0. When using ORM 3, report_fields_where_declared will always be true% -%Class "Doctrine\\ORM\\Proxy\\DefaultProxyClassNameResolver" is deprecated. Use native lazy objects instead% -%Calling Doctrine\\ORM\\Configuration::(getProxyDir|setProxyDir|getAutoGenerateProxyClasses|setAutoGenerateProxyClasses|setProxyNamespace|getProxyNamespace) is deprecated and will not be possible in Doctrine ORM 4.0% -%Class "Doctrine\\ORM\\Proxy\\Autoloader" is deprecated. Use native lazy objects instead% -%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% diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index d0cb7088..00000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,21 +0,0 @@ -