mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 03:51:37 +00:00
Update CallbackValidator
This commit is contained in:
8
composer.lock
generated
8
composer.lock
generated
@@ -349,12 +349,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/CallbackValidator.git",
|
||||
"reference": "4b9b375590872cdd98a2a07c5aa0e1e99af5ceda"
|
||||
"reference": "8e0e3be58e89c2611beac9c6954a036b81b2b6fc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/CallbackValidator/zipball/4b9b375590872cdd98a2a07c5aa0e1e99af5ceda",
|
||||
"reference": "4b9b375590872cdd98a2a07c5aa0e1e99af5ceda",
|
||||
"url": "https://api.github.com/repos/pmmp/CallbackValidator/zipball/8e0e3be58e89c2611beac9c6954a036b81b2b6fc",
|
||||
"reference": "8e0e3be58e89c2611beac9c6954a036b81b2b6fc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -391,7 +391,7 @@
|
||||
"issues": "https://github.com/pmmp/CallbackValidator/issues",
|
||||
"source": "https://github.com/pmmp/CallbackValidator/tree/rewrite"
|
||||
},
|
||||
"time": "2025-01-03T17:50:24+00:00"
|
||||
"time": "2025-10-10T21:55:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/color",
|
||||
|
@@ -554,14 +554,16 @@ final class Utils{
|
||||
* Verifies that the given callable is compatible with the desired signature. Throws a TypeError if they are
|
||||
* incompatible.
|
||||
*
|
||||
* @param \Closure $signature Dummy callable with the required parameters and return type
|
||||
* @param Prototype|\Closure $signature Dummy callable with the required parameters and return type, or a manually constructed Prototype
|
||||
* @param \Closure $subject Callable to check the signature of
|
||||
* @phpstan-param anyClosure $signature
|
||||
* @phpstan-param anyClosure $subject
|
||||
*/
|
||||
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) . "`");
|
||||
public static function validateCallableSignature(Prototype|\Closure $signature, \Closure $subject) : void{
|
||||
$signaturePrototype = $signature instanceof Prototype ? $signature : Prototype::fromClosure($signature);
|
||||
$subjectPrototype = Prototype::fromClosure($subject);
|
||||
if(!$signaturePrototype->isSatisfiedBy($subjectPrototype)){
|
||||
throw new \TypeError("Declaration of callable `$subjectPrototype` must be compatible with `$signaturePrototype`");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user