Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81837 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73657 invoked from network); 4 Feb 2015 19:36:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2015 19:36:44 -0000 Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:44318] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/D5-40930-AC472D45 for ; Wed, 04 Feb 2015 14:36:43 -0500 Received: (qmail 6210 invoked from network); 4 Feb 2015 20:36:39 +0100 Received: from cm135-167.liwest.at (HELO RoLaptop) (81.10.135.167) by ns73.kreativmedia.ch with ESMTPSA (AES256-SHA encrypted, authenticated); 4 Feb 2015 20:36:39 +0100 To: "'Nikita Popov'" , "'PHP internals'" References: <002e01d040b0$208abf50$61a03df0$@tutteli.ch> In-Reply-To: <002e01d040b0$208abf50$61a03df0$@tutteli.ch> Date: Wed, 4 Feb 2015 20:36:38 +0100 Message-ID: <002f01d040b1$e4f6c130$aee44390$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQGT0XnrbIGLsDRs7AVh3vczbttSBwHv/v0ZnUpAorA= Content-Language: de-ch Subject: AW: [PHP-DEV] Allow dropping typehints during inheritance From: php@tutteli.ch ("Robert Stoll") > -----Urspr=C3=BCngliche Nachricht----- > Von: Robert Stoll [mailto:php@tutteli.ch] > Gesendet: Mittwoch, 4. Februar 2015 20:24 > An: 'Nikita Popov'; 'PHP internals' > Betreff: AW: [PHP-DEV] Allow dropping typehints during inheritance >=20 >=20 > > -----Urspr=C3=BCngliche Nachricht----- > > Von: Nikita Popov [mailto:nikita.ppv@gmail.com] > > Gesendet: Mittwoch, 4. Februar 2015 19:50 > > An: PHP internals > > Betreff: [PHP-DEV] Allow dropping typehints during inheritance > > > > Hi internals! > > > > Currently we do not allow [1] removing a typehint during = inheritance. For example the following code is not valid: > > > > interface A { > > public function method(Typehint $param); > > } > > class B implements A { > > public function method($param); > > } > > // Fatal error: Declaration of B::method() must be compatible = with > > A::method(Typehint $param) > > > > The above code does *not* constitute an LSP violation, because = B::method() accepts more inputs than A::method(). > > However we still forbid it. > > > > This is an issue, because it makes it impossible to add typehints to > > parameters at a later point in time. I've seen this issue come up = both > > in userland code, as well as in a recent DateTime change, see > > = https://github.com/php/php-src/commit/8e19705a93d785cd1ff8ba3a69699b00 > > 169fea47 > > . > > > > Instead of reverting the DateTime BC break, I'm wondering if it > > wouldn't be better to fix the root cause by making the inheritance = check less strict and allow removing typehints? > > > > Thanks, > > Nikita > > > > [1] This is a fatal error when interfaces or abstract methods are = involved, otherwise this is an E_STRICT error. >=20 > I do not entirely agree here since what you are proposing is not to = introduce contravariance for parameters (which I would > support) but remove the check entirely. > In this sense it is an LSP violation (you cannot substitute A with B = and guarantee the correctness) and therefore should not > be introduced into PHP. >=20 > Cheers, > Robert >=20 >=20 > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, = visit: http://www.php.net/unsub.php I have to correct myself, without type hint is equal to say any type and = in this sense it is contravariance, all good to go :)