编辑:Hooks.php
<?php /** * Handles adding and dispatching events * * @package Requests\EventDispatcher */ namespace WpOrg\Requests; use WpOrg\Requests\Exception\InvalidArgument; use WpOrg\Requests\HookManager; use WpOrg\Requests\Utility\InputValidator; /** * Handles adding and dispatching events * * @package Requests\EventDispatcher */ class Hooks implements HookManager { /** * Registered callbacks for each hook * * @var array */ protected $hooks = []; /** * Register a callback for a hook * * @param string $hook Hook name * @param callable $callback Function/method to call on event * @param int $priority Priority number. <0 is executed earlier, >0 is executed later * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $hook argument is not a string. * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $callback argument is not callable. * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $priority argument is not an integer. */ public function register($hook, $callback, $priority = 0) { if (is_string($hook) === false) { throw InvalidArgument::create(1, '$hook', 'string', gettype($hook)); } if (is_callable($callback) === false) { throw InvalidArgument::create(2, '$callback', 'callable', gettype($callback)); } if (InputValidator::is_numeric_array_key($priority) === false) { throw InvalidArgument::create(3, '$priority', 'integer', gettype($priority)); } if (!isset($this->hooks[$hook])) { $this->hooks[$hook] = [ $priority => [], ]; } elseif (!isset($this->hooks[$hook][$priority])) { $this->hooks[$hook][$priority] = []; } $this->hooks[$hook][$priority][] = $callback; } /** * Dispatch a message * * @param string $hook Hook name * @param array $parameters Parameters to pass to callbacks * @return boolean Successfulness * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $hook argument is not a string. * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $parameters argument is not an array. */ public function dispatch($hook, $parameters = []) { if (is_string($hook) === false) { throw InvalidArgument::create(1, '$hook', 'string', gettype($hook)); } // Check strictly against array, as Array* objects don't work in combination with `call_user_func_array()`. if (is_array($parameters) === false) { throw InvalidArgument::create(2, '$parameters', 'array', gettype($parameters)); } if (empty($this->hooks[$hook])) { return false; } if (!empty($parameters)) { // Strip potential keys from the array to prevent them being interpreted as parameter names in PHP 8.0. $parameters = array_values($parameters); } ksort($this->hooks[$hook]); foreach ($this->hooks[$hook] as $priority => $hooked) { foreach ($hooked as $callback) { $callback(...$parameters); } } return true; } public function __wakeup() { throw new \LogicException( __CLASS__ . ' should never be unserialized' ); } }
保存文件
位置:
home
/
fembzvrs
/
zimeza.com
/
wp-includes
/
Requests
/
src
批量上传
创建
创建
批量权限
批量删除
名称
权限
大小
修改时间
操作
↑ 返回上级
-
-
-
-
Auth
drwxr-xr-x
-
2025-12-21 04:18
权限
删除
重命名
Cookie
drwxr-xr-x
-
2025-07-06 02:11
权限
删除
重命名
Exception
drwxr-xr-x
-
2026-05-14 04:25
权限
删除
重命名
Proxy
drwxr-xr-x
-
2025-12-21 04:18
权限
删除
重命名
Response
drwxr-xr-x
-
2025-12-21 04:18
权限
删除
重命名
Transport
drwxr-xr-x
-
2025-12-21 04:18
权限
删除
重命名
Capability.php
-rw-r--r--
652 B
2023-04-05 17:12
编辑
下载
权限
删除
重命名
Cookie.php
-rw-r--r--
15.03 KB
2024-03-25 16:23
编辑
下载
权限
删除
重命名
Hooks.php
-rw-r--r--
2.96 KB
2023-10-12 16:34
编辑
下载
权限
删除
重命名
Ipv6.php
-rw-r--r--
5.51 KB
2022-12-16 02:32
编辑
下载
权限
删除
重命名
Iri.php
-rw-r--r--
28.93 KB
2023-10-12 16:34
编辑
下载
权限
删除
重命名
Proxy.php
-rw-r--r--
867 B
2022-12-16 02:32
编辑
下载
权限
删除
重命名
Requests.php
-rw-r--r--
33.2 KB
2024-03-25 16:23
编辑
下载
权限
删除
重命名
Session.php
-rw-r--r--
8.89 KB
2023-10-12 16:34
编辑
下载
权限
删除
重命名
Ssl.php
-rw-r--r--
5.3 KB
2022-12-16 02:32
编辑
下载
权限
删除
重命名
Transport.php
-rw-r--r--
1.51 KB
2022-12-16 02:32
编辑
下载
权限
删除
重命名
error_log
-rw-r--r--
75.41 KB
2026-05-14 03:05
编辑
下载
权限
删除
重命名