<?php
class Foo {
private function bar() { echo 'baz'; }
}
class Bar extends Foo {
public function foo() {
$reflected = new ReflectionMethod('Foo', 'bar');
$reflected->invoke();
}
}
$bar = new Bar();
$bar->foo();
Fatal error: Uncaught ArgumentCountError: ReflectionMethod::invoke() expects at least 1 argument, 0 given in /in/ibU0O:10
Stack trace:
#0 /in/ibU0O(10): ReflectionMethod->invoke()
#1 /in/ibU0O(15): Bar->foo()
#2 {main}
thrown in /in/ibU0O on line 10
Process exited with code 255.
Fatal error: Uncaught ReflectionException: Trying to invoke private method Foo::bar() from scope ReflectionMethod in /in/ibU0O:10
Stack trace:
#0 /in/ibU0O(10): ReflectionMethod->invoke()
#1 /in/ibU0O(15): Bar->foo()
#2 {main}
thrown in /in/ibU0O on line 10
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Fatal error: Uncaught exception 'ReflectionException' with message 'Trying to invoke private method Foo::bar() from scope ReflectionMethod' in /in/ibU0O:10
Stack trace:
#0 /in/ibU0O(10): ReflectionMethod->invoke()
#1 /in/ibU0O(15): Bar->foo()
#2 {main}
thrown in /in/ibU0O on line 10
Process exited with code 255.