Automattic\WooCommerce\Utilities
CallbackUtil::get_closure_signature
Get a stable signature for a closure based on its file path and line numbers.
Method of the class: CallbackUtil{}
No Hooks.
Returns
String. Signature in the format 'Closure@filename:startLine-endLine'.
Usage
$result = CallbackUtil::get_closure_signature( $closure ): string;
- $closure(Closure) (required)
- The closure to generate a signature for.
CallbackUtil::get_closure_signature() CallbackUtil::get closure signature code WC 10.8.1
private static function get_closure_signature( \Closure $closure ): string {
$reflection = new \ReflectionFunction( $closure );
$file = $reflection->getFileName();
$start = $reflection->getStartLine();
$end = $reflection->getEndLine();
if ( false === $file || false === $start || false === $end ) {
throw new \ReflectionException( 'Unable to get closure location information' );
}
return sprintf( 'Closure@%s:%d-%d', $file, $start, $end );
}