Skip to content

Avoid ReflectionMethod::setAccessible() deprecations on PHP 8.5+ in serializer tests - #274

Merged
goetas merged 1 commit into
masterfrom
copilot/do-not-call-setaccessible-on-php-8-5
Aug 18, 2026
Merged

Avoid ReflectionMethod::setAccessible() deprecations on PHP 8.5+ in serializer tests#274
goetas merged 1 commit into
masterfrom
copilot/do-not-call-setaccessible-on-php-8-5

Conversation

Copilot AI commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

PHP 8.5 deprecates ReflectionMethod::setAccessible() (no-op since 8.1), which causes the PHPUnit 8.5 job to fail on deprecation-as-failure. This change removes those deprecations while preserving test behavior on older PHP versions.

  • Scope

    • Updated serializer test helpers that reflect protected methods:
      • test/HTML5/Serializer/TraverserTest.php
      • test/HTML5/Serializer/OutputRulesTest.php
  • Change

    • Guarded setAccessible(true) behind a PHP version check so it is only called where still relevant (< 8.5).
  • Behavior impact

    • On PHP 8.5+: no deprecated setAccessible() calls.
    • On older runtimes: existing reflection access pattern remains unchanged.
$method = $class->getMethod($name);
if (\PHP_VERSION_ID < 80500) {
    $method->setAccessible(true);
}

Co-authored-by: goetas <776743+goetas@users.noreply.github.com>
@goetas
goetas marked this pull request as ready for review August 18, 2026 05:55
@goetas
goetas merged commit aa7ba18 into master Aug 18, 2026
10 checks passed
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.

2 participants