Skip to content
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

Do not initialize lazy objects during export #69

Merged

Conversation

nikophil
Copy link
Contributor

@nikophil nikophil commented Dec 3, 2024

Reason behind this is that if a dataprovider is passed a php 8.4 lazy proxy, the "lazyness" is lost, because of ReflectionObject()->getProperties(), see https://www.php.net/manual/en/language.oop5.lazy-objects.php#language.oop5.lazy-objects.initialization-triggers

@nikophil nikophil marked this pull request as ready for review December 3, 2024 21:32
Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (ddf1579) to head (9c05000).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##                main       #69   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity        60        61    +1     
===========================================
  Files              1         1           
  Lines            185       186    +1     
===========================================
+ Hits             185       186    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nikophil nikophil force-pushed the fix/use-reflection-class branch from e20a38f to 5446448 Compare December 4, 2024 18:19
@nikophil nikophil force-pushed the fix/use-reflection-class branch from 5446448 to 9c05000 Compare December 4, 2024 18:42
@sebastianbergmann
Copy link
Owner

May I ask you to target the 5.1 branch (which is used by PHPUnit 10.5)? Thanks!

@nikophil
Copy link
Contributor Author

nikophil commented Dec 5, 2024

it seems that the problem does not exist in 5.1: there is no usage of ReflectionObject (and method countProperties() does not exist)

@nikophil
Copy link
Contributor Author

nikophil commented Dec 5, 2024

static analysis seems to not understand new php 8.4 lazy stuff 😆

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Dec 5, 2024

static analysis seems to not understand new php 8.4 lazy stuff 😆

Yes, PHPStan runs on PHP 8.4 but does not yet supports its features. @staabm and @ondrejmirtes are workin on it :)

I will take care of ignoring the "issues" in the meantime.

@sebastianbergmann
Copy link
Owner

it seems that the problem does not exist in 5.1: there is no usage of ReflectionObject (and method countProperties() does not exist)

Okay, thanks!

@sebastianbergmann sebastianbergmann merged commit 83e92a6 into sebastianbergmann:main Dec 5, 2024
7 of 8 checks passed
@ondrejmirtes
Copy link

Adding support for PHP 8.4 is gradual. PHPStan already knows about new functions and methods added in PHP 8.4, here's proof: https://phpstan.org/r/22140ef9-ff53-4a33-9655-e8248d342619

I haven't checked precisely but my estimate is that it knows about newLazyProxy and similar method since 2.0.0 (released on November 11th).

The biggest amount of work are going to be property hooks, they will take some time to be implemented :)

@sebastianbergmann sebastianbergmann changed the title fix: use ReflectionClass insteadof ReflectionObject Do not initialize lazy objects during export Dec 5, 2024
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.

3 participants