ClosureTask: relax closure checks to allow arrow functions without return typehints

nobody uses return typehints on arrow functions anyway .. they just waste space.
This commit is contained in:
Dylan K. Taylor 2021-10-10 23:31:57 +01:00
parent 912e612743
commit 2696698926
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -23,6 +23,8 @@ declare(strict_types=1);
namespace pocketmine\scheduler;
use DaveRandom\CallbackValidator\CallbackType;
use DaveRandom\CallbackValidator\ReturnType;
use pocketmine\utils\Utils;
/**
@ -49,7 +51,7 @@ class ClosureTask extends Task{
* @phpstan-param \Closure() : void $closure
*/
public function __construct(\Closure $closure){
Utils::validateCallableSignature(function() : void{}, $closure);
Utils::validateCallableSignature(new CallbackType(new ReturnType()), $closure);
$this->closure = $closure;
}