-
-
Notifications
You must be signed in to change notification settings - Fork 933
Closed
Labels
Milestone
Description
Feature request
When describing an array, you can write
array => Reported as an error level 6
array<string> => no errors
array<string, string> => no errors
If I wand to create a similar generic,
/**
* @phpstan-template TKey of array-key
* @phpstan-template TValue
*/
class MyArray {}
I didn't find a way to make a template param optionnal,
so MyArray<Foo>
is giving an error because I does not specify all template types
A syntax like
/**
* @phpstan-template ?TKey of array-key
* @phpstan-template TValue
*/
class MyArray {}
could be useful.
In order to avoid issue with
/**
* @phpstan-template ?T1
* @phpstan-template T2
* @phpstan-template ?T3
*/
we might decide that all the optional template should be last, and are filled in the order they are defined.
/**
* @phpstan-template T1
* @phpstan-template ?T2
* @phpstan-template ?T3
*/
Foo<T1> => Valid
Foo<T1, T2> => Valid
Foo<T1, T2, T3> => Valid
Foo<T1, T3> => Invalid
pbourdet, Seldaek, internalsystemerror, TemirkhanN, pascalheidmann and 7 more