Remove remaining usage of setAccessible()

Created on 8 August 2025, 13 days ago

Problem/Motivation

The Reflection*::setAccessible() is deprecated and throws deprecation warning since PHP 8.5 beta1.
General usage was removed in πŸ“Œ Remove usage of setAccessible() when core requires PHP 8.1 Fixed

Steps to reproduce

- https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionsetacc...
- https://github.com/php/php-src/commit/922c225fbf1a5a7a2e43ebfdff8d91ad91...

Proposed resolution

- remove remaining usage

Remaining tasks

MR, review, commit

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡«πŸ‡·France andypost

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @andypost
  • πŸ‡«πŸ‡·France andypost

    Usage is

    core$ git grep setAccessible
    core/tests/Drupal/Tests/Component/Plugin/Attribute/AttributeClassDiscoveryCachedTest.php:70:    $ref_file_cache->setAccessible(TRUE);
    core/tests/Drupal/Tests/Component/Plugin/Attribute/AttributeClassDiscoveryCachedTest.php:128:    $ref_file_cache->setAccessible(TRUE);
    core/tests/Drupal/Tests/Component/Plugin/Attribute/AttributeClassDiscoveryTest.php:51:    $reflection->setAccessible(TRUE);
    core/tests/Drupal/Tests/Core/Entity/Access/EntityCreateAccessCustomCidTest.php:100:    $access_cache->setAccessible(TRUE);
    core/tests/Drupal/Tests/Core/Field/FieldTypePluginManagerTest.php:75:    $property->setAccessible(TRUE);
    core/tests/Drupal/Tests/Core/Theme/Icon/IconFinderTest.php:647:    $method->setAccessible(TRUE);
    core/tests/Drupal/Tests/Core/Theme/Icon/IconFinderTest.php:661:    $method->setAccessible(TRUE);
    core/tests/Drupal/Tests/Core/Theme/Icon/IconFinderTest.php:674:    $method->setAccessible(TRUE);
    core/tests/Drupal/Tests/Core/Theme/Icon/IconFinderTest.php:688:    $method->setAccessible(TRUE);
    core/tests/Drupal/Tests/Core/Theme/Icon/IconFinderTest.php:702:    $method->setAccessible(TRUE);
    core/tests/Drupal/Tests/Core/Theme/Icon/IconFinderTest.php:768:    $method->setAccessible(TRUE);
    core/tests/Drupal/Tests/Core/Theme/Icon/IconFinderTest.php:778:    $method->setAccessible(TRUE);
    
  • @andypost opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    pretty straight forward, searched for setAccessible() and found 12 instances all covered by the MR.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Committed and pushed 967e3af639f to 11.x and d6d4d9cd564 to 11.2.x. Thanks!

    • alexpott β†’ committed d6d4d9cd on 11.2.x
      Issue #3540525 by andypost: Remove remaining usage of setAccessible()
      
      (...
Production build 0.71.5 2024