Skip to content

Forward $hooks through fragment-spread getters#45

Merged
ruudk merged 1 commit intomainfrom
fix
Apr 18, 2026
Merged

Forward $hooks through fragment-spread getters#45
ruudk merged 1 commit intomainfrom
fix

Conversation

@ruudk
Copy link
Copy Markdown
Owner

@ruudk ruudk commented Apr 18, 2026

PR #43 taught data classes to accept and store $hooks, and the planner marks every transitive parent as hook-using -- but the fragment-spread getter templates in DataClassGenerator kept hard-coding new Child($this->data), so the stored hooks never reached the child. PHPStan flagged each intermediate class with arguments.count on the child constructor and property.onlyWritten on its own $hooks property.

Delegate the constructor expression to $typeInitializer, which already consults ClassHookUsageRegistry via ObjectTypeInitializer, instead of rebuilding new X(...) by hand in four places.

PR #43 taught data classes to accept and store $hooks, and the planner
marks every transitive parent as hook-using -- but the fragment-spread
getter templates in DataClassGenerator kept hard-coding
`new Child($this->data)`, so the stored hooks never reached the child.
PHPStan flagged each intermediate class with arguments.count on the
child constructor and property.onlyWritten on its own $hooks property.

Delegate the constructor expression to $typeInitializer, which already
consults ClassHookUsageRegistry via ObjectTypeInitializer, instead of
rebuilding `new X(...)` by hand in four places.
@ruudk ruudk merged commit 09b3e20 into main Apr 18, 2026
3 checks passed
@ruudk ruudk deleted the fix branch April 18, 2026 13:22
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