Skip to content

Removes three calls to ReflectionProperty::setAccessible() / ReflectionMethod::setAccessible() in the test suite#942

Draft
masteradhoc wants to merge 4 commits into
WordPress:masterfrom
masteradhoc:remove-setAccessible
Draft

Removes three calls to ReflectionProperty::setAccessible() / ReflectionMethod::setAccessible() in the test suite#942
masteradhoc wants to merge 4 commits into
WordPress:masterfrom
masteradhoc:remove-setAccessible

Conversation

@masteradhoc

@masteradhoc masteradhoc commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

What?

Removes three calls to ReflectionProperty::setAccessible() / ReflectionMethod::setAccessible() for PHP 8.1+ in the test suite.

Fixes #

Why?

See: https://www.php.net/manual/de/reflectionmethod.setaccessible.php

Since PHP 8.1, reflection properties and methods are accessible without calling setAccessible( true ), making the call a no-op. As of PHP 8.5, calling it is deprecated and emits a PHP Deprecated notice, which was showing up as noise in test runs (tests/class-two-factor-core.php:168, :2374, tests/providers/class-two-factor-totp.php:457).

............................................................... 63 / 232 ( 27%) [23-Jul-2026 20:30:55 UTC] PHP Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/wp-content/plugins/two-factor/tests/class-two-factor-core.php on line 168 .......Received a non-notice error: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/wp-content/plugins/two-factor/tests/class-two-factor-core.php on line 168 [23-Jul-2026 20:30:55 UTC] PHP Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/wp-content/plugins/two-factor/tests/class-two-factor-core.php on line 2398 Received a non-notice error: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1Received a non-notice error: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1.Received a non-notice error: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1Received a non-notice error: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1Received a non-notice error: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1...Received a non-notice error: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 Deprecated: Method ReflectionProperty::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/wp-content/plugins/two-factor/tests/class-two-factor-core.php on line 2398 ...................................F................ 126 / 232 ( 54%) ............................................................... 189 / 232 ( 81%) [23-Jul-2026 20:30:57 UTC] PHP Deprecated: Method ReflectionMethod::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/wp-content/plugins/two-factor/tests/providers/class-two-factor-totp.php on line 457 ...................................... Deprecated: Method ReflectionMethod::setAccessible() is deprecated since 8.5, as it has no effect since PHP 8.1 in /var/www/html/wp-content/plugins/two-factor/tests/providers/class-two-factor-totp.php on line 457

How?

Deleted the three now-redundant setAccessible( true ) lines. No behavior change — the reflection objects were already accessible without it.

Use of AI Tools

Testing Instructions

  1. Run the plugin's PHPUnit suite on PHP 8.5.
  2. Confirm the ReflectionProperty::setAccessible() is deprecated / ReflectionMethod::setAccessible() is deprecated notices no longer appear.

Changelog Entry

Fixed - Removed deprecated setAccessible() calls in the test suite to prevent PHP 8.5 deprecation notices.

Open WordPress Playground Preview

Sign up for free to 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.

1 participant