Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110007 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4207 invoked from network); 5 May 2020 17:03:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 May 2020 17:03:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4F2C81804D3 for ; Tue, 5 May 2020 08:38:33 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 5 May 2020 08:38:32 -0700 (PDT) Received: by mail-io1-f48.google.com with SMTP id 19so2376975ioz.10 for ; Tue, 05 May 2020 08:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XbbuxtVi0F+vRgl49k62Q/tB+HxkdWruau657pr/T1U=; b=kF2jl3DlNKDy+1EOc+3GZu9AFGtbR34nZdj4mw4D5Z02Fg7GqThF9YFTW9AFUQjYUr vrnaQV2NpmWlcEE6GkB293pMiptOYpNtdGTxtRnlYQGfaiHGVt02Cfdy7oG8ZXh5bUFa YJ/hWbsd7sJcRErst9t7UPwoy3ECgv3XQYooqbJ0ZPjbqE53bUjSukDDWEqDdhD6vseC FOQFud4Vs3DwiGGKPndSBVR74gPwb4ufSXC1khFspp6RwQ87rKQ0cRC0dbFZf/bvX0V7 8niUKRX6z924ZK+pnr8a+JJdQtnvpmkbg2SBhjV2A6QVEAoufbJ/ecGaMRtlrCBge/H7 wMXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XbbuxtVi0F+vRgl49k62Q/tB+HxkdWruau657pr/T1U=; b=k1aksy/n8OZlYvlq7UXI3UUdeus1pFlTZvEkI/NOFaWXaRnm4so6ePAOV/Q7V5AFvT BjmAkl3aE6qDmeQbTJpGrx7gD9lb0ays0S7CPQS6g6hbRhpRIdXuzq44cLHNdbksmuWW jKIFgGIzCCiWOVNUlAoVw/2c3iHdw5PendotcoQlit4L6Xz/S44hfTcrUImNv65defG/ bFKmvShcu24dxcIO/s4Dei3HKoFwmmvCxl7yXgFv0mcSCLb5OdEPA+1Hd24jRnlz8Ocp 9nX6Nxi8Co1JQ8Sv1hhLPpGMS64lu3y5K6l4GcVZnB81S0fZMv2UW4HRN30DWHK6cdHU FCCg== X-Gm-Message-State: AGi0Pua09zVv2zZ4137IhAgLKbo8YmBkvqa82GS6dnkmaVdI99Tr9YKT s+QOriE59MUL4smxLvhzcDkjULpBAsKuKgyHxUMR1TMDRE8= X-Google-Smtp-Source: APiQypKwpCEUZbngkBOchnu+Ilt2yEV+FYX44nE4GatNXvN7WLKki8nodFvM8a59yOXq4UZvoELcHMRiu4nR05c39RE= X-Received: by 2002:a5e:9703:: with SMTP id w3mr4035036ioj.111.1588693110806; Tue, 05 May 2020 08:38:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 5 May 2020 17:38:19 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="00000000000086e40a05a4e87012" Subject: Re: [PHP-DEV] [RFC] Named arguments From: ocramius@gmail.com (Marco Pivetta) --00000000000086e40a05a4e87012 Content-Type: text/plain; charset="UTF-8" Hey Larry, On Tue, May 5, 2020 at 5:29 PM Larry Garfield wrote: > The biggest use case I see is, as discussed previously, value object > constructors. "Pass an entirely untyped and undocumentable array of > parameters" is not an sufficient userland solution in my mind, but is the > only available alternative right now. > This is easily mitigated by named constructors ( https://verraes.net/2014/06/named-constructors-in-php/), which are a good/established practice among those using value objects. You can create multiple (meaningful) constructor signatures depending on use-case, which is still a much safer approach than delegating this responsibility to a caller. My example above uses a `::fromArray()` "factory" precisely for that purpose. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --00000000000086e40a05a4e87012--