3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function foo(&$arg1) { var_dump('arg1: ', $arg1); } } class B extends A { public function bar() { $x = new stdClass(); $x->baz = 'just a value'; $this->callPrivate($x); } private function callPrivate($x) { $method = new \ReflectionMethod( 'A', 'foo' ); //working 5.4 (* see above) but not in 5.5 $arguments = func_get_args(); return $method->invokeArgs($this, $arguments); } } $obj = new B; $obj->bar();

preferences:
43.79 ms | 402 KiB | 5 Q