-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
beberlei
wants to merge
2
commits into
doctrine:3.3.x
Choose a base branch
from
beberlei:ReflectionLazyGhost-3.3.x
base: 3.3.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beberlei
changed the title
Add support for Reflection lazy ghos
Add support for ReflectionLazyGhost
Oct 9, 2024
beberlei
changed the title
Add support for ReflectionLazyGhost
Add support for ReflectionClass::newLazyGhost of PHP 8.4
Oct 10, 2024
6 tasks
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
GromNaN
reviewed
Jan 21, 2025
@@ -3049,6 +3060,10 @@ public function initializeObject(object $obj): void | |||
*/ | |||
public function isUninitializedObject(mixed $obj): bool | |||
{ | |||
if ($this->em->getConfiguration()->isLazyProxyEnabled() && ! ($obj instanceof Collection)) { | |||
return $this->em->getClassMetadata(get_class($obj))->reflClass->isUninitializedLazyObject($obj); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
return $this->em->getClassMetadata(get_class($obj))->reflClass->isUninitializedLazyObject($obj); | |
return $this->em->getClassMetadata($obj::class)->reflClass->isUninitializedLazyObject($obj); |
@@ -939,7 +938,6 @@ public function testResolveAssociationCacheEntry(): void | |||
self::assertNotNull($state1->getCountry()); | |||
$this->assertQueryCount(1); | |||
self::assertInstanceOf(State::class, $state1); | |||
self::assertInstanceOf(InternalProxy::class, $state1->getCountry()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful to have a BaseTestCase::isLazyObject
function for this assertion, I did one for MongoDB ODM.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
ClassMetadata::$reflFields
to a new abstractionPropertyAccessor
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?).