Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81846 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23013 invoked from network); 4 Feb 2015 23:58:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2015 23:58:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=hannes.magnusson@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=hannes.magnusson@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.182 as permitted sender) X-PHP-List-Original-Sender: hannes.magnusson@gmail.com X-Host-Fingerprint: 209.85.217.182 mail-lb0-f182.google.com Received: from [209.85.217.182] ([209.85.217.182:55999] helo=mail-lb0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/CE-40930-112B2D45 for ; Wed, 04 Feb 2015 18:58:10 -0500 Received: by mail-lb0-f182.google.com with SMTP id l4so4323236lbv.13 for ; Wed, 04 Feb 2015 15:58:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=JjFfb7ueOEqYMwxqYBhTSbrm+MdpgQGLvhlavbRCPNs=; b=yCA6TOCI6Sc8bWtMbjKMi5NeCGWN4B0QXy3p3C0HI8H1O7doqlc8GrWSQ5OnvnKiIC ZfW2sj/tTZoD3EJg16i274PWF3B8Cya2kteLsNgw8G5+uJ0ewBQlHInxOFYKFb60KAEQ af1BAxOa/eE1vIt1Lb4e7t7F0TSNeZ1LDNznowehPRZNQzZKFE6HwXJTtgwkcaZEMHiS qSN02HwxrLMO+ux1WVnLFCTO/ewBVdMVTWhCT6V7jxoUFuS1gVLkDCPTK72ySg7cuMvQ otVsX4vNBtH9zGEPXAv770r3JDtB848fagPaJhJpXthh3JKm4KKqv67KzogazBjuplEb bQew== MIME-Version: 1.0 X-Received: by 10.112.129.195 with SMTP id ny3mr323669lbb.10.1423094287052; Wed, 04 Feb 2015 15:58:07 -0800 (PST) Received: by 10.25.22.145 with HTTP; Wed, 4 Feb 2015 15:58:06 -0800 (PST) In-Reply-To: References: Date: Wed, 4 Feb 2015 15:58:06 -0800 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Allow dropping typehints during inheritance From: hannes.magnusson@gmail.com (Hannes Magnusson) On Wed, Feb 4, 2015 at 10:49 AM, Nikita Popov wrote: > 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. So what it supports "more inputs"? It does constitute an LSP violation. "more inputs" is not what the guarantee is at all, if that is what you want you'd typehint on a interface. It is a LSP failure to allow a string, or any other scalar value, when the parent requires a specific type/object. It sucks that we fail our arginfo very frequently, but this is the way it is :] -Hannes