Automattic\WooCommerce\Utilities

CallbackUtil::get_closure_signatureprivate staticWC 1.0

Get a stable signature for a closure based on its file path and line numbers.

Метод класса: CallbackUtil{}

Хуков нет.

Возвращает

Строку. Signature in the format 'Closure@filename:startLine-endLine'.

Использование

$result = CallbackUtil::get_closure_signature( $closure ): string;
$closure(Closure) (обязательный)
The closure to generate a signature for.

Код CallbackUtil::get_closure_signature() WC 10.5.2

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 );
}