mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 17:06:16 +00:00
@ -38,7 +38,7 @@
|
||||
"pocketmine/bedrock-item-upgrade-schema": "~1.15.0+bedrock-1.21.100",
|
||||
"pocketmine/bedrock-protocol": "~40.0.0+bedrock-1.21.100",
|
||||
"pocketmine/binaryutils": "^0.2.1",
|
||||
"pocketmine/callback-validator": "^1.0.2",
|
||||
"pocketmine/callback-validator": "dev-rewrite",
|
||||
"pocketmine/color": "^0.3.0",
|
||||
"pocketmine/errorhandler": "^0.7.0",
|
||||
"pocketmine/locale-data": "~2.25.0",
|
||||
|
23
composer.lock
generated
23
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "326e0882230a0614d3dd2f0dce8e2efc",
|
||||
"content-hash": "deb7c003ba4a6101153256d5d590da42",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/json-comment",
|
||||
@ -344,30 +344,30 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/callback-validator",
|
||||
"version": "1.0.3",
|
||||
"version": "dev-rewrite",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/CallbackValidator.git",
|
||||
"reference": "64787469766bcaa7e5885242e85c23c25e8c55a2"
|
||||
"reference": "4b9b375590872cdd98a2a07c5aa0e1e99af5ceda"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/CallbackValidator/zipball/64787469766bcaa7e5885242e85c23c25e8c55a2",
|
||||
"reference": "64787469766bcaa7e5885242e85c23c25e8c55a2",
|
||||
"url": "https://api.github.com/repos/pmmp/CallbackValidator/zipball/4b9b375590872cdd98a2a07c5aa0e1e99af5ceda",
|
||||
"reference": "4b9b375590872cdd98a2a07c5aa0e1e99af5ceda",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-reflection": "*",
|
||||
"php": "^7.1 || ^8.0"
|
||||
"php": "^8.1"
|
||||
},
|
||||
"replace": {
|
||||
"daverandom/callback-validator": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/extension-installer": "^1.0",
|
||||
"phpstan/phpstan": "0.12.59",
|
||||
"phpstan/phpstan-strict-rules": "^0.12.4",
|
||||
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.0"
|
||||
"phpstan/phpstan": "2.1.0",
|
||||
"phpstan/phpstan-strict-rules": "^2.0",
|
||||
"phpunit/phpunit": "^9.0 || ^10.0 || ^11.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@ -388,9 +388,9 @@
|
||||
"description": "Fork of daverandom/callback-validator - Tools for validating callback signatures",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/CallbackValidator/issues",
|
||||
"source": "https://github.com/pmmp/CallbackValidator/tree/1.0.3"
|
||||
"source": "https://github.com/pmmp/CallbackValidator/tree/rewrite"
|
||||
},
|
||||
"time": "2020-12-11T01:45:37+00:00"
|
||||
"time": "2025-01-03T17:50:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/color",
|
||||
@ -2734,6 +2734,7 @@
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"pocketmine/callback-validator": 20,
|
||||
"pocketmine/math": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
|
@ -23,9 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\entity;
|
||||
|
||||
use DaveRandom\CallbackValidator\CallbackType;
|
||||
use DaveRandom\CallbackValidator\ParameterType;
|
||||
use DaveRandom\CallbackValidator\ReturnType;
|
||||
use pocketmine\block\RuntimeBlockStateRegistry;
|
||||
use pocketmine\data\bedrock\LegacyEntityIdToStringIdMap;
|
||||
use pocketmine\data\bedrock\PotionTypeIdMap;
|
||||
@ -206,11 +203,7 @@ final class EntityFactory{
|
||||
throw new \InvalidArgumentException("At least one save name must be provided");
|
||||
}
|
||||
Utils::testValidInstance($className, Entity::class);
|
||||
Utils::validateCallableSignature(new CallbackType(
|
||||
new ReturnType(Entity::class),
|
||||
new ParameterType("world", World::class),
|
||||
new ParameterType("nbt", CompoundTag::class)
|
||||
), $creationFunc);
|
||||
Utils::validateCallableSignature(fn(World $world, CompoundTag $nbt) : Entity => die(), $creationFunc);
|
||||
|
||||
foreach($saveNames as $name){
|
||||
$this->creationFuncs[$name] = $creationFunc;
|
||||
|
@ -23,9 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item\enchantment;
|
||||
|
||||
use DaveRandom\CallbackValidator\CallbackType;
|
||||
use DaveRandom\CallbackValidator\ParameterType;
|
||||
use DaveRandom\CallbackValidator\ReturnType;
|
||||
use pocketmine\lang\Translatable;
|
||||
use pocketmine\utils\NotCloneable;
|
||||
use pocketmine\utils\NotSerializable;
|
||||
@ -55,10 +52,7 @@ class Enchantment{
|
||||
){
|
||||
$this->minEnchantingPower = $minEnchantingPower ?? fn(int $level) : int => 1;
|
||||
|
||||
Utils::validateCallableSignature(new CallbackType(
|
||||
new ReturnType("int"),
|
||||
new ParameterType("level", "int")
|
||||
), $this->minEnchantingPower);
|
||||
Utils::validateCallableSignature(fn(int $level) : int => die(), $this->minEnchantingPower);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,8 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
use DaveRandom\CallbackValidator\CallbackType;
|
||||
use DaveRandom\CallbackValidator\ReturnType;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
/**
|
||||
@ -46,7 +44,7 @@ class ClosureTask extends Task{
|
||||
public function __construct(
|
||||
private \Closure $closure
|
||||
){
|
||||
Utils::validateCallableSignature(new CallbackType(new ReturnType()), $closure);
|
||||
Utils::validateCallableSignature(function() : void{}, $closure);
|
||||
}
|
||||
|
||||
public function getName() : string{
|
||||
|
@ -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) . "`");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ class BlockTransaction{
|
||||
* @phpstan-param \Closure(ChunkManager $world, int $x, int $y, int $z) : bool $validator
|
||||
*/
|
||||
public function addValidator(\Closure $validator) : void{
|
||||
Utils::validateCallableSignature([$this, 'dummyValidator'], $validator);
|
||||
Utils::validateCallableSignature($this->dummyValidator(...), $validator);
|
||||
$this->validators[] = $validator;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user