Skip to content

PHP 8.5 | TestUtils: prevent deprecation notice for Reflection*::setAccessible()#695

Merged
jrfnl merged 2 commits into
developfrom
feature/fix-test-runtime-deprecations-php-8.5
Aug 9, 2025
Merged

PHP 8.5 | TestUtils: prevent deprecation notice for Reflection*::setAccessible()#695
jrfnl merged 2 commits into
developfrom
feature/fix-test-runtime-deprecations-php-8.5

Conversation

@jrfnl

@jrfnl jrfnl commented Aug 9, 2025

Copy link
Copy Markdown
Member

PHP 8.5 | TestUtils: prevent deprecation notice for Reflection*::setAccessible()

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

PHP 8.5 | Tests: prevent deprecation notice for Reflection*::setAccessible()

Do the same for uses of Reflection*::setAccessible() within our own test suite.

jrfnl added 2 commits August 10, 2025 01:00
…ccessible()

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.1.x Next milestone Aug 9, 2025
@jrfnl jrfnl merged commit 89ec9b4 into develop Aug 9, 2025
70 checks passed
@jrfnl jrfnl deleted the feature/fix-test-runtime-deprecations-php-8.5 branch August 9, 2025 23:45
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.

1 participant