phpstan-nette
phpstan-nette copied to clipboard
Added Nette\Caching\Cache dynamic return type extensions
Hi, I worry that some cases will not work well, for example:
/**
* @template TFallback
* @param mixed $key
* @param (callable(mixed): TFallback)|null $fallback
* @return TFallback
*/
public function load($key, callable $fallback = null)
If the fallback is not passed, we have an unresolved TFallback.
And in some other cases I'm not sure that callable(mixed)
is right, there might be none or more arguments passed.
Can we somehow tell that if no fallback is passed it should return null?
In source is this https://github.com/nette/caching/blob/be02f7e/src/Caching/Cache.php#L104, so the parameter should be only one?
- TFallback - nope, at that point you can't use generics, but need a dynamic return type extension instead.
- There are three
callable(mixed)
in the stubs, is it true for all of those? What's the diferrence betweenfn(&$dependencies)
andfn(...[&$dependencies])
?
- OK, introduced dynamic return type extensions for all previously stubbed methods
- i have no clue, im really lost in references in php :)