<?php
interface StreamInterfaceA
{
public function write($data);
}
interface StreamInterfaceB
{
public function write($data);
}
class Stream implements StreamInterfaceA
{
public function write($data)
{
echo $data;
}
}
function outputStreamInterfaceB(StreamInterfaceB $stream) {
$stream->write('hello world');
}
$stream = new Stream();
outputStreamInterfaceB($stream);
Fatal error: Uncaught TypeError: outputStreamInterfaceB(): Argument #1 ($stream) must be of type StreamInterfaceB, Stream given, called in /in/EFG1e on line 30 and defined in /in/EFG1e:24
Stack trace:
#0 /in/EFG1e(30): outputStreamInterfaceB(Object(Stream))
#1 {main}
thrown in /in/EFG1e on line 24
Process exited with code 255.
Fatal error: Uncaught TypeError: Argument 1 passed to outputStreamInterfaceB() must implement interface StreamInterfaceB, instance of Stream given, called in /in/EFG1e on line 30 and defined in /in/EFG1e:24
Stack trace:
#0 /in/EFG1e(30): outputStreamInterfaceB(Object(Stream))
#1 {main}
thrown in /in/EFG1e on line 24
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Catchable fatal error: Argument 1 passed to outputStreamInterfaceB() must implement interface StreamInterfaceB, instance of Stream given, called in /in/EFG1e on line 30 and defined in /in/EFG1e on line 24
Process exited with code 255.