<?php
class A {
private $b;
function __construct() { $this->b = new B; }
function __call($method, $args) { $this->b->$method(...$args); }
}
class B {
function work() { echo 'working'; }
}
(new B)->work();
(new A)->work();
(new A)->not();
workingworking
Fatal error: Uncaught Error: Call to undefined method B::not() in /in/PmI25:6
Stack trace:
#0 /in/PmI25(16): A->__call('not', Array)
#1 {main}
thrown in /in/PmI25 on line 6
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
workingworking
Fatal error: Uncaught Error: Call to undefined method B::not() in /in/PmI25:6
Stack trace:
#0 /in/PmI25(16): A->__call('not', Array)
#1 {main}
thrown in /in/PmI25 on line 6
Process exited with code 255.