#1460·predis

Type parameter that are not currently typed

Author: kylekatarnlsCreated May 24, 2024Updated Mar 18, 2025
Labelsfeature

Is your feature request related to a problem? Please describe. Some methods, for instance setex have some untyped parameters $seconds and $value

  • Is there any other valid type than int for $seconds?
  • Is there any other relevant type than string for $value? AFAIK it always ends up being stored as string in Redis.

The reason why the absence of typing is a problem is because it's error-prone, new people discovering the library or the code using the libraries or older people who don't have a their knowledge of the library fresh might ask the questions above or other ones such as

  • Is this value nullable, if so what happens if I send null false here?
  • Is it really mixed? I can put array or object and they will get serialized?

Those are all doubts that can actually be cleared out right away if the type-hints reflect accurately what is relevant to be passed.

Describe the solution you'd like Method such as:

@method Status setex(string $key, $seconds, $value)

To be transformed into:

@method Status setex(string $key, int $seconds, string $value)

Describe alternatives you've considered Other ways I could think of to enforce types are:

  • quite tedious to implement
  • are not as good in term of discoverability