Skip to content

Conversation

W0rma
Copy link
Contributor

@W0rma W0rma commented Aug 11, 2025

Description

As of PHP 8.1.0, calling this method has no effect; all methods are invokable by default.

(https://www.php.net/manual/en/reflectionmethod.setaccessible.php and https://www.php.net/manual/en/reflectionproperty.setaccessible.php).

There're even plans to deprecate the method in PHP 8.5: https://wiki.php.net/rfc/deprecations_php_8_5#extreflection_deprecations

Type of change

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • Unit tests

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes a deprecated call to ReflectionProperty::setAccessible() which is no longer needed as of PHP 8.1.0, where all reflection methods are invokable by default. The change helps future-proof the codebase against the planned deprecation in PHP 8.5.

  • Removes redundant setAccessible(true) call from reflection property access

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

$idProperty = $reflection->getProperty($this->userIdField);
$idProperty->setAccessible(true);

$value = $idProperty->getValue($user);
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

Removing setAccessible(true) may cause issues when accessing private or protected properties in PHP versions prior to 8.1. Consider checking the PHP version or handling potential ReflectionException when accessing non-public properties.

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

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

Will this cause any problems for older versions of PHP that may be using this library?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to https://github.com/Unleash/unleash-client-symfony/blob/main/composer.json#L12 this package requires at least PHP 8.2.

Do we still need to check for older versions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's automatically transpiled for older versions, this runs on 7.3 as well.

@RikudouSage
Copy link
Collaborator

RikudouSage commented Aug 13, 2025

This can't be merged, the code is transpiled all the way down to 7.3 where it would cause issues if merged.

See for example the 7.3 branch.

@github-project-automation github-project-automation bot moved this from New to Done in Issues and PRs Aug 13, 2025
@W0rma W0rma deleted the reflection-set-accessible branch August 14, 2025 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants