On Tue, 18 Feb 2025 at 12:45, Sebastian Bergmann <sebast...@php.net> wrote:
> Am 18.02.2025 um 09:00 schrieb Rowan Tommins [IMSoP]: > > named constructors make a lot more sense than type-based overloads > > +1 > Hi, Viktor. I agree with others that named static constructors are much better than overloading of the primary constructor. Regardless of whether it is possible in PHP or not. Even for Java that supports overloading, Robert Martin recommends factory methods in his book "Clean code": "Prefer static factory methods (with names that describe the arguments) to overloaded constructors." Also see this discussion: https://stackoverflow.com/questions/628950/constructors-vs-factory-methods -- Valentin