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

Add support for PHP 8.4 Lazy Objects RFC with configuration flag #11853

Open
wants to merge 15 commits into
base: 3.4.x
Choose a base branch
from

Conversation

beberlei
Copy link
Member

@beberlei beberlei commented Feb 27, 2025

Our goal is that we can completely replace all kinds of code for proxy generation and proxy usage with the new lazy objects feature of PHP 8.4: https://wiki.php.net/rfc/lazy-objects

In 3.4.x we can add support for optionally using lazy objects, and in 4.x we increase the requirement for PHP to 8.4 and automatically always use lazy objects.

The benefit of lazy objects is that we don't need code-generation anymore, and that it also allows us to treat partial objects as lazy objects that can load their missing properties only when accessed.

See #11659 for prerequisites of using new Reflection APIs.

Use:

$config = new \Doctrine\ORM\Configuration();
$config->enableNativeLazyObjects(true);

To run tests with this ENABLE_NATIVE_LAZY_OBJECTS=1 php vendor/bin/phpunit.

@beberlei beberlei changed the title Reflection lazy ghost 3.4.x Add support for PHP 8.4 Lazy Objects RFC with configuration flag Feb 27, 2025
… expensive and could lead to errors. Adjust lifecycle test that uses transient properittes for assertions.
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Well done!

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Well done, so happy it works this seamlessly :)
I agree with @GromNaN : the term proxy is now inaccurate; this uses the ghost strategy, no proxy is involved.

@beberlei beberlei requested a review from greg0ire February 28, 2025 20:44
…t required anymore with native lazy objects.
@greg0ire
Copy link
Member

greg0ire commented Mar 8, 2025

@jaapio the docs build suddenly fails, what should we do?

@jaapio
Copy link

jaapio commented Mar 8, 2025

You need to update phpDocumentor/filesystem. As this is an unexpected breaking change. But it's fixed when you update the package.

@greg0ire
Copy link
Member

greg0ire commented Mar 8, 2025

I made doctrine/.github#60 from my phone 📱

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.

6 participants