externals.io
Read post

[RFC] Primary Constructors

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.

    #php
Jun 29•3m read time•From externals.io
Post cover image
323 Impressions
externals.io's image
externals.io

3 Followers

•

43 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard