On 28/05/2017 18:06, Aidan Woods wrote:
So, if I understand everything here correctly
```
interface Foo
{
public function bar(Boo $Boo);
}
```
and
```
interface Foo
{
/*
* @param $Boo, pretty please accept type Boo here
*/
public function bar($Boo);
}
```
will be equivalent in 7.2? :(
No, what's being proposed is that this will be allowed:
interface Foo
{
public function bar(Boo $Boo);
}
class Bar implements Foo
{
public function bar($Boo) { ... }
}
Whereas currently, the class would have to look like this:
class Bar implements Foo
{
public function bar(Boo $Boo) { ... }
}
An interface's job is to provide guarantees to calling code about where
and how an object can be used. It doesn't place any limits on what
*else* the class can do - class Bar might have extra methods, public
properties, be written in a completely different style, etc. Accepting
extra types *as well as* the one specified in the interface is in the
same category: the class is doing *more than* the interface, and that's
none of the interface's business.
I think some of the examples here are approaching interfaces as a
broader contract, that allows a library author to say "you must
implement the library this way". It's similar to the debate about
whether strict type hints should be the choice of the caller or the
callee. If you treat each module of the program as a black box, then all
that matters is the guarantees of what's acceptable, which type hints
and interfaces provide; but if you want more control over *how* somebody
meets those guarantees, then I can see that this RFC, and the
caller-selected type hint modes, would feel like a step in the wrong
direction.
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php