<?php
trait t {
public function f() { return __CLASS__; }
}
class c {
use t;
}
function dick(t $a) {
return $a->f();
}
$c = new c();
echo $c->f();
echo dick($c);
c
Fatal error: Uncaught TypeError: dick(): Argument #1 ($a) must be of type t, c given, called in /in/to5ha on line 14 and defined in /in/to5ha:9
Stack trace:
#0 /in/to5ha(14): dick(Object(c))
#1 {main}
thrown in /in/to5ha on line 9
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
c
Fatal error: Uncaught TypeError: dick(): Argument #1 ($a) must be of type t, c given, called in /in/to5ha on line 14 and defined in /in/to5ha:9
Stack trace:
#0 /in/to5ha(14): dick(Object(c))
#1 {main}
thrown in /in/to5ha on line 9
Process exited with code 255.
c
Fatal error: Uncaught TypeError: Argument 1 passed to dick() must be an instance of t, instance of c given, called in /in/to5ha on line 14 and defined in /in/to5ha:9
Stack trace:
#0 /in/to5ha(14): dick(Object(c))
#1 {main}
thrown in /in/to5ha on line 9
Process exited with code 255.
c
Catchable fatal error: Argument 1 passed to dick() must be an instance of t, instance of c given, called in /in/to5ha on line 14 and defined in /in/to5ha on line 9
Process exited with code 255.