Skip to content

chore: do not call Reflection*::setAccessible() in PHP >= 8.1#8907

Merged
kubawerlos merged 2 commits intoPHP-CS-Fixer:masterfrom
W0rma:reflection-set-accessible
Aug 2, 2025
Merged

chore: do not call Reflection*::setAccessible() in PHP >= 8.1#8907
kubawerlos merged 2 commits intoPHP-CS-Fixer:masterfrom
W0rma:reflection-set-accessible

Conversation

@W0rma
Copy link
Copy Markdown
Contributor

@W0rma W0rma commented Aug 2, 2025

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

@coveralls
Copy link
Copy Markdown

coveralls commented Aug 2, 2025

Coverage Status

coverage: 94.726% (+0.004%) from 94.722%
when pulling de15026 on W0rma:reflection-set-accessible
into f89c7d3 on PHP-CS-Fixer:master.

Comment thread src/Error/SourceExceptionFactory.php Outdated
Comment thread src/Error/SourceExceptionFactory.php Outdated
Co-authored-by: Gregor Harlan <mail@gh01.de>
@kubawerlos kubawerlos changed the title chore: Do not call Reflection*::setAccessible() in PHP >= 8.1 chore: do not call Reflection*::setAccessible() in PHP >= 8.1 Aug 2, 2025
@kubawerlos kubawerlos merged commit 9e141f5 into PHP-CS-Fixer:master Aug 2, 2025
31 checks passed
@kubawerlos
Copy link
Copy Markdown
Member

Thank you @W0rma

@W0rma W0rma deleted the reflection-set-accessible branch August 2, 2025 11:12
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.

4 participants