From bf7379e76a548bc79a5ebe7eab4cb30474c02f0e Mon Sep 17 00:00:00 2001 From: aaa2000 Date: Mon, 15 Dec 2025 14:07:25 +0100 Subject: [PATCH] ci: php 8.5 (#7585) --- .github/workflows/ci.yml | 49 +++++++++++-------- src/Doctrine/Odm/Filter/ExistsFilter.php | 2 +- src/Doctrine/Odm/Filter/OrderFilter.php | 2 +- src/Doctrine/Orm/Filter/OrderFilter.php | 2 +- .../Extension/PaginationExtensionTest.php | 2 - .../Tests/Serializer/ItemNormalizerTest.php | 1 - .../Extractor/PhpFileResourceExtractor.php | 1 - .../PublishMercureUpdatesListener.php | 12 ++--- .../TestBundle/Document/ResourceWithFloat.php | 7 ++- .../TestBundle/Entity/ResourceWithFloat.php | 14 ++++-- 10 files changed, 52 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f212c87769..f135f73d3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false steps: - name: Checkout @@ -81,7 +81,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false steps: - name: Checkout @@ -118,7 +118,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false env: APP_DEBUG: '1' # https://github.com/phpstan/phpstan-symfony/issues/37 @@ -188,10 +188,12 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' include: - php: '8.2' - php: '8.3' - php: '8.4' + - php: '8.5' coverage: true fail-fast: false steps: @@ -262,10 +264,11 @@ jobs: - version: '8.2' - version: '8.3' - version: '8.4' + - version: '8.5' coverage: true - - version: '8.4' + - version: '8.5' lowest: true - - version: '8.4' + - version: '8.5' minimal-changes: true component: - api-platform/doctrine-common @@ -351,7 +354,7 @@ jobs: strategy: matrix: php: - - version: '8.4' + - version: '8.5' component: - api-platform/doctrine-common - api-platform/doctrine-orm @@ -404,10 +407,12 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' include: - php: '8.2' - php: '8.3' - php: '8.4' + - php: '8.5' coverage: true fail-fast: false steps: @@ -485,7 +490,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false env: APP_ENV: postgres @@ -539,7 +544,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false services: mysql: @@ -593,7 +598,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false env: APP_ENV: mongodb @@ -681,7 +686,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false env: APP_ENV: mercure @@ -839,7 +844,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false steps: - name: Checkout @@ -878,7 +883,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false steps: - name: Checkout @@ -921,7 +926,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false steps: - name: Checkout @@ -966,7 +971,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false env: APP_ENV: sqlite @@ -1063,7 +1068,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false steps: - name: Checkout @@ -1109,9 +1114,9 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' include: - - php: '8.4' + - php: '8.5' coverage: true fail-fast: false steps: @@ -1187,7 +1192,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false steps: - name: Checkout @@ -1235,7 +1240,7 @@ jobs: strategy: matrix: php: - - '8.4' + - '8.5' fail-fast: false steps: - name: Checkout @@ -1286,10 +1291,12 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' include: - php: '8.2' - php: '8.3' - php: '8.4' + - php: '8.5' coverage: true fail-fast: false steps: @@ -1319,7 +1326,7 @@ jobs: working-directory: 'src/Laravel' laravel-e2e: - name: Laravel E2E installation (PHP 8.4) + name: Laravel E2E installation (PHP 8.5) runs-on: ubuntu-latest timeout-minutes: 20 steps: @@ -1328,7 +1335,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.4 + php-version: 8.5 tools: pecl, composer extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite ini-values: memory_limit=-1 diff --git a/src/Doctrine/Odm/Filter/ExistsFilter.php b/src/Doctrine/Odm/Filter/ExistsFilter.php index a4f751b3a9..452df1e9d8 100644 --- a/src/Doctrine/Odm/Filter/ExistsFilter.php +++ b/src/Doctrine/Odm/Filter/ExistsFilter.php @@ -129,7 +129,7 @@ public function __construct(?ManagerRegistry $managerRegistry = null, ?LoggerInt public function apply(Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void { $parameter = $context['parameter'] ?? null; - if (null !== ($value = $context['filters'][$parameter?->getProperty()] ?? null)) { + if (null !== ($value = $context['filters'][$parameter?->getProperty() ?? ''] ?? null)) { $this->filterProperty($this->denormalizePropertyName($parameter->getProperty()), $value, $aggregationBuilder, $resourceClass, $operation, $context); return; diff --git a/src/Doctrine/Odm/Filter/OrderFilter.php b/src/Doctrine/Odm/Filter/OrderFilter.php index c699275c0c..c518cf6ca4 100644 --- a/src/Doctrine/Odm/Filter/OrderFilter.php +++ b/src/Doctrine/Odm/Filter/OrderFilter.php @@ -239,7 +239,7 @@ public function apply(Builder $aggregationBuilder, string $resourceClass, ?Opera } $parameter = $context['parameter'] ?? null; - if (null !== ($value = $context['filters'][$parameter?->getProperty()] ?? null)) { + if (null !== ($value = $context['filters'][$parameter?->getProperty() ?? ''] ?? null)) { $this->filterProperty($this->denormalizePropertyName($parameter->getProperty()), $value, $aggregationBuilder, $resourceClass, $operation, $context); return; diff --git a/src/Doctrine/Orm/Filter/OrderFilter.php b/src/Doctrine/Orm/Filter/OrderFilter.php index f924aabac1..54de60267c 100644 --- a/src/Doctrine/Orm/Filter/OrderFilter.php +++ b/src/Doctrine/Orm/Filter/OrderFilter.php @@ -238,7 +238,7 @@ public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $q } $parameter = $context['parameter'] ?? null; - if (null !== ($value = $context['filters'][$parameter?->getProperty()] ?? null)) { + if (null !== ($value = $context['filters'][$parameter?->getProperty() ?? ''] ?? null)) { $this->filterProperty($this->denormalizePropertyName($parameter->getProperty()), $value, $queryBuilder, $queryNameGenerator, $resourceClass, $operation, $context); return; diff --git a/src/Doctrine/Orm/Tests/Extension/PaginationExtensionTest.php b/src/Doctrine/Orm/Tests/Extension/PaginationExtensionTest.php index f4acdd700f..005ffae16f 100644 --- a/src/Doctrine/Orm/Tests/Extension/PaginationExtensionTest.php +++ b/src/Doctrine/Orm/Tests/Extension/PaginationExtensionTest.php @@ -388,7 +388,6 @@ public function testGetResultWithFetchJoinCollection(bool $paginationFetchJoinCo $this->assertInstanceOf(PaginatorInterface::class, $result); $doctrinePaginatorReflectionProperty = new \ReflectionProperty(AbstractPaginator::class, 'paginator'); - $doctrinePaginatorReflectionProperty->setAccessible(true); $doctrinePaginator = $doctrinePaginatorReflectionProperty->getValue($result); $this->assertSame($expected, $doctrinePaginator->getFetchJoinCollection()); @@ -436,7 +435,6 @@ public function testGetResultWithUseOutputWalkers(bool $paginationUseOutputWalke $this->assertInstanceOf(PaginatorInterface::class, $result); $doctrinePaginatorReflectionProperty = new \ReflectionProperty(AbstractPaginator::class, 'paginator'); - $doctrinePaginatorReflectionProperty->setAccessible(true); $doctrinePaginator = $doctrinePaginatorReflectionProperty->getValue($result); $this->assertSame($expected, $doctrinePaginator->getUseOutputWalkers()); diff --git a/src/Hal/Tests/Serializer/ItemNormalizerTest.php b/src/Hal/Tests/Serializer/ItemNormalizerTest.php index 750be842af..2dfef7ad0c 100644 --- a/src/Hal/Tests/Serializer/ItemNormalizerTest.php +++ b/src/Hal/Tests/Serializer/ItemNormalizerTest.php @@ -296,7 +296,6 @@ public function testMaxDepth(): void { $setId = static function (MaxDepthDummy $dummy, int $id): void { $prop = new \ReflectionProperty($dummy, 'id'); - $prop->setAccessible(true); $prop->setValue($dummy, $id); }; diff --git a/src/Metadata/Extractor/PhpFileResourceExtractor.php b/src/Metadata/Extractor/PhpFileResourceExtractor.php index d0a4a0a198..672dd4e020 100644 --- a/src/Metadata/Extractor/PhpFileResourceExtractor.php +++ b/src/Metadata/Extractor/PhpFileResourceExtractor.php @@ -38,7 +38,6 @@ protected function extractPath(string $path): void $resourceReflection = new \ReflectionClass($resource); foreach ($resourceReflection->getProperties() as $property) { - $property->setAccessible(true); $resolvedValue = $this->resolve($property->getValue($resource)); $property->setValue($resource, $resolvedValue); } diff --git a/src/Symfony/Doctrine/EventListener/PublishMercureUpdatesListener.php b/src/Symfony/Doctrine/EventListener/PublishMercureUpdatesListener.php index 14763dbe96..902f4c52a0 100644 --- a/src/Symfony/Doctrine/EventListener/PublishMercureUpdatesListener.php +++ b/src/Symfony/Doctrine/EventListener/PublishMercureUpdatesListener.php @@ -129,16 +129,16 @@ public function postFlush(): void try { $creatingObjects = clone $this->createdObjects; foreach ($creatingObjects as $object) { - if ($this->createdObjects->contains($object)) { - $this->createdObjects->detach($object); + if ($this->createdObjects->offsetExists($object)) { + $this->createdObjects->offsetUnset($object); } $this->publishUpdate($object, $creatingObjects[$object], 'create'); } $updatingObjects = clone $this->updatedObjects; foreach ($updatingObjects as $object) { - if ($this->updatedObjects->contains($object)) { - $this->updatedObjects->detach($object); + if ($this->updatedObjects->offsetExists($object)) { + $this->updatedObjects->offsetUnset($object); } $this->publishUpdate($object, $updatingObjects[$object], 'update'); } @@ -146,8 +146,8 @@ public function postFlush(): void $deletingObjects = clone $this->deletedObjects; foreach ($deletingObjects as $object) { $options = $this->deletedObjects[$object]; - if ($this->deletedObjects->contains($object)) { - $this->deletedObjects->detach($object); + if ($this->deletedObjects->offsetExists($object)) { + $this->deletedObjects->offsetUnset($object); } $this->publishUpdate($object, $deletingObjects[$object], 'delete'); } diff --git a/tests/Fixtures/TestBundle/Document/ResourceWithFloat.php b/tests/Fixtures/TestBundle/Document/ResourceWithFloat.php index 2b66265cd7..5af9cc73a4 100644 --- a/tests/Fixtures/TestBundle/Document/ResourceWithFloat.php +++ b/tests/Fixtures/TestBundle/Document/ResourceWithFloat.php @@ -33,9 +33,12 @@ public function getId(): ?int return $this->id; } - public function getMyFloatField(): float + public function getMyFloatField(): string|float { - return $this->myFloatField; + // php 8.5 emits warning unexpected NAN value was coerced to string + // with symfony serializer + // @see https://github.com/symfony/symfony/pull/62740 + return is_nan($this->myFloatField) ? 'NAN' : $this->myFloatField; } public function setMyFloatField(float $myFloatField): void diff --git a/tests/Fixtures/TestBundle/Entity/ResourceWithFloat.php b/tests/Fixtures/TestBundle/Entity/ResourceWithFloat.php index f38b6a2d90..94ba3b1b3e 100644 --- a/tests/Fixtures/TestBundle/Entity/ResourceWithFloat.php +++ b/tests/Fixtures/TestBundle/Entity/ResourceWithFloat.php @@ -28,20 +28,26 @@ class ResourceWithFloat #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; #[ORM\Column(type: 'float')] - private float $myFloatField = 0.0; + private string|float $myFloatField = 0.0; public function getId(): ?int { return $this->id; } - public function getMyFloatField(): float + public function getMyFloatField(): string|float { - return $this->myFloatField; + // php 8.5 emits warning unexpected NAN value was coerced to string + // with symfony serializer + // @see https://github.com/symfony/symfony/pull/62740 + return is_nan($this->myFloatField) ? 'NAN' : $this->myFloatField; } public function setMyFloatField(float $myFloatField): void { - $this->myFloatField = $myFloatField; + // When binding a NAN value to a prepared statement parameter with Doctrine, + // PHP 8.5 emits a warning: "unexpected NAN value was coerced to string". + // @see https://github.com/doctrine/dbal/pull/7249 + $this->myFloatField = is_nan($myFloatField) ? 'NAN' : $myFloatField; } }