<?php
class TestClass
{
public function __construct()
{
}
public function __invoke()
{
}
public function foo()
{
}
public static function bar()
{
}
}
//$r = new ReflectionMethod('TestClass::foo');
//$r = new ReflectionMethod('TestClass::__construct');
//$r = new ReflectionMethod(new TestClass(), '__construct');
$r = new ReflectionMethod('TestClass::_bar');
var_dump($r->class, $r->name);
Fatal error: Uncaught ReflectionException: Method TestClass::_bar() does not exist in /in/Rb6kb:26
Stack trace:
#0 /in/Rb6kb(26): ReflectionMethod->__construct('TestClass::_bar')
#1 {main}
thrown in /in/Rb6kb on line 26
Process exited with code 255.
Fatal error: Uncaught exception 'ReflectionException' with message 'Method TestClass::_bar() does not exist' in /in/Rb6kb:26
Stack trace:
#0 /in/Rb6kb(26): ReflectionMethod->__construct('TestClass::_bar')
#1 {main}
thrown in /in/Rb6kb on line 26
Process exited with code 255.
Output for 5.0.3 - 5.0.5, 5.1.0 - 5.1.1
Warning: ReflectionMethod::__construct() expects exactly 2 parameters, 1 given in /in/Rb6kb on line 26
string(0) ""
string(0) ""
Output for 5.0.0 - 5.0.2
Warning: ReflectionMethod::__construct() expects exactly 2 parameters, 1 given in /in/Rb6kb on line 26
Notice: Undefined property: ReflectionMethod::$class in /in/Rb6kb on line 27
Notice: Undefined property: ReflectionMethod::$name in /in/Rb6kb on line 27
NULL
NULL
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Rb6kb on line 5
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Rb6kb on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/Rb6kb on line 5
Process exited with code 255.