<?php
trait EndpointInjector
{
public function before($str)
{
echo $str;
}
}
class Endpoint
{
use EndpointInjector;
public function test($boringObj)
{
return $boringObj->withBody('#');
}
}
class BoringObj
{
public function withBody($str)
{
return $str;
}
}
$ep = new Endpoint();
$ep->before();
$ep->test(new BoringObj());
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Endpoint::before(), 0 passed in /in/93pHc on line 30 and exactly 1 expected in /in/93pHc:5
Stack trace:
#0 /in/93pHc(30): Endpoint->before()
#1 {main}
thrown in /in/93pHc on line 5
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
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Endpoint::before(), 0 passed in /in/93pHc on line 30 and exactly 1 expected in /in/93pHc:5
Stack trace:
#0 /in/93pHc(30): Endpoint->before()
#1 {main}
thrown in /in/93pHc on line 5
Process exited with code 255.
Warning: Missing argument 1 for Endpoint::before(), called in /in/93pHc on line 30 and defined in /in/93pHc on line 5
Notice: Undefined variable: str in /in/93pHc on line 7