Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113467 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60709 invoked from network); 11 Mar 2021 08:52:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Mar 2021 08:52:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4B2D81804B4 for ; Thu, 11 Mar 2021 00:45:06 -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=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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, 11 Mar 2021 00:45:05 -0800 (PST) Received: by mail-wr1-f49.google.com with SMTP id h98so850511wrh.11 for ; Thu, 11 Mar 2021 00:45:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:from:message-id; bh=qFKmBJn92S4xjevfLneNMe47Eh4Bnce/VfefcktI9y4=; b=nOitvfRszTcRMnJG2jU1AW0id7RQWz3Xzv36Dn6K6jRv7hzbxXGXTKhlC/dCcbP9HI qEBUHeU2DDW27i84qrNZ9DhWeoxioZt3l+T/LMJaBodyHbLfmeartxdCezxVzG0Jh5Rn wGTaaxRHz6ciHBWqhUDGWQdFQl9IaW2sulcITO/Wv+c7aOYhiIYXEMu1hRRYScjuavVc 5ScnhatEb/glM4AplOv7tEoypBh2UraLjjkaJHMFOaHd4mqC7jPWO9wvervaODF884wZ qtwrUWk0ei9Wy7nfiQyD8B5viEmPB/XvAVPIYB5PN2yhS6yDnV46rPDZIKl+c70Kgblv 2DSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=qFKmBJn92S4xjevfLneNMe47Eh4Bnce/VfefcktI9y4=; b=BjniVQhGdX/kBISEn01VWhwYf0gdBG8mIaLfYMfyFqlaP4zVnaobKj/3WKS5A6/SO/ jtFQlD6+J1bWHWpRZW1WEgZs4knHkMUXbvZzZJUh53k5mntwm0jzy1M66Q5kNXO0t/OT K6x/svh6Xosg9BtQH6BOUHJchwPX/hQLoFuNZ5FaIwChHPSKaSPmboVziDgDMI7K0lVx Mv1pbrQYa/MAbphd0jTuMvHSOvvV0z3Xn4fTwXEyOADuT6TFC4Kb8W+XHTchcpu1bW+m 4ZDUhkPNcBMmUvN/40avHd04OyI46umko/9Gvsv8Dy3vVGYAEbQFAui5GwAAp4vEWGFw gQ0A== X-Gm-Message-State: AOAM533zmuiYWZrbszqass+0a3Wh24rM2KQd05ALtd+y/GR/OpjIbqTz it29wMZGA8YHLtMdraH4fvp6hbXZPCE= X-Google-Smtp-Source: ABdhPJxK4OlFNg4HyWnJOilMiHAuPrQA1RwU1AzY3IAx+ivppIiekX/RcsZqtZQHuaTqJGp1LwCP+w== X-Received: by 2002:adf:84e6:: with SMTP id 93mr7114411wrg.376.1615452304642; Thu, 11 Mar 2021 00:45:04 -0800 (PST) Received: from [192.168.0.27] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.gmail.com with ESMTPSA id c11sm2719916wrm.67.2021.03.11.00.45.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Mar 2021 00:45:04 -0800 (PST) Date: Thu, 11 Mar 2021 08:45:04 +0000 User-Agent: K-9 Mail for Android In-Reply-To: <01fa01d71627$edb078a0$c91169e0$@gmail.com> References: <01fa01d71627$edb078a0$c91169e0$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net Message-ID: <0DC08797-11DD-4D45-8C43-5678822DA259@gmail.com> Subject: Re: [PHP-DEV] Honour the Default Value of 'return' Statement According to the Function Signature From: rowan.collins@gmail.com (Rowan Tommins) On 11 March 2021 03:37:52 GMT, office=2Ehamzaahmad@gmail=2Ecom wrote: >function get_nationality_string(int $country_code) : string | "unknown" >{ > return; >}; If I understand you correctly, your idea is that the "return;" here would = be treated automatically as "return 'unknown';" I think that's an interesti= ng idea, although I can't immediately think of a situation where I'd use it= =2E My main concerns are with the syntax: - Firstly, specific literals aren't currently allowed in return types, and= allowing them would have other implications=2E Three exception is "false",= which is allowed because of its common use as an error code, including in = many internal functions=2E - Secondly, it could be ambiguous which is intended to be the default valu= e, if the return type was something like int|"yes"|"no" Perhaps the default return value would need to be specified separately fro= m the return type somehow? Regards, Hi Hamza, Welcome to the list, and thanks for sharing this idea=2E --=20 Rowan Tommins [IMSoP]