Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112881 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24350 invoked from network); 14 Jan 2021 18:14:13 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Jan 2021 18:14:13 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 42BC61804E3 for ; Thu, 14 Jan 2021 09:52:44 -0800 (PST) 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.5 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,HTML_IMAGE_ONLY_24,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-Virus: No X-Envelope-From: Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (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 ; Thu, 14 Jan 2021 09:52:43 -0800 (PST) Received: by mail-io1-f47.google.com with SMTP id w18so12941945iot.0 for ; Thu, 14 Jan 2021 09:52:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=eCmOQdDMkBQAsMSgvM0uE8K3SuFfPYBo6dAoALK8mbE=; b=pp28SsrACTRFGUoo4D/IxJQX/iNxvLbN2OuGbjJ1k1yJ39qbjFRHQQgSfAY/fE0EMC 7b7H5NPzR6YXMYVmg586I3vX667Jna/rgvCa5jcZQQgS+FsyTa0KjDGuPKmPO0WUDMAM hLZCxrkBYy9Pj+epS8j9pB6NnjtqZyqFMzVaxvMwzDk/ML5o8RVBVtVdrY2eUKVXBLx9 wdErH1t+/UdSiTMzfPvUee4BO866MabZQE5D76vyBjxrhQ2ZOq59eQsxhThTp2bUAbhF jFDpTZ10Cv7Eg74N3Wvf9AR2z2dQhWofY9kzKVHDgSGDhQwSu4zohyC5rImOte5Neg3s CUew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=eCmOQdDMkBQAsMSgvM0uE8K3SuFfPYBo6dAoALK8mbE=; b=JgpBrT2QIhc+0PQjA7JxBexwGgebnbAppv66D28qbkV8ZJFW4B0/v0yxi9wxSoonTC K9m9QGlgAWBfnG4gLj/2S88FFhmi33Nlc/NGfueVfby1mGazMMxoOwRgZZ5GkYSXYSrO pVKzwBA9ObKcHUDpctR5O77fonWOtTWuXSLbjvDfhRfKpiSsD6wBgvMjVI4Shlq6igSg B5HHdAJLxyliHpm2csFtobFA7qbRq8wgrj3r6snH9PTRrG++8uq+1o91/v7bDljRo72C Xq5SiwLIlxe7NcPcKsG5zmpROIcy51TJpJlCSOGf+7ayw3/vSOZKf8J6Ar02+ZBbSc+T Uoag== X-Gm-Message-State: AOAM532A6Gs8k0VFqB2Zm6yWY/VEtfNnzAjyTS8rhBedmQUcKkjd/1j2 3mTOpuaadn2q/j8Cpi6W7fwzBpedC4G0IzSUxF5LqlHz+j6jwg== X-Google-Smtp-Source: ABdhPJySWNFCamp935PkQaRfVR9H9qtm91a5LEXPC8fScCPKoRzgQYVzMXxEC9Smq9D8Jgg1Aq7ugvK3N9SWIH5IW9E= X-Received: by 2002:a05:6638:c52:: with SMTP id g18mr7260447jal.84.1610646760988; Thu, 14 Jan 2021 09:52:40 -0800 (PST) MIME-Version: 1.0 Date: Thu, 14 Jan 2021 11:52:24 -0600 Message-ID: To: PHP internals Content-Type: multipart/related; boundary="0000000000000d168c05b8dfece0" Subject: Feature Proposal From: browner12@gmail.com (Andrew Brown) --0000000000000d168c05b8dfece0 Content-Type: multipart/alternative; boundary="0000000000000d168a05b8dfecdf" --0000000000000d168a05b8dfecdf Content-Type: text/plain; charset="UTF-8" This is my first foray into PHP internals, so please let me know if I'm doing something wrong. Currently just following the instructions from https://wiki.php.net/rfc/howto. Currently this proposal is only a "concept". I propose we add a "default" keyword that can be passed as an argument into a function/method call. This would allow the calling code to defer to the function signature for the value of a parameter. Traditionally, all optional parameters are placed towards the end of the function parameter list, but as we all know, sometimes this order can be tricky. So if some calling code wants to override a later parameter, it currently needs to pass a value to the earlier optional parameters. A current solution around this is to define all defaults in the body of the function rather than in the signature. [image: Screen-Shot-2021-01-14-at-11.45.09-AM.jpg] However, this adds some extra boilerplate, and we can't use default parameters as they were really intended. My proposal is to add a new `default` keyword to be passed as an argument. [image: Screen-Shot-2021-01-14-at-11.44.57-AM.jpg] The first call of the function here is how we currently have to do things. We have to explicitly pass `true` in as the second parameter. However, in the second call, we now use the new `default` keyword, which will defer to the function signature for the default value of `$param2`. Thanks all, looking forward to some feedback! -- Andrew M. Brown --0000000000000d168a05b8dfecdf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This is my first foray into PHP internals, so please = let me know if I'm doing something wrong. Currently just following the = instructions from=C2=A0https://wiki.php.net/rfc/howto.

Curre= ntly this proposal is only a "concept".

= I propose we add a "default" keyword that can be passed as an arg= ument into a function/method call. This would allow the calling code to def= er to the function signature for the value of a parameter.

Traditionally, all optional parameters are placed towards the end = of the function parameter list, but as we all know, sometimes this order ca= n be tricky. So if some calling code wants to override a later parameter, i= t currently needs to pass a value to the earlier optional parameters.
=

A current solution around this is to define all default= s in the body of the function rather than in the signature.

<= /div>3D"Screen-Shot-2021-01-14-at-11.45.0=

However, thi= s adds some extra boilerplate, and we can't use default parameters as t= hey were really intended.

My proposal is to add a = new `default` keyword to be passed as an argument.

3D"Screen-Shot-2021-01-14-at-11.44.57-AM=

The fi= rst call of the function here is how we currently have to do things. We hav= e to explicitly pass `true` in as the second parameter.

However, in the second call, we now use the new `default` keyword, wh= ich will defer to the function signature for the default value of `$param2`= .

Thanks all, looking forward to some feedback!

--
Andrew M. Brown
--0000000000000d168a05b8dfecdf-- --0000000000000d168c05b8dfece0--