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 ReflectionClass::newLazyGhost of PHP 8.4 #11652

Draft
wants to merge 2 commits into
base: 3.3.x
Choose a base branch
from

Conversation

beberlei
Copy link
Member

@beberlei beberlei commented Oct 9, 2024

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.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 properites only when accessed.

Todos

  • Due to property hooks and lazy initialization interactions, this PR also needs to make sure we replace all ReflectionProperty::getValue calls with ReflectionProperty::getRawValue and ReflectionProperty::setValue with ReflectionProperty::setValueWithoutLazyInitialization.
  • Move from ClassMetadata::$reflFields to a new abstraction PropertyAccessor that avoids us having to extend ReflectionProperty for our edge cases (enums, typed no default, embedded, ....).

Future

As a next step this also allows us to implement a feature to mark properties as lazy, meaning that they are never fully fetched on the first query unless specify in the query (query hint? dql keyword?).

@beberlei beberlei changed the title Add support for Reflection lazy ghos Add support for ReflectionLazyGhost Oct 9, 2024
@beberlei beberlei changed the title Add support for ReflectionLazyGhost Add support for ReflectionClass::newLazyGhost of PHP 8.4 Oct 10, 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.

1 participant