<?php
class A {
private $b;
function __construct() { $this->b = new B; }
function __call($method, $args) { $this->b->$method(...$args); }
}
class B {
function work($p1, $p2, $p3) { echo 'working'; }
}
(new B)->work();
(new A)->work();
(new A)->not();
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::work(), 0 passed in /in/SGjGg on line 14 and exactly 3 expected in /in/SGjGg:11
Stack trace:
#0 /in/SGjGg(14): B->work()
#1 {main}
thrown in /in/SGjGg on line 11
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 B::work(), 0 passed in /in/SGjGg on line 14 and exactly 3 expected in /in/SGjGg:11
Stack trace:
#0 /in/SGjGg(14): B->work()
#1 {main}
thrown in /in/SGjGg on line 11
Process exited with code 255.
Output for 7.0.0 - 7.0.33
Warning: Missing argument 1 for B::work(), called in /in/SGjGg on line 14 and defined in /in/SGjGg on line 11
Warning: Missing argument 2 for B::work(), called in /in/SGjGg on line 14 and defined in /in/SGjGg on line 11
Warning: Missing argument 3 for B::work(), called in /in/SGjGg on line 14 and defined in /in/SGjGg on line 11
working
Warning: Missing argument 1 for B::work(), called in /in/SGjGg on line 6 and defined in /in/SGjGg on line 11
Warning: Missing argument 2 for B::work(), called in /in/SGjGg on line 6 and defined in /in/SGjGg on line 11
Warning: Missing argument 3 for B::work(), called in /in/SGjGg on line 6 and defined in /in/SGjGg on line 11
working
Fatal error: Uncaught Error: Call to undefined method B::not() in /in/SGjGg:6
Stack trace:
#0 /in/SGjGg(16): A->__call('not', Array)
#1 {main}
thrown in /in/SGjGg on line 6
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Warning: Missing argument 1 for B::work(), called in /in/SGjGg on line 14 and defined in /in/SGjGg on line 11
Warning: Missing argument 2 for B::work(), called in /in/SGjGg on line 14 and defined in /in/SGjGg on line 11
Warning: Missing argument 3 for B::work(), called in /in/SGjGg on line 14 and defined in /in/SGjGg on line 11
working
Warning: Missing argument 1 for B::work(), called in /in/SGjGg on line 6 and defined in /in/SGjGg on line 11
Warning: Missing argument 2 for B::work(), called in /in/SGjGg on line 6 and defined in /in/SGjGg on line 11
Warning: Missing argument 3 for B::work(), called in /in/SGjGg on line 6 and defined in /in/SGjGg on line 11
working
Fatal error: Call to undefined method B::not() in /in/SGjGg on line 6
Process exited with code 255.