mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 11:58:00 +00:00
@@ -27,7 +27,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\utils;
|
||||
|
||||
use DaveRandom\CallbackValidator\CallbackType;
|
||||
use DaveRandom\CallbackValidator\Prototype;
|
||||
use pocketmine\entity\Location;
|
||||
use pocketmine\errorhandler\ErrorTypeToStringMap;
|
||||
use pocketmine\math\Vector3;
|
||||
@@ -554,20 +554,14 @@ final class Utils{
|
||||
* Verifies that the given callable is compatible with the desired signature. Throws a TypeError if they are
|
||||
* incompatible.
|
||||
*
|
||||
* @param callable|CallbackType $signature Dummy callable with the required parameters and return type
|
||||
* @param callable $subject Callable to check the signature of
|
||||
* @phpstan-param anyCallable|CallbackType $signature
|
||||
* @phpstan-param anyCallable $subject
|
||||
*
|
||||
* @throws \DaveRandom\CallbackValidator\InvalidCallbackException
|
||||
* @throws \TypeError
|
||||
* @param \Closure $signature Dummy callable with the required parameters and return type
|
||||
* @param \Closure $subject Callable to check the signature of
|
||||
* @phpstan-param anyClosure $signature
|
||||
* @phpstan-param anyClosure $subject
|
||||
*/
|
||||
public static function validateCallableSignature(callable|CallbackType $signature, callable $subject) : void{
|
||||
if(!($signature instanceof CallbackType)){
|
||||
$signature = CallbackType::createFromCallable($signature);
|
||||
}
|
||||
if(!$signature->isSatisfiedBy($subject)){
|
||||
throw new \TypeError("Declaration of callable `" . CallbackType::createFromCallable($subject) . "` must be compatible with `" . $signature . "`");
|
||||
public static function validateCallableSignature(\Closure $signature, \Closure $subject) : void{
|
||||
if(!Prototype::isSatisfiedBy($signature, $subject)){
|
||||
throw new \TypeError("Declaration of callable `" . Prototype::print($subject) . "` must be compatible with `" . Prototype::print($signature) . "`");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user