/home/techb158/l2hypotheques.com/wp-content/plugins/woocommerce/src/Utilities
Edit: /home/techb158/l2hypotheques.com/wp-content/plugins/woocommerce/src/Utilities/CallbackUtil.php (4504B)
> Array of priority => array( signatures ), empty if hook has no callbacks.
*
* @since 10.5.0
*/
public static function get_hook_callback_signatures( string $hook_name ): array {
global $wp_filter;
if ( ! isset( $wp_filter[ $hook_name ] ) ) {
return array();
}
$result = array();
foreach ( $wp_filter[ $hook_name ]->callbacks as $priority => $priority_callbacks ) {
$result[ $priority ] = array_map(
fn( $callback_data ) => self::get_callback_signature( $callback_data['function'] ),
array_values( $priority_callbacks )
);
}
return $result;
}
/**
* Get a stable signature for a closure based on its file path and line numbers.
*
* @param \Closure $closure The closure to generate a signature for.
* @return string Signature in the format 'Closure@filename:startLine-endLine'.
* @throws \ReflectionException If reflection fails.
*/
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 );
}
/**
* Get a stable signature for an invokable object based on its class and __invoke method location.
*
* For regular classes, returns 'ClassName::__invoke' since the class name is stable.
* For anonymous classes, includes file location since the class name varies between requests.
*
* @param object $invokable The invokable object to generate a signature for.
* @return string Signature in format 'ClassName::__invoke' or 'class@anonymous[hash]::__invoke@filename:startLine-endLine'.
*/
private static function get_invokable_signature( object $invokable ): string {
$method = new \ReflectionMethod( $invokable, '__invoke' );
$class = $method->getDeclaringClass();
if ( ! $class->isAnonymous() ) {
return $class->getName() . '::__invoke';
}
return sprintf(
'class@anonymous[%s]::__invoke@%s:%d-%d',
md5( $class->getName() ),
$method->getFileName(),
$method->getStartLine(),
$method->getEndLine()
);
}
}