Rob Landers has submitted a PHP RFC for Primary Constructors, a syntax sugar that allows declaring constructor parameters at the class level (e.g., `class Money(public readonly int $amount) {}`). The proposal saves a few lines of boilerplate compared to traditional constructor promotion. Nick Sdot responds critically, arguing the RFC is too limited because it does not support constructor bodies, making it incompatible with readonly classes that need property hooks, and requiring refactoring back to conventional constructors as soon as logic becomes non-trivial. Nick questions whether the minimal gain justifies introducing new syntax with new gotchas, and proposes an alternative syntax that would support full constructor body behavior.

3m read timeFrom externals.io
Post cover image
324 Impressions