Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108062 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 75134 invoked from network); 9 Jan 2020 16:35:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Jan 2020 16:35:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 246CB180504 for ; Thu, 9 Jan 2020 06:41:12 -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_H3,RCVD_IN_MSPIKE_WL,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-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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, 9 Jan 2020 06:41:08 -0800 (PST) Received: by mail-ot1-f44.google.com with SMTP id r27so7425838otc.8 for ; Thu, 09 Jan 2020 06:41:08 -0800 (PST) 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=mO4rYVyUtsXdu0aSEFcxbXgERvgDNCu02RUbj11XeLE=; b=O9RAq8CriKeNnunqzAkT9nQwVIAdvOFvyp73qqQqoIfwM6paH/DskcydaVDPg4zbZT RRAVUnmce6C17iitxcLvxqfI2lrZ5hLdhD1b58hAENoVGph9MWkoDK5B5OboICwUn4uh qtEoplDD3sXVJ6wdZIE6lNmzbN3yfCsyCzTrvEHWMKRjYEAKJ+hYHcGZdf1x99DYxvPF C4da0yJhYUQYN58YKjdYjC1/mxBF4roWaOVQyo/mZ8WTU1abGZ3fqfysTjVioDkxcHqI yuQwwfk66UI5GTm3p6KQ9Fc49Wk1O86cnFFDo0j8VtULl3xOgDtiE3DnAzRCWr8j+nIJ /OZg== 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=mO4rYVyUtsXdu0aSEFcxbXgERvgDNCu02RUbj11XeLE=; b=UqiKjNgm29w1c5A+6jVSbTM83QQydVW3d3EUErrA0glsj8lCQkmunfDKTcfVaGHHYd 7/AdFjz0lpn0KBYRvtud0r2C9MA1AGwlSA4vMt1XeIQMqy0LzzEGV3Wy21PNzbszoynX v6hHNNEclj9sEP8uY36Q/e4lo17n9eTZXk5T/oyJ7AUsBDfWfry36Xci4Jr15p2CxKxx K1jlzNzz272/n+UoUe0gq48UgEAQnCyaTXLwXojq1mPnZXYu6M4VxXq/1GEdrC+jev9H r5zk35XIJ3A4KZPdq6DMmKoo0XPAWdrGQ39ytenzAA3CTPY2T49ySNBDvgU0hINuT+r5 L25g== X-Gm-Message-State: APjAAAU2WdLXtRa7JQTSeKtvFDJr97KzxANvQ7E0T2jS9BJDmE4IUfri +xfB0xp3QSksIWXHd0ZAwkfsAxXYXv5PPTFMCCw= X-Google-Smtp-Source: APXvYqyLmAVntHZCmNol5G92PcaYDSAg3oNgOv6KTY0sb8OyisiI9wdPUhtU8t6FAREHZtuK8Kme20tslmbhKxawxeQ= X-Received: by 2002:a05:6830:1e37:: with SMTP id t23mr8851521otr.16.1578580866737; Thu, 09 Jan 2020 06:41:06 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 9 Jan 2020 15:40:54 +0100 Message-ID: To: Nikita Popov Cc: php internals , Andreas Hennings Content-Type: multipart/alternative; boundary="000000000000cfad04059bb5ffd8" Subject: Re: [PHP-DEV] [RFC] Static return type From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000cfad04059bb5ffd8 Content-Type: text/plain; charset="UTF-8" > Of course this ": $this" could be added later in the future. > But this would have the risk that people start adding ": static" on methods > that really return $this. > I second $this. I also would like to be able to declare `function foo(): $this` at the same time as `function foo(): static` so that we can use the most accurate description right away. Although I'm not into the C part of the proposal, if I may have a suggestion here, it would be to implement the check *at compile time*. Like nullable return types check at compile time that `return null;` is used instead of just `return;`, I think a `$this` return type could and should enforce `return $this;` on all return point of such methods. That would also make the check free at runtime. Cheers, Nicolas --000000000000cfad04059bb5ffd8--