Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104457 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68128 invoked from network); 18 Feb 2019 18:28:29 -0000 Received: from unknown (HELO mail-qt1-f180.google.com) (209.85.160.180) by pb1.pair.com with SMTP; 18 Feb 2019 18:28:29 -0000 Received: by mail-qt1-f180.google.com with SMTP id b8so19475015qtr.9 for ; Mon, 18 Feb 2019 07:12:54 -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=x8Ivd4X6AFpeOlCayz7O/TampNuvmNXAJRSE8W6n1GQ=; b=L5vQhpAuKaMcwmmoRNoLDH05YWsNZ0IL4Zul4IOUdFhBws9GmcPjJPP2c89c+nH/jV QEq/cba0yKuXKOGyazZduK8Z269UGeZjNijToLCOaEioNScAYdz0iuQ0rg71DBzEXrri GLJ0LYmlZwdrQwEJdJNmKSJkMZPlHsuOeGDqIo5z5A5r1RJaIYyZtvmt6icqNghacqKu KwK5PFAcDDKzb8eHPURvR1WStAGywprPxaNWy0QLaXUlOWf+nPrtDoYcksjOOoh7FQZe JvsY2CrPXU9aUDqz8gOnBAkjCvY021oNsDQ5UYobuTtSIqDFpJexD69zTIahrgczbcfy XAdA== 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=x8Ivd4X6AFpeOlCayz7O/TampNuvmNXAJRSE8W6n1GQ=; b=c9thHf/0HKqnNvIqRDGGm+3/iMbyQk/Gn/QhQF3xOPcl9XlQwhH/9scgmQXUHpIGbC yj1V6V1IiCo2M7vWSKKSGSJmQKsWRsGd29MTLj+8HjqL6msJejq3PYNn8s0rSFht56cQ CCGyTeFwv1RQwtrqYpfYJNqqPyxhUT4WFUfrI+BPrD3r+bsHHw8FHRFmPw6H6j5EG6eA 56QK7zull0DYFHWUJ15RbNX6Lpk3qRTBObAhYt+Bg9/toklojxC58hHlZyyZDwNdGNhg bWy4zDoIpFFiqqrKnOm9yk26N4bCtHkeMDElyHoNrhoU4wCh78Bc2Vjf1qh2lYvFCnl7 /tdQ== X-Gm-Message-State: AHQUAuZIqZHQgaU3ARQxy6Cn7PV7YZGDnxQ+v8T5vKEc6rWTi/0XQ2k+ WWwsS+gl1MVosfn42DtlqXB/9wngygBlsPexq0rPCw== X-Google-Smtp-Source: AHgI3IZdHUOW+LQCKjs07PR8LBE7RC6VVs012wo3SFgqdaOcDYoZokPXBeMHDKTVD1SgheeH6T1eg2962sdeiZp4jZE= X-Received: by 2002:ac8:26b9:: with SMTP id 54mr18870824qto.301.1550502773736; Mon, 18 Feb 2019 07:12:53 -0800 (PST) MIME-Version: 1.0 References: <5f06eda3-5431-5469-badf-317e4eddd2fa@gmail.com> In-Reply-To: <5f06eda3-5431-5469-badf-317e4eddd2fa@gmail.com> Date: Mon, 18 Feb 2019 16:12:47 +0100 Message-ID: To: Rowan Collins Cc: PHP Internals Content-Type: multipart/alternative; boundary="0000000000000d4af905822c8faf" Subject: Re: [PHP-DEV][RFC] Allow void return type variance From: mike.php.net@gmail.com (Michael Wallner) --0000000000000d4af905822c8faf Content-Type: text/plain; charset="UTF-8" I second Rowans thoughts. Am So., 17. Feb. 2019, 17:36 hat Rowan Collins geschrieben: > On 04/02/2019 03:22, Wes wrote: > > Recent events convinced me to write this RFC :P > > > > Please have a read here https://wiki.php.net/rfc/allow-void-variance > > > I was thinking about this this afternoon, and I think the current > behaviour is actually correct, and this constraint should stay invariant. > > My reasoning is that ": void" isn't actually a *type constraint* - there > is no "void type" to apply the rules of covariance and contravariance > to. It's tempting to place it on a par with ": null", but a void > function evaluates to null only for the same reason an unset variable > does: because the runtime has to give you *something*. > > Instead, ": void" in PHP represents a *behavioural constraint* on the > function - it declares that within this function, anything of the form > "return $value" is to be treated as an error. In other languages, the > same constraint might be enforced by declaring the routine as a > "procedure" rather than a "function". > > As such, it is more appropriate to compare "void vs non-void" to "static > vs non-static", which is an invariant constraint - you can't over-ride a > static method with a non-static one, or vice versa. > > > (Incidentally, the RFC mentions TypeScript as precedent; there, "void" > apparently *is* a type, not just a keyword in function signatures: > https://www.typescriptlang.org/docs/handbook/basic-types.html) > > Regards, > > -- > Rowan Collins > [IMSoP] > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0000000000000d4af905822c8faf--