Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81834 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66381 invoked from network); 4 Feb 2015 18:49:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2015 18:49:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.172 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.172 mail-wi0-f172.google.com Received: from [209.85.212.172] ([209.85.212.172:55499] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 81/B4-40930-AC962D45 for ; Wed, 04 Feb 2015 13:49:46 -0500 Received: by mail-wi0-f172.google.com with SMTP id h11so33934022wiw.5 for ; Wed, 04 Feb 2015 10:49:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=borOwSTEBzwNXClMiA7GcyK9b8VCKiTyAgYYMiDb+1w=; b=Eeb4juJroEIFjC+A4ce6GvKgoODGZO3k/MFDD8YhHz4nhBG8+D6bpKn+HGmeDEzRPJ GhUh/4b5iY6vLg5dSNA3qchDAY7i16xklkMhn+Z9j7JHpyil28/AehV4V2fnMavYE7fI eguPmNYnn6mtRodSBPV1oz5ZMRDMTdd0DaUTdPFxuSTKiZa5CL7by1FO5PNDwUOcimpJ TmfRX6mvyXjpII5J2tc3Us9DIcIq5vd2E43Q0lJm6z0c/uCiI55nJMUf5p8Yi7OAcg3u LvVgXIJJmMUNtEM9AgRbxWtJ0fSGQuW/AHqciXjaLO0UZ3doBqS0jmW6XJH4FxQCy5/H J/TQ== MIME-Version: 1.0 X-Received: by 10.180.207.83 with SMTP id lu19mr47944232wic.52.1423075783287; Wed, 04 Feb 2015 10:49:43 -0800 (PST) Received: by 10.27.10.138 with HTTP; Wed, 4 Feb 2015 10:49:43 -0800 (PST) Date: Wed, 4 Feb 2015 19:49:43 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=001a11c3a6b88d2a9e050e47a6ea Subject: Allow dropping typehints during inheritance From: nikita.ppv@gmail.com (Nikita Popov) --001a11c3a6b88d2a9e050e47a6ea Content-Type: text/plain; charset=UTF-8 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/8e19705a93d785cd1ff8ba3a69699b00169fea47 . 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. --001a11c3a6b88d2a9e050e47a6ea--