From 16fa9584164c18f682435f0e84dc90e9155c3df4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 27 Jan 2021 19:25:28 +0000 Subject: [PATCH] phpstan: better hack for any-callable parameters variadics are a bad fit for this because what we really need is to accept callable with any number of arguments. LSP requires that the provided number of arguments must be >= than the required number of arguments. --- phpstan.neon.dist | 6 ++++++ src/pocketmine/utils/Utils.php | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index adab63b58..7586d7e11 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -42,3 +42,9 @@ parameters: reportUnmatchedIgnoredErrors: false #no other way to silence platform-specific non-warnings staticReflectionClassNamePatterns: - "#^COM$#" + typeAliases: + #variadics don't work for this - mixed probably shouldn't work either, but for now it does + #what we actually need is something that accepts an infinite number of parameters, but in the absence of that, + #we'll just fill it with 10 - it's very unlikely to encounter a callable with 10 parameters anyway. + anyCallable: 'callable(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed) : mixed' + anyClosure: '\Closure(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed) : mixed' diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 53ca56490..5e8deeb81 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -117,7 +117,7 @@ class Utils{ /** * Generates an unique identifier to a callable * - * @phpstan-param callable(mixed...) : mixed $variable + * @phpstan-param anyCallable $variable * * @return string */ @@ -134,7 +134,7 @@ class Utils{ /** * Returns a readable identifier for the given Closure, including file and line. * - * @phpstan-param \Closure(mixed...) : mixed $closure + * @phpstan-param anyClosure $closure * @throws \ReflectionException */ public static function getNiceClosureName(\Closure $closure) : string{ @@ -688,8 +688,8 @@ class Utils{ * * @param callable $signature Dummy callable with the required parameters and return type * @param callable $subject Callable to check the signature of - * @phpstan-param callable(mixed...) : mixed $signature - * @phpstan-param callable(mixed...) : mixed $subject + * @phpstan-param anyCallable $signature + * @phpstan-param anyCallable $subject * * @throws \DaveRandom\CallbackValidator\InvalidCallbackException * @throws \TypeError