Re: [RFC] Parameter No Type Variance

From: Date: Mon, 21 Nov 2016 10:42:53 +0000
Subject: Re: [RFC] Parameter No Type Variance
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-97105@lists.php.net to get a copy of this message
2016-11-21 11:00 GMT+01:00 Daniel Morris <daniel@honestempire.com>: > What happens if the method signature is defined within an interface? Just the same as for every class. Having other rules for interfaces doesn't make sense. Imagine the following example: interface I { function foo(array $foo); } class C1 implements I { function foo(array $foo) { /* with your proposal, we have to keep the type here? */ } } class C2 extends C2 { function foo($foo) { /* we can suddenly drop the parameter type now?! */ } } > I would consider that method signature a contract and one that should not > be able to be overwritten. > Subtypes can always accept more than a parent by the LSP ( https://en.wikipedia.org/wiki/Liskov_substitution_principle) Regards, Niklas

« previous php.internals (#97105) next »