Skip to content

ci: use php 8.5 - #7585

Merged
soyuka merged 7 commits into
api-platform:mainfrom
aaa2000:php85
Dec 15, 2025
Merged

ci: use php 8.5#7585
soyuka merged 7 commits into
api-platform:mainfrom
aaa2000:php85

Conversation

@aaa2000

@aaa2000aaa2000 commented Dec 4, 2025

Copy link
Copy Markdown
Contributor
QA
Branchmain
LicenseMIT

This PR updates the GitHub Actions workflow to use the latest stable PHP version, 8.5, in the CI pipeline.

@aaa2000

Copy link
Copy Markdown
ContributorAuthor

The error of the "PHPUnit + Behat (PHP 8.5) (MongoDB)" job is already present on the main branch.

The errors of others behat jobs appear to be related to the following deprecation https://wiki.php.net/rfc/warnings-php-8-5#coercing_nan_to_other_types

<response>
<title>An error occurred</title>
<detail>Warning: unexpected NAN value was coerced to string in
/code/vendor/doctrine/dbal/src/Driver/PDO/Statement.php line 26
</detail>
<status>500</status>
<type>/errors/500</type>
<trace>
<function>handleError</function>
<class>Behat\Testwork\Call\Handler\RuntimeCallHandler</class>
<type><![CDATA[->]]></type>
</trace>
<trace>
<file>/code/vendor/doctrine/dbal/src/Driver/PDO/Statement.php</file>
<line>26</line>
<function>bindValue</function>
<class>PDOStatement</class>
<type><![CDATA[->]]></type>
</trace>

When the value is NaN, INF, or -INF, PDO::bindValue with PDO::PARAM_STR appears to convert to a string and throw the warning Warning: unexpected NAN value was coerced to string

Note: These values ​​are not compatible with SQLite, the value is 0, unlike postgres.

<?xml version="1.0"?><response><id>2</id><myFloatField>NAN</myFloatField></response>
<?xml version="1.0"?><response><id>3</id><myFloatField>INF</myFloatField></response>
`<?xml version="1.0"?>\n<response><id>4</id><myFloatField>-INF</myFloatField></response>

no idea how to fix it... Should the test be ignored in PHP 8.5?

Comment thread.github/workflows/ci.yml Outdated
matrix:
php:
- '8.3'
- '8.5'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

php-cs-fixer doesn't support 8.5 yet can you lower to 8.4 maybe?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP 8.5 officially supported in version v3.91.0 https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/tag/v3.91.0

@soyukasoyukaDec 11, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah but their recommendation is:

You are running PHP CS Fixer on PHP 8.5.0, but the minimum PHP version supported by your project in composer.json is PHP 8.2. Executing PHP CS Fixer on newer PHP versions may introduce syntax or features not yet available in PHP 8.2, which could cause issues under that version. It is recommended to run PHP CS Fixer on PHP 8.2, to fit your project specifics.

Unsure about what we should do...

@soyuka

soyuka commented Dec 7, 2025

Copy link
Copy Markdown
Member

This failure is probably related to the changes:


--- Failed steps:
001 Example: | NaN | # features/xml/deserialization.feature:74
Then the response status code should be 201 # features/xml/deserialization.feature:68
Current response status code is 500, but 201 expected. (Behat\Mink\Exception\ExpectationException)
839 scenarios (837 passed, 1 failed, 1 undefined)
5481 steps (5470 passed, 1 failed, 1 undefined, 9 skipped)
6m38.62s (324.02Mb)

Add a Then print last JSON response in there to know what's wrong. There are instructions in CONTRIBUTING.md if you need the commands to run the tests.

@aaa2000

Copy link
Copy Markdown
ContributorAuthor

The error <response><title>An error occurred</title><detail>Warning: unexpected NAN value was coerced to string in /code/vendor/doctrine/dbal/src/Driver/PDO/Statement.php line 26</detail> was a dump of the response. I think it's the same thing as step `Then print last JSON response.

With PHP 8.5 and PDO, I have

docker run --rm php:8.5-cli php -r '
$pdo = new PDO("sqlite::memory:");
$stmt = $pdo->prepare("
WITH dummy(value) AS (VALUES ('1'), ('2'))
SELECT * FROM dummy WHERE value = :value
");
$stmt->bindValue(":value", NAN, PDO::PARAM_STR);
$stmt->execute();
var_dump($stmt->fetchAll());
'
Warning: unexpected NAN value was coerced to string in Command line code on line 7
array(0) {
}

I will investigate further

@soyuka

Copy link
Copy Markdown
Member

Interesting this means that the issue is inside Symfony transformation? I'm not even sure why we support XML to be honest xD

@aaa2000
aaa2000force-pushed the php85 branch 2 times, most recently from 3f20608 to f6abdb6CompareDecember 11, 2025 16:36
ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants
Method SplObjectStorage::contains() is deprecated since 8.5, use method SplObjectStorage::offsetExists() instead
Method SplObjectStorage::detach() is deprecated since 8.5, use method SplObjectStorage::offsetUnset() instead
When binding a NAN value to a prepared statement parameter, PHP 8.5 emits a warning: "unexpected NAN value was coerced to string". This warning is not present in PHP 8.4, where the value was silently converted to the string "NAN" and handled correctly by PostgreSQL.
@seehttps://wiki.php.net/rfc/warnings-php-8-5#coercing_nan_to_other_types
@aaa2000

Copy link
Copy Markdown
ContributorAuthor

@soyuka There are Two problems:

I've reported the problem in the Doctrine and PHP repository, but it seems that this needs to be handled at the application level. See doctrine/dbal#7249 and php/php-src#20666

  • The Symfony XML Encoder also emits a warning
<?xml version="1.0"?>\n
<response><title>An error occurred</title><detail>Warning: unexpected NAN value was coerced to string in /app/vendor/symfony/serializer/Encoder/XmlEncoder.php line 483</detail><status>500</status><type>/errors/500</type><trace><file>/app/vendor/symfony/serializer/Encoder/XmlEncoder.php</file><line>483</line><function>handleError</function><cl

I created a PR @seesymfony/symfony#62740

I have modified ResourceWithFloat entity and ResourceWithFloat document so that the CI was successful but that doesn't seem like the right solution to me...

@soyuka

Copy link
Copy Markdown
Member

I have modified ResourceWithFloat entity and ResourceWithFloat document so that the CI was successful but that doesn't seem like the right solution to me...

it looks like any user should do these checks so I don't think that there's a better fix then this..

@soyuka
soyuka merged commit 5c9bb34 into api-platform:mainDec 15, 2025
148 of 149 checks passed
@soyuka

Copy link
Copy Markdown
Member

many thanks for this @aaa2000 !

4lxndr pushed a commit to 4lxndr/api-platform-core that referenced this pull request Dec 16, 2025
rvanlaak pushed a commit to rvanlaak/apip-core that referenced this pull request Jan 8, 2026
soyuka pushed a commit to soyuka/core that referenced this pull request Feb 21, 2026
soyuka pushed a commit to soyuka/core that referenced this pull request Feb 22, 2026
soyuka pushed a commit that referenced this pull request Feb 25, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@aaa2000@soyuka