Skip to content

Conversation

@kitsunet
Copy link
Member

Totally sneak peek, if someone interested. Ideally this should just work if applied.

kitsunet and others added 10 commits September 8, 2025 22:29
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.
@github-actions github-actions bot added the 9.1 label Oct 22, 2025
@kitsunet
Copy link
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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants