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:
Dylan K. Taylor
2019-05-27 17:11:35 +01:00
parent 2720ff9607
commit 7eb8d8e366
3 changed files with 9 additions and 9 deletions

View File

@ -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;