Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108060 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70474 invoked from network); 9 Jan 2020 16:21:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Jan 2020 16:21:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C74871804D1 for ; Thu, 9 Jan 2020 06:27:17 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE 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-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (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:27:17 -0800 (PST) Received: by mail-qv1-f42.google.com with SMTP id m14so3024351qvl.3 for ; Thu, 09 Jan 2020 06:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1wQiGiuf14MitnxWF8H9Ee2BLjBS/vUwB4hnLLpoyPU=; b=MY8sNSObr59gf4yHCeQUffcxPu78NfeymSS/+oJ45FIiR/f3jxvs46XE4O+U81rL55 LY7JmdR6/39hkqbEI9h2DLNjbPh41M96Asq89bDn2xC+5N7y0cjFKXOaqFTMbLTdW6gd ZBIa3PCRbfpGuv9xiIS1deE4yGdJ6rXnRV1JEQyho9giHEjFIWbuGAvoPev24hfXxPVc 7mPvwQlpyaaOkhMd55a37I3pWWrwHYTnwj6Kcsa6rUrv6fc6eTM59OTEBiCjLCcUHGKk fw8dOrqLxu6A2+/yTGkEe6BF2i1r6v8/+6bTfMcR04pU5GATC8TZjj5aknyQMz5df488 xA5g== 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=1wQiGiuf14MitnxWF8H9Ee2BLjBS/vUwB4hnLLpoyPU=; b=dsOl8Bd60ktotBQDVyS9u+WS/5RUCLRqqEW5RQQZa3Bdr81tjWXOFoI1bGqPcL6/u6 k6tXaKifhE/60V4rQ+SPcfrHb/Fl+QzZKHELoP3DsM+3dk+J+5NmP0B8Mr8G6jppwAzn D9PR0fJT5Z/K5NzMM5vCdZ4kb9fJ4GLp3Gkq95hBvPPl7sJCmt3bE1JBUv674BMWx4v7 GSzjAm5i/GQ4feklS+LzMf0L0N2F+cPL398vKXLGxeBQQ3hnnxhoQ2h6TZIJ1VJkdc3K adtnURE1Co6A0n++/VL1DrY6+hMgv0wVHvh1vrAmUeZdUEnqWmtj7eDcK6UcvJvJtQPK 3cyg== X-Gm-Message-State: APjAAAW3IvS6sjOeFYTy2z/aJBg3uaYPHo2PVjeWgV7ARbuiJ6LLsDvs I7YB8rWTHhiVOF/GkrN/dONmcftoNjw= X-Google-Smtp-Source: APXvYqzbM0Q2BmaGmKutdzev5vYUZdTuVRdm3MqOLrreLuNXRldkeni7jl80K3RaPBaKDSAvS6S7rQ== X-Received: by 2002:ad4:496f:: with SMTP id p15mr8875075qvy.191.1578580034807; Thu, 09 Jan 2020 06:27:14 -0800 (PST) Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com. [209.85.219.47]) by smtp.googlemail.com with ESMTPSA id g18sm3483420qtc.83.2020.01.09.06.27.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Jan 2020 06:27:14 -0800 (PST) Received: by mail-qv1-f47.google.com with SMTP id z3so3032585qvn.0 for ; Thu, 09 Jan 2020 06:27:14 -0800 (PST) X-Received: by 2002:a05:6214:433:: with SMTP id a19mr9074699qvy.221.1578580034053; Thu, 09 Jan 2020 06:27:14 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 9 Jan 2020 15:27:03 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000002dea61059bb5cef2" Subject: Re: [PHP-DEV] [RFC] Static return type From: andreas@dqxtech.net (Andreas Hennings) --0000000000002dea61059bb5cef2 Content-Type: text/plain; charset="UTF-8" On Thu, 9 Jan 2020 at 15:22, Andreas Hennings wrote: > > However, $this is not a real type, and it is unclear what the advantage > of specifying $this rather than static would be from a type system level > perspective. > > Perhaps not from a "type system level", but from a more broad "enforced > contract" level. > E.g. IDEs or code inspection tools can warn if a method will not return > $this. > This also means recursive calls also need to return $this instead of > static. > > class C { > function foo(): static { > return clone $this; > } > function bar(): $this { > return $this->foo(); // IDE can complain. > } > } > 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. This would cause confusion if later some packages introduce ": $this", but others are still behind. namespace oldpackage; class B { function foo(): static { // Actually returns $this, not just static. return $this; } } namespace newpackage; class C extends B { function foo(): $this { return parent::foo(); // Should the IDE complain? } } > > > On Thu, 9 Jan 2020 at 15:07, Larry Garfield > wrote: > >> On Wed, Jan 8, 2020, at 5:42 AM, Nikita Popov wrote: >> > Hi internals, >> > >> > I would like to propose the following RFC, which allows using "static" >> as a >> > return type: >> > >> > https://wiki.php.net/rfc/static_return_type >> > >> > While I'm personally not a fan of late static binding, we do support it >> and >> > people do use it quite heavily, so I think we should also support it in >> > return types. >> > >> > Regards, >> > Nikita >> >> >> Is "squee!" an appropriate response on the list? For interface authors >> this is a huge deal. >> >> --Larry Garfield >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> --0000000000002dea61059bb5cef2--