ClosureHelper.php
Namespace
Revolt\EventLoop\InternalFile
-
vendor/
revolt/ event-loop/ src/ EventLoop/ Internal/ ClosureHelper.php
View source
<?php
declare (strict_types=1);
namespace Revolt\EventLoop\Internal;
/** @internal */
final class ClosureHelper {
public static function getDescription(\Closure $closure) : string {
try {
$reflection = new \ReflectionFunction($closure);
$description = $reflection->name;
if ($scopeClass = $reflection->getClosureScopeClass()) {
$description = $scopeClass->name . '::' . $description;
}
if ($reflection->getFileName() && $reflection->getStartLine()) {
$description .= " defined in " . $reflection->getFileName() . ':' . $reflection->getStartLine();
}
return $description;
} catch (\ReflectionException) {
return '???';
}
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
ClosureHelper | @internal |