mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
add some PHPStan-specific callable prototypes
This commit is contained in:
parent
e2871fad8e
commit
2b402e525a
@ -68,7 +68,10 @@ class AsyncPool{
|
||||
/** @var int[] */
|
||||
private $workerLastUsed = [];
|
||||
|
||||
/** @var \Closure[] */
|
||||
/**
|
||||
* @var \Closure[]
|
||||
* @phpstan-var (\Closure(int $workerId) : void)[]
|
||||
*/
|
||||
private $workerStartHooks = [];
|
||||
|
||||
public function __construct(Server $server, int $size, int $workerMemoryLimit, \ClassLoader $classLoader, \ThreadedLogger $logger){
|
||||
@ -100,6 +103,8 @@ class AsyncPool{
|
||||
* The signature should be `function(int $worker) : void`
|
||||
*
|
||||
* This function will call the hook for every already-running worker.
|
||||
*
|
||||
* @phpstan-param \Closure(int $workerId) : void $hook
|
||||
*/
|
||||
public function addWorkerStartHook(\Closure $hook) : void{
|
||||
Utils::validateCallableSignature(function(int $worker) : void{}, $hook);
|
||||
@ -111,6 +116,8 @@ class AsyncPool{
|
||||
|
||||
/**
|
||||
* Removes a previously-registered callback listening for workers being started.
|
||||
*
|
||||
* @phpstan-param \Closure(int $workerId) : void $hook
|
||||
*/
|
||||
public function removeWorkerStartHook(\Closure $hook) : void{
|
||||
unset($this->workerStartHooks[spl_object_hash($hook)]);
|
||||
|
@ -38,11 +38,15 @@ use pocketmine\utils\Utils;
|
||||
*/
|
||||
class ClosureTask extends Task{
|
||||
|
||||
/** @var \Closure */
|
||||
/**
|
||||
* @var \Closure
|
||||
* @phpstan-var \Closure(int) : void
|
||||
*/
|
||||
private $closure;
|
||||
|
||||
/**
|
||||
* @param \Closure $closure Must accept only ONE parameter, $currentTick
|
||||
* @phpstan-param \Closure(int) : void $closure
|
||||
*/
|
||||
public function __construct(\Closure $closure){
|
||||
Utils::validateCallableSignature(function(int $currentTick) : void{}, $closure);
|
||||
|
@ -183,6 +183,7 @@ class Internet{
|
||||
* @param string[] $extraHeaders extra headers to send as a plain string array
|
||||
* @param array $extraOpts extra CURLOPT_* to set as an [opt => value] map
|
||||
* @param callable|null $onSuccess function to be called if there is no error. Accepts a resource argument as the cURL handle.
|
||||
* @phpstan-param (callable(resource) : void)|null $onSuccess
|
||||
*
|
||||
* @return array a plain array of three [result body : string, headers : array[], HTTP response code : int]. Headers are grouped by requests with strtolower(header name) as keys and header value as values
|
||||
*
|
||||
|
@ -454,6 +454,7 @@ class Utils{
|
||||
* @param string[] $extraHeaders extra headers to send as a plain string array
|
||||
* @param array $extraOpts extra CURLOPT_* to set as an [opt => value] map
|
||||
* @param callable|null $onSuccess function to be called if there is no error. Accepts a resource argument as the cURL handle.
|
||||
* @phpstan-param (callable(resource) : void)|null $onSuccess
|
||||
*
|
||||
* @return array a plain array of three [result body : string, headers : array[], HTTP response code : int]. Headers are grouped by requests with strtolower(header name) as keys and header value as values
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user