Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104454 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82171 invoked from network); 17 Feb 2019 19:52:41 -0000 Received: from unknown (HELO mail-wm1-f52.google.com) (209.85.128.52) by pb1.pair.com with SMTP; 17 Feb 2019 19:52:41 -0000 Received: by mail-wm1-f52.google.com with SMTP id h22so10343087wmb.0 for ; Sun, 17 Feb 2019 08:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=In3axJjnBqQQF2jEAXVOY6siOOCiWfW+dnG/3ven3Js=; b=c4NGwisVPWL5ACxbSU6yQNr6OL0ZeePN62UTWxYX1DHGdZfqpBvylFCa8/Ym8nL8aJ RdNQ3ab1g8vep36f6TqCwyQNlPeJhKJlLTh4IAYujH4+PR462I8HoM29GS7LzG140wPd M+T6l+Ws20rVOmvbmwYq2CIArDMhwPOx+Eu8sCx78RDlQ2//XyALRRAgI3JXkcyPzk07 w6L1ON1MP9uaYarxZ67mcqFNOyrfErvuFAG1mNSEC4peEh3TfNNMww+lrjhcKE+GQmdf 7XUS7qyDJr06wCTbvoDgeRiLNzOP49tngNdispZ8K9vppU4Ivymo+aSzFRGYsgBeMbnX ky7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=In3axJjnBqQQF2jEAXVOY6siOOCiWfW+dnG/3ven3Js=; b=guXJld6StQr1NLI7Cc/L17LbQt/6ptETd70NUwIr9di0IDeDjSlCQTq7bhYGU52Sfo d4cD+e+2Er68VwimSDfFYIILnbWRvizt9I/AUjDeozDdjxWKFr2VJnR/OIIZlcZrHpne UfIXra4RbM4MDqAYJ+FAC6M2GbhfSpY3vJrit724VRqRLfPJPme2cIViufboh7GD+naO 7iryB+flhaKZpwX5Z28B3+D/P2UzP1hKLBxeNuj7DejD901+fL9BaEb/PGJdsrs22qct rNaZl7wJoxsAOj+fD5RDm/3CX93AxTPawDZu7ntxCD186uqMJNt9rCjnTiqxnt/wMXWd Ua5Q== X-Gm-Message-State: AHQUAuY5g2CgvN0ITQWuxZhVsMEhWHnzQzaaxVFMvhl3gsLLk0zOddfy KvRORizWqwEdc7nC/1uhzuiqu9jS X-Google-Smtp-Source: AHgI3IaXVnctxR1dV0NHphG3FZdfw6pgCQwWHec+Mr0mVmvy5IIgiZ79zXC4QafmaIsqYOgKuWl+og== X-Received: by 2002:a1c:f509:: with SMTP id t9mr13719379wmh.76.1550421410607; Sun, 17 Feb 2019 08:36:50 -0800 (PST) Received: from [192.168.0.16] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id h142sm20381896wme.33.2019.02.17.08.36.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 08:36:49 -0800 (PST) To: internals@lists.php.net References: Message-ID: <5f06eda3-5431-5469-badf-317e4eddd2fa@gmail.com> Date: Sun, 17 Feb 2019 16:36:48 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV][RFC] Allow void return type variance From: rowan.collins@gmail.com (Rowan Collins) 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]