Skip to content

[Form][PhpUnitBridge] Remove usage of noop ReflectionProperty::setAccessible() #61207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

NickSdot
Copy link
Contributor

@NickSdot NickSdot commented Jul 22, 2025

Q A
Branch? 6.4
Bug fix? no
New feature? no
Deprecations? no
Issues -
License MIT

As of PHP 8.1.0, calling this method has no effect; all properties are accessible by default. Symfony 7.x requires PHP 8.2+.

https://www.php.net/manual/en/reflectionproperty.setaccessible.php

Notes:

  • Component/ErrorHandler/Internal/TentativeTypes.php is auto-generated, didn't touch it.
  • targeted 7.3 because support for 7.2 ends in a few days.
  • now targets 6.4

@NickSdot NickSdot requested review from xabbuh and yceruto as code owners July 22, 2025 18:59
@carsonbot carsonbot added this to the 7.3 milestone Jul 22, 2025
@OskarStark OskarStark changed the title chore: removed usage of noop ReflectionProperty::setAccessible() Remove usage of noop ReflectionProperty::setAccessible() Jul 22, 2025
@carsonbot carsonbot changed the title Remove usage of noop ReflectionProperty::setAccessible() [Form][PhpUnitBridge] Remove usage of noop ReflectionProperty::setAccessible() Jul 22, 2025
@NickSdot
Copy link
Contributor Author

  • fabbot failures are unrelated.
  • windows failure should be unrelated?

@alexandre-daubois
Copy link
Member

alexandre-daubois commented Jul 23, 2025

Refactors like this one generally target the feature branch (7.4 at this time). Only bug fixes are pushed to 7.3 (and below), so given setAccessible() is no-op, I'd target 7.4.

And indeed, you can safely ignore fabbot recommendations and Windows failures, which are not related to your pull request.

@NickSdot
Copy link
Contributor Author

Refactors like this one generally target the feature branch (7.4 at this time). Only bug fixes are pushed to 7.3 (and below), so given setAccessible() is no-op, I'd target 7.4.

And indeed, you can safely ignore fabbot recommendations and Windows failures, which are not related to your pull request.

Hey Alexandre, thanks for the input! Before I change the target branch, here my rational why I believe it should be in 7.3. This RFC (vote pending) seeks to deprecate the usage in PHP 8.5. If the vote goes through, what I believe based on the internals list discussion, it would unneccessarily spam depcrecation warnings. I agree, it's not a bug, but I think it's a worthy "fix" to have in all supported versions. Wdyt?

@alexandre-daubois
Copy link
Member

alexandre-daubois commented Jul 23, 2025

Ah yes, I missed this one. Makes sense then 👍 If these lines are also present in earlier versions, it might be a good idea to even target 6.4, so it is also compatible with upcoming 8.5 and doesn't trigger deprecations on release.

@NickSdot NickSdot force-pushed the chore-setAccessible branch from 072c2b0 to 5623395 Compare July 23, 2025 14:55
@NickSdot NickSdot changed the base branch from 7.3 to 6.4 July 23, 2025 14:56
@NickSdot
Copy link
Contributor Author

NickSdot commented Jul 23, 2025

Done. 6.4 had a few more. Updated and target branch changed!

Edit: I am a bit confused about the test suite here. 😅 Again not related? If there is anything I must do, please let me know.

@nicolas-grekas nicolas-grekas modified the milestones: 7.3, 6.4 Jul 24, 2025
@nicolas-grekas
Copy link
Member

Thank you @NickSdot.

@nicolas-grekas nicolas-grekas merged commit 4af9890 into symfony:6.4 Jul 24, 2025
9 of 12 checks passed
@NickSdot NickSdot deleted the chore-setAccessible branch July 24, 2025 08:26
@@ -86,7 +86,6 @@ public function startTest(Test $test): void
private function addCoversForClassToAnnotationCache(Test $test, array $covers): void
{
$r = new \ReflectionProperty(TestUtil::class, 'annotationCache');
$r->setAccessible(true);
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to revert the changes made to the PHPUnit bridge as it supports PHP 7.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why does/would the PhpUnit bridge in Symfony 6.4, which requires PHP 8.1, need to support PHP 7?

Copy link
Member

Choose a reason for hiding this comment

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

We have to indeed, my bad for missing that!
The bridge on 7.4 is the one that's bumped to PHP >= 8.1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So back to where we been yesterday? I target 7.4 for the full changes, and 6.4 for everything but bridge?

Copy link
Member

Choose a reason for hiding this comment

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

I added these calls back in 0270060 and removed them again when merging branches up in 72ccba7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants