diff --git a/.editorconfig b/.editorconfig index 677e36e2..68a969ea 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,3 +7,6 @@ indent_size = 4 indent_style = space insert_final_newline = true trim_trailing_whitespace = true + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75654188..86865d3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: name: PHPStan runs-on: ubuntu-latest env: - php-version: 8.2 + php-version: 8.4 steps: - name: "Setup PHP" uses: shivammathur/setup-php@v2 @@ -35,7 +35,8 @@ jobs: name: PHP-CS-Fixer runs-on: ubuntu-latest env: - php-version: 8.2 + php-version: 8.4 + PHP_CS_FIXER_IGNORE_ENV: 1 steps: - name: "Setup PHP" uses: shivammathur/setup-php@v2 @@ -55,35 +56,26 @@ jobs: 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 }}) (${{ matrix.dependencies }}) + name: PHPUnit (PHP ${{ matrix.php }}) (Symfony ${{ matrix.sf_version }}) runs-on: ubuntu-latest strategy: max-parallel: 10 fail-fast: false matrix: - dependencies: ['highest'] - php: [ '7.4', '8.0', '8.1', '8.2' ] - sf_version: [ '4.4.*', '5.4.*', '6.4.*', '7.0.*' ] -# include: -# - php: '7.4' -# sf_version: '4.4.*' -# dependencies: 'lowest' -# - php: '7.4' -# sf_version: '5.4.*' -# dependencies: 'lowest' + php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] + sf_version: [ '5.4.*', '6.4.*', '7.2.*' ] exclude: - - php: '7.4' - sf_version: '4.4.*' - php: '7.4' sf_version: '6.4.*' - php: '8.0' sf_version: '6.4.*' - php: '7.4' - sf_version: '7.0.*' + sf_version: '7.2.*' - php: '8.0' - sf_version: '7.0.*' + sf_version: '7.2.*' - php: '8.1' - sf_version: '7.0.*' + sf_version: '7.2.*' + steps: - name: "Checkout code" uses: actions/checkout@v4 @@ -101,7 +93,6 @@ jobs: uses: "ramsey/composer-install@v3" with: composer-options: "--optimize-autoloader" - dependency-versions: "${{ matrix.dependencies }}" - name: "Run tests" env: diff --git a/README.md b/README.md index 619c6e1d..ed2404d2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ BazingaGeocoderBundle ===================== -[![Build Status](https://travis-ci.org/geocoder-php/BazingaGeocoderBundle.svg?branch=master)](http://travis-ci.org/geocoder-php/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) diff --git a/composer.json b/composer.json index 830303a9..be2d0370 100644 --- a/composer.json +++ b/composer.json @@ -18,17 +18,17 @@ "geocoder-php/plugin": "^1.5", "php-http/curl-client": "^2.3", "php-http/discovery": "^1.14", - "symfony/console": "^4.4 || ^5.4 || ^6.4 || ^7.0", - "symfony/framework-bundle": "^4.4 || ^5.4 || ^6.4 || ^7.0", - "symfony/options-resolver": "^4.4 || ^5.4 || ^6.4 || ^7.0", + "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" }, "require-dev": { "doctrine/annotations": "^1.11.1 || ^2.0", "doctrine/doctrine-bundle": "^2.3", - "doctrine/orm": "^2.8", + "doctrine/orm": "^2.8 || ^3.0", "fakerphp/faker": "^1.20", - "friendsofphp/php-cs-fixer": "^3.0", + "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", @@ -67,12 +67,12 @@ "phpstan/phpstan": "^1.9.2", "psr/http-client": "^1.0", "psr/simple-cache": "^1.0 || ^2.0", - "symfony/cache": "^4.4 || ^5.0 || ^6.0 || ^7.0", - "symfony/config": "^4.4 || ^5.0 || ^6.0 || ^7.0", - "symfony/phpunit-bridge": "^6.1", - "symfony/validator": "^4.4 || ^5.0 || ^6.0 || ^7.0", - "symfony/var-exporter": "^5.0 || ^6.0 || ^7.0", - "symfony/yaml": "^4.4 || ^5.0 || ^6.0 || ^7.0" + "symfony/cache": "^5.4 || ^6.4 || ^7.0", + "symfony/config": "^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" }, "conflict": { "geocoder-php/nominatim-provider": "<5.0" diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 864b6503..4d7a09d4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -125,6 +125,11 @@ parameters: count: 1 path: src/DependencyInjection/Configuration.php + - + message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Event\\\\OnFlushEventArgs\\:\\:getEntityManager\\(\\)\\.$#" + count: 1 + path: src/Doctrine/ORM/GeocoderListener.php + - message: "#^Cannot call method getLatitude\\(\\) on Geocoder\\\\Model\\\\Coordinates\\|null\\.$#" count: 1 @@ -135,6 +140,16 @@ parameters: count: 1 path: src/Doctrine/ORM/GeocoderListener.php + - + message: "#^Method Bazinga\\\\GeocoderBundle\\\\Mapping\\\\Driver\\\\AnnotationDriver\\:\\:getReflection\\(\\) return type with generic class ReflectionClass does not specify its types\\: T$#" + count: 1 + path: src/Mapping/Driver/AnnotationDriver.php + + - + message: "#^Method Bazinga\\\\GeocoderBundle\\\\Mapping\\\\Driver\\\\AttributeDriver\\:\\:getReflection\\(\\) return type with generic class ReflectionClass does not specify its types\\: T$#" + count: 1 + path: src/Mapping/Driver/AttributeDriver.php + - message: "#^Parameter \\#1 \\$text of method Geocoder\\\\Query\\\\GeocodeQuery\\:\\:withText\\(\\) expects string, string\\|null given\\.$#" count: 1 diff --git a/src/Mapping/Driver/AnnotationDriver.php b/src/Mapping/Driver/AnnotationDriver.php index e2ae8498..71089902 100644 --- a/src/Mapping/Driver/AnnotationDriver.php +++ b/src/Mapping/Driver/AnnotationDriver.php @@ -17,6 +17,7 @@ use Bazinga\GeocoderBundle\Mapping\Exception; use Doctrine\Common\Annotations\Reader; use Doctrine\Common\Util\ClassUtils; +use Doctrine\ORM\Proxy\DefaultProxyClassNameResolver; /** * @author Markus Bachmann @@ -32,14 +33,14 @@ public function __construct(Reader $reader) public function isGeocodeable($object): bool { - $reflection = ClassUtils::newReflectionObject($object); + $reflection = self::getReflection($object); return (bool) $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class); } public function loadMetadataFromObject($object) { - $reflection = ClassUtils::newReflectionObject($object); + $reflection = self::getReflection($object); if (!$annotation = $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class)) { throw new Exception\MappingException(sprintf('The class %s is not geocodeable', get_class($object))); @@ -74,4 +75,13 @@ public function loadMetadataFromObject($object) return $metadata; } + + private static function getReflection(object $object): \ReflectionClass + { + if (class_exists(ClassUtils::class)) { + return ClassUtils::newReflectionObject($object); + } + + return new \ReflectionClass(DefaultProxyClassNameResolver::getClass($object)); + } } diff --git a/src/Mapping/Driver/AttributeDriver.php b/src/Mapping/Driver/AttributeDriver.php index 2b1cbaaf..703b0efb 100644 --- a/src/Mapping/Driver/AttributeDriver.php +++ b/src/Mapping/Driver/AttributeDriver.php @@ -16,6 +16,7 @@ use Bazinga\GeocoderBundle\Mapping\ClassMetadata; use Bazinga\GeocoderBundle\Mapping\Exception\MappingException; use Doctrine\Common\Util\ClassUtils; +use Doctrine\ORM\Proxy\DefaultProxyClassNameResolver; /** * @author Pierre du Plessis @@ -28,7 +29,7 @@ public function isGeocodeable($object): bool return false; } - $reflection = ClassUtils::newReflectionObject($object); + $reflection = self::getReflection($object); return count($reflection->getAttributes(Annotations\Geocodeable::class)) > 0; } @@ -42,7 +43,7 @@ public function loadMetadataFromObject($object): ClassMetadata throw new MappingException(sprintf('The class %s is not geocodeable', get_class($object))); } - $reflection = ClassUtils::newReflectionObject($object); + $reflection = self::getReflection($object); $attributes = $reflection->getAttributes(Annotations\Geocodeable::class); @@ -79,4 +80,13 @@ public function loadMetadataFromObject($object): ClassMetadata return $metadata; } + + private static function getReflection(object $object): \ReflectionClass + { + if (class_exists(ClassUtils::class)) { + return ClassUtils::newReflectionObject($object); + } + + return new \ReflectionClass(DefaultProxyClassNameResolver::getClass($object)); + } } diff --git a/templates/Collector/geocoder.html.twig b/templates/Collector/geocoder.html.twig index 01f747b3..9ec3c1fb 100644 --- a/templates/Collector/geocoder.html.twig +++ b/templates/Collector/geocoder.html.twig @@ -99,7 +99,7 @@ {% if query.result.message is defined %} Exception {% else %} - {{ dump(query.resultCount) }} Result(s) + {{ profiler_dump(query.resultCount) }} Result(s) {% endif %}