Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119203 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 30610 invoked from network); 23 Dec 2022 11:11:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Dec 2022 11:11:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9CA03180511 for ; Fri, 23 Dec 2022 03:11:27 -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.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, T_SCC_BODY_TEXT_LINE 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-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 23 Dec 2022 03:11:27 -0800 (PST) Received: by mail-yb1-f181.google.com with SMTP id j206so4967454ybj.1 for ; Fri, 23 Dec 2022 03:11:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4gw3inblfk+g1dYcwYoH/au1AN/hDbszdfo53kzfYOk=; b=XOozvpVunxQf4HG2YhOo9TPqSHcITdWqFhrsI//dkVCB7t9rY/eIDWchyJytiMh1nJ 1T3cLakxcKu7NVozuawWigxD8kaXDk30xCKHepf8ZNIVeoBiwWd+4UTwwK316NtFmL2a QKZe8w42A95+y3nc4uEpxRoEhcNFTOyYnlX1VLWzvBaZ9Sx5sbAWdurNGVM7xAfg2ovg Kc0O00ewnL13u9YNQ/81BOk7txqSKihcKzl4kUp41v2mISS8D4f0Wp78TmKW8rA6/K9E c+PCs0oJAR7Ri5OdrB5TIRDCEmN8gHemjiA746ddOAtdboROLaOvZEEsBu9VRSDOLYPV CorA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4gw3inblfk+g1dYcwYoH/au1AN/hDbszdfo53kzfYOk=; b=6iDLy+wt3KYtqzDQVLp87CnZq/pbO7cP/JdpZRslQ8SpDiHHyvTwkJZvklmpql70Qj EmccCd9407yFMIQcPSTMGsNIPwF8LytXvbFsgLPNNUtlf07eayEtDrUOVYBgm3IOJoNP KeE+BbduEaU/tWqewtZFnsW+3ixzthDZgm+VvY2zxiNQE4MYXvfs3oNgfSUVm6H7BR1A 9IGlhZQ/8wLt62kpLgMnw3NvRqMBRVsebeZp7MjiKbxHR0UPGoRP36ESuW4U3eS2G+8s oECZPYN/wqD5EoTN+K3zRSroHe5PVgckFoAWiMN1Sy73X2EnNTNht35nKQ3FWfsYCLBW SyRw== X-Gm-Message-State: AFqh2krB0BQU2jrsQmiWtzHOGK/O/ADragHhqwWnQptnHAG6QHqc9Gfs ITZ+h5sgjivSe/bXUAT82qxwqaSlN5XLHq1ImxA= X-Google-Smtp-Source: AMrXdXu2ZSi/nMx/fqDGegYV/vx2iqOxS8m0fdxh3Pr2dQmFUVviDZvj2m2LupeymGlcdBN0WR/qB1f+WK8J2L9JogI= X-Received: by 2002:a5b:387:0:b0:768:2e4c:9799 with SMTP id k7-20020a5b0387000000b007682e4c9799mr358053ybp.481.1671793886522; Fri, 23 Dec 2022 03:11:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 23 Dec 2022 12:10:59 +0100 Message-ID: To: Claude Pache Cc: joke2k , internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000be717a05f07cd809" Subject: Re: [PHP-DEV] Methods which auto-return the class instance From: kjarli@gmail.com (Lynn) --000000000000be717a05f07cd809 Content-Type: text/plain; charset="UTF-8" On Fri, Dec 23, 2022 at 10:33 AM Claude Pache wrote: > > ```php > public function hit(): $this { $this->counter++; } > ``` > > Here, there is only one possible return value, and therefore the `return` > instruction might be reasonably omitted. > > The real question is: Is it worth to add special cases for some specific > return values? > We do have true, false, and null as return types ( https://www.php.net/releases/8.2/en.php#null_false_true_types). I'm personally not opposed to having `$this` as return type, but it also starts getting close to short function notations. --000000000000be717a05f07cd809--