-
-
Notifications
You must be signed in to change notification settings - Fork 190
Task/constructor injection objectmanager #3510
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
Draft
kitsunet
wants to merge
11
commits into
neos:9.1
Choose a base branch
from
kitsunet:task/constructor-injection-objectmanager
base: 9.1
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.
Draft
Task/constructor injection objectmanager #3510
kitsunet
wants to merge
11
commits into
neos:9.1
from
kitsunet:task/constructor-injection-objectmanager
+1,438
−1,335
Conversation
This file contains hidden or 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
Props to @lorenzulrich for this correct fix, which always gets the parent in relation to the method being called and not the parent of the instance at hand. Fixes: neos#3406
This allows classes without constructor injection to have a proper constructor signature.
This is an overhaul of how object serialization is prepared in proxies. Proxies can skip object serialization code if there is nothing to serialize, that is, if there are no entity properties, no injected, or transient properties. We were too eager prior to this patch with not using the serialization code, the checks are now way more detailed. Additionally the "Proxy" Annotation now allows to force serialization code for a class if the checks still fail to detect correctly, this should be rarely needed. This fix however broke some code in Neos that should have gotten the serialization code previously but didn't. Since the class in question is readonly, injecting a mutable property via trait resulted in PHP errors. Therefore we now use a mutable object to hold related entities for serialization purposes which is declared readonly in the proxy to avoid errors with readonly classes should they need serialization code. Other mutable properties were removed as they are not strictly needed. We should do the same refactoring for AOP as well. Proxies can use the original constructor argument signature if no constructor injection is used. Finally prototype autowiring is now a choice via setting, currently default enabled to not change behavior, in the future we should plan a breaking change to disable it and then remove the option altogether. Fixes: neos#3493 Related: neos#3212 Related: neos#3076
This change enables Flow proxy classes to support PHP 8+ named argument syntax by including the original constructor parameter signature in generated proxies, fixing compatibility issues with modern PHP code and reflection-based serializers. The proxy constructor now always includes parameters matching the original constructor signature, with all parameters made nullable and given null default values to maintain dependency injection flexibility. This allows both named and positional argument syntax while preserving backward compatibility with existing DI patterns. Resolves neos#3076
This also avoids a bug with constructors accepting variadic arguments as they exist in Neos.Neos.
Member
Author
|
Obviously broke the tests with my two class changes to make those unproxied. But then, I am not sure I want to keep those changes in there, it was just for show. |
Code cleanup around proxy building and also showing off some constructor injection for Flow core classes that is now possible.
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.
Totally sneak peek, if someone interested. Ideally this should just work if applied.