<?php
interface Dynamic
{
function __call($name, $arguments);
}
class Foo
{
public function sing()
{
var_dump('Do re mi!');
}
public function dance()
{
var_dump('Cha cha cha!');
}
}
class Bar implements Dynamic
{
public function __call($name, $arguments)
{
// @todo; magic
}
}
function gimmeFoo(Foo $foo)
{
$foo->sing();
$foo->dance();
}
gimmeFoo(new Bar()); // works because Dynamic dodges typechecks
Fatal error: Uncaught TypeError: gimmeFoo(): Argument #1 ($foo) must be of type Foo, Bar given, called in /in/MOTfr on line 35 and defined in /in/MOTfr:29
Stack trace:
#0 /in/MOTfr(35): gimmeFoo(Object(Bar))
#1 {main}
thrown in /in/MOTfr on line 29
Process exited with code 255.
Fatal error: Uncaught TypeError: Argument 1 passed to gimmeFoo() must be an instance of Foo, instance of Bar given, called in /in/MOTfr on line 35 and defined in /in/MOTfr:29
Stack trace:
#0 /in/MOTfr(35): gimmeFoo(Object(Bar))
#1 {main}
thrown in /in/MOTfr on line 29
Process exited with code 255.
Catchable fatal error: Argument 1 passed to gimmeFoo() must be an instance of Foo, instance of Bar given, called in /in/MOTfr on line 35 and defined in /in/MOTfr on line 29
Process exited with code 255.
Output for 5.1.1 - 5.1.6
Fatal error: Argument 1 passed to gimmeFoo() must be an instance of Foo, called in /in/MOTfr on line 35 and defined in /in/MOTfr on line 29
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/MOTfr on line 35
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Argument 1 must be an instance of Foo in /in/MOTfr on line 29
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/MOTfr on line 3
Process exited with code 255.