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.
This commit is contained in:
Dylan K. Taylor 2021-01-27 19:25:28 +00:00
parent bac57c159f
commit 16fa958416
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 10 additions and 4 deletions

View File

@ -42,3 +42,9 @@ parameters:
reportUnmatchedIgnoredErrors: false #no other way to silence platform-specific non-warnings reportUnmatchedIgnoredErrors: false #no other way to silence platform-specific non-warnings
staticReflectionClassNamePatterns: staticReflectionClassNamePatterns:
- "#^COM$#" - "#^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'

View File

@ -117,7 +117,7 @@ class Utils{
/** /**
* Generates an unique identifier to a callable * Generates an unique identifier to a callable
* *
* @phpstan-param callable(mixed...) : mixed $variable * @phpstan-param anyCallable $variable
* *
* @return string * @return string
*/ */
@ -134,7 +134,7 @@ class Utils{
/** /**
* Returns a readable identifier for the given Closure, including file and line. * Returns a readable identifier for the given Closure, including file and line.
* *
* @phpstan-param \Closure(mixed...) : mixed $closure * @phpstan-param anyClosure $closure
* @throws \ReflectionException * @throws \ReflectionException
*/ */
public static function getNiceClosureName(\Closure $closure) : string{ 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 $signature Dummy callable with the required parameters and return type
* @param callable $subject Callable to check the signature of * @param callable $subject Callable to check the signature of
* @phpstan-param callable(mixed...) : mixed $signature * @phpstan-param anyCallable $signature
* @phpstan-param callable(mixed...) : mixed $subject * @phpstan-param anyCallable $subject
* *
* @throws \DaveRandom\CallbackValidator\InvalidCallbackException * @throws \DaveRandom\CallbackValidator\InvalidCallbackException
* @throws \TypeError * @throws \TypeError