<?php
interface Exp { public function x();}
class First implements Exp {
public function x() {}
}
class Second {}
function x(Exp $e){
echo get_class($e)."\n";
}
x(new First);
x(new Second);
?>
First
Fatal error: Uncaught TypeError: x(): Argument #1 ($e) must be of type Exp, Second given, called in /in/qZU6F on line 11 and defined in /in/qZU6F:7
Stack trace:
#0 /in/qZU6F(11): x(Object(Second))
#1 {main}
thrown in /in/qZU6F on line 7
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
First
Fatal error: Uncaught TypeError: x(): Argument #1 ($e) must be of type Exp, Second given, called in /in/qZU6F on line 11 and defined in /in/qZU6F:7
Stack trace:
#0 /in/qZU6F(11): x(Object(Second))
#1 {main}
thrown in /in/qZU6F on line 7
Process exited with code 255.
First
Fatal error: Uncaught TypeError: Argument 1 passed to x() must implement interface Exp, instance of Second given, called in /in/qZU6F on line 11 and defined in /in/qZU6F:7
Stack trace:
#0 /in/qZU6F(11): x(Object(Second))
#1 {main}
thrown in /in/qZU6F on line 7
Process exited with code 255.
Output for 5.6.38
First
Catchable fatal error: Argument 1 passed to x() must implement interface Exp, instance of Second given, called in /in/qZU6F on line 11 and defined in /in/qZU6F on line 7
Process exited with code 255.