mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Require Closures in more places instead of callable
Non-closure callables have strange context-dependent behaviour and are slower to call than a closure. It's possible to use Closure::fromCallable() in the origin scope, which guarantees that the callable will remain callable no matter where it's used.
This commit is contained in:
@ -27,7 +27,7 @@ use pocketmine\utils\Utils;
|
||||
use function array_push;
|
||||
|
||||
class CompressBatchPromise{
|
||||
/** @var callable[] */
|
||||
/** @var \Closure[] */
|
||||
private $callbacks = [];
|
||||
|
||||
/** @var string|null */
|
||||
@ -36,7 +36,7 @@ class CompressBatchPromise{
|
||||
/** @var bool */
|
||||
private $cancelled = false;
|
||||
|
||||
public function onResolve(callable ...$callbacks) : void{
|
||||
public function onResolve(\Closure ...$callbacks) : void{
|
||||
$this->checkCancelled();
|
||||
foreach($callbacks as $callback){
|
||||
Utils::validateCallableSignature(function(CompressBatchPromise $promise){}, $callback);
|
||||
@ -64,7 +64,7 @@ class CompressBatchPromise{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return callable[]
|
||||
* @return \Closure[]
|
||||
*/
|
||||
public function getResolveCallbacks() : array{
|
||||
return $this->callbacks;
|
||||
|
Reference in New Issue
Block a user