/**
* @phpstan-type MyType<T> array{create: callable(): T, test: callable(T): void}
*/
class HelloWorld
{
/**
* @template U
* @param MyType<U> $case
* @return U
*/
public static function takesMyType(array $case): mixed
{
$theThing = $case['create']();
$case['test']($theThing);
return $theThing;
}
}
Feature request
Local type aliases (
@phpstan-type Foo 'a'|'b') should be allowed to be generic:https://phpstan.org/r/9dd37e37-8838-4b9d-ac79-45ed361cbf55
The equivalent TypeScript code with usage examples