A PHP internals mailing list thread discussing the proposed Primary Constructors RFC for PHP. The RFC proposes a new syntax allowing class properties to be declared directly in the class signature (e.g., `class Money(public readonly int $amount) {}`), saving a few lines over constructor promotion. Key debate centers on whether primary constructors should support a body for initialization/validation logic. The RFC author (Rob Landers) argues bodies are intentionally excluded and that 30-70% of real-world constructors could benefit even without bodies. Critics (notably Nick Sdot) argue the feature is too limited without body support, won't work well with readonly classes and property hooks, and risks becoming another half-finished PHP feature. Rowan Tommins takes the opposite view, preferring limited shorthands over full-featured alternatives that cause style debates.

1h 18m read timeFrom externals.io
Post cover image
78 Impressions