4 namespace Civi\Core\Event
;
7 * This provides some rarely used debug utilities.
9 * @package Civi\Core\Event
14 * Prepare a name to identify a callable element.
16 * @param mixed $callback
19 public static function formatName($callback): string {
20 $normalizeNamespace = function($symbol) {
21 return $symbol{0} === '\\' ?
substr($symbol, 1) : $symbol;
23 if (is_array($callback)) {
26 return $normalizeNamespace(get_class($a)) . "->$b(\$e)";
28 elseif (is_string($a)) {
29 return $normalizeNamespace($a) . "::$b(\$e)";
32 elseif (is_string($callback)) {
33 return $normalizeNamespace($callback) . '(\$e)';
35 elseif ($callback instanceof ServiceListener ||
$callback instanceof HookStyleListener
) {
36 return (string) $callback;
40 $f = new \
ReflectionFunction($callback);
41 return 'closure<' . $f->getFileName() . '@' . $f->getStartLine() . '>($e)';
43 catch (\ReflectionException
$e) {
47 return 'unidentified';