REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 4.40 KB
Close
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/woocommerce/src/Utilities/CallbackUtil.php
Text
Base64
<?php declare(strict_types=1); namespace Automattic\WooCommerce\Utilities; /** * Utility class for working with WordPress hooks and callbacks. * * @since 10.5.0 */ final class CallbackUtil { /** * Get a stable signature for a callback that can be used for hashing. * * This method normalizes callbacks into consistent string representations, * regardless of changes in dynamic properties in callback instances. * * @param callable|mixed $callback A PHP callback. * @return string Normalized callback signature. * * @since 10.5.0 */ public static function get_callback_signature( $callback ): string { if ( is_string( $callback ) ) { // Standalone function. return $callback; } if ( is_array( $callback ) && 2 === count( $callback ) ) { $target = $callback[0]; $method = $callback[1]; if ( ( is_object( $target ) || is_string( $target ) ) && is_string( $method ) ) { // Array callback (class method). $class = is_object( $target ) ? get_class( $target ) : $target; return "{$class}::{$method}"; } } if ( $callback instanceof \Closure ) { // Closure. try { return self::get_closure_signature( $callback ); } catch ( \Exception $e ) { return 'Closure@' . spl_object_hash( $callback ); } } if ( is_object( $callback ) ) { // Invokable object. try { return self::get_invokable_signature( $callback ); } catch ( \Exception $e ) { return get_class( $callback ) . '::__invoke'; } } // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Fallback for unknown callback types. return serialize( $callback ); } /** * Get signatures for all callbacks attached to a specific hook. * * Returns an array of callback signatures for all callbacks registered * with the specified hook name, organized by priority. This is useful * for generating cache keys or comparing hook state. * * Closure signatures are based on their file location and line numbers, * providing consistent hashes across requests for the same closure code. * * @param string $hook_name The name of the hook to inspect. * @return array<int, array<string>> 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() ); } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 14
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
ArrayUtil.php
12.99 KB
lrw-r--r--
2025-05-12 21:07:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CallbackUtil.php
4.40 KB
lrw-r--r--
2026-01-19 14:46:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DiscountsUtil.php
1.10 KB
lrw-r--r--
2024-05-30 18:23:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
FeaturesUtil.php
5.19 KB
lrw-r--r--
2026-01-26 10:40:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
I18nUtil.php
1.69 KB
lrw-r--r--
2023-02-22 07:17:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
LoggingUtil.php
3.18 KB
lrw-r--r--
2024-08-27 23:04:44
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
MetaDataUtil.php
1.87 KB
lrw-r--r--
2026-05-05 14:26:50
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
NumberUtil.php
7.11 KB
lrw-r--r--
2025-07-29 12:34:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
OrderUtil.php
9.19 KB
lrw-r--r--
2025-11-24 23:10:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PluginUtil.php
12.99 KB
lrw-r--r--
2025-10-06 17:56:06
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RestApiUtil.php
5.01 KB
lrw-r--r--
2025-11-24 23:10:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ShippingUtil.php
1020 B
lrw-r--r--
2025-05-12 21:07:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
StringUtil.php
5.09 KB
lrw-r--r--
2024-06-04 15:20:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
TimeUtil.php
1.16 KB
lrw-r--r--
2024-01-30 23:24:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).