Skip to content

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Aug 10, 2025

Since PHP 8.1, calling the Reflection*::setAccessible() methods is no longer necessary as reflected properties/methods/etc will always be accessible. However, the method calls are still needed for PHP < 8.1.

As of PHP 8.5, calling the Reflection*::setAccessible() methods is now formally deprecated and will yield a deprecation notice, which will fail test runs. As of PHP 9.0, the setAccessible() method(s) will be removed.

With the latter in mind, this commit prevents the deprecation notice by making the calls to setAccessible() conditional.

Silencing the deprecation would mean, this would need to be "fixed" again come PHP 9.0, while the current solution should be stable, including for PHP 9.0.

Ref: https://wiki.php.net/rfc/deprecations_php_8_5#extreflection_deprecations

…sible()

Since PHP 8.1, calling the `Reflection*::setAccessible()` methods is no longer necessary as reflected properties/methods/etc will always be accessible.
However, the method calls are still needed for PHP < 8.1.

As of PHP 8.5, calling the `Reflection*::setAccessible()` methods is now formally deprecated and will yield a deprecation notice, which will fail test runs.
As of PHP 9.0, the `setAccessible()` method(s) will be removed.

With the latter in mind, this commit prevents the deprecation notice by making the calls to `setAccessible()` conditional.

Silencing the deprecation would mean, this would need to be "fixed" again come PHP 9.0, while the current solution should be stable, including for PHP 9.0.

Ref: https://wiki.php.net/rfc/deprecations_php_8_5#extreflection_deprecations
@jrfnl jrfnl added this to the 1.x Next Release milestone Aug 10, 2025
@jrfnl jrfnl requested a review from grogy August 10, 2025 03:25
Copy link
Member

@grogy grogy left a comment

Choose a reason for hiding this comment

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

Thanks!

I am thinking if this type of running method with and operator is good readable, but I will let it.

@grogy grogy merged commit 68cf19b into master Sep 14, 2025
39 checks passed
@grogy grogy deleted the feature/fix-test-runtime-deprecations-php-8.5 branch September 14, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants