<?php
final class EventManager
{
public static function call($sEvent) {
$aClasses = ['B'];
foreach ($aClasses as $sClassName) {
$oMethodChecking = new ReflectionMethod($sClassName,$sFunctionName);
$sFunctionName = 'event_'.$sEvent;
if (method_exists($sClassName, $sFunctionName) && $oMethodChecking->isStatic()) {
call_user_func($sClassName.'::'.$sFunctionName);
}
}
}
}
final class B
{
public static function event_event_name() {
echo 'ok';
}
}
EventManager::call('event_name');
Warning: Undefined variable $sFunctionName in /in/UpOX8 on line 9
Fatal error: Uncaught ReflectionException: ReflectionMethod::__construct(): Argument #1 ($objectOrMethod) must be a valid method name in /in/UpOX8:9
Stack trace:
#0 /in/UpOX8(9): ReflectionMethod->__construct('B', NULL)
#1 /in/UpOX8(25): EventManager::call('event_name')
#2 {main}
thrown in /in/UpOX8 on line 9
Process exited with code 255.
Notice: Undefined variable: sFunctionName in /in/UpOX8 on line 9
Fatal error: Uncaught ReflectionException: Method B::() does not exist in /in/UpOX8:9
Stack trace:
#0 /in/UpOX8(9): ReflectionMethod->__construct('B', '')
#1 /in/UpOX8(25): EventManager::call('event_name')
#2 {main}
thrown in /in/UpOX8 on line 9
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught ReflectionException: Method B::() does not exist in /in/UpOX8:9
Stack trace:
#0 /in/UpOX8(9): ReflectionMethod->__construct('B', '')
#1 /in/UpOX8(25): EventManager::call('event_name')
#2 {main}
thrown in /in/UpOX8 on line 9
Process exited with code 255.
Notice: Undefined variable: sFunctionName in /in/UpOX8 on line 9
Fatal error: Uncaught exception 'ReflectionException' with message 'Method B::() does not exist' in /in/UpOX8:9
Stack trace:
#0 /in/UpOX8(9): ReflectionMethod->__construct('B', '')
#1 /in/UpOX8(25): EventManager::call('event_name')
#2 {main}
thrown in /in/UpOX8 on line 9
Process exited with code 255.