-
-
Notifications
You must be signed in to change notification settings - Fork 946
Description
Feature request
The recent addition of type aliases in configuration file led me to a thought: sometimes I have complex types such as callables or array shapes that are repeated in a single file, and since they are internal to the file, I don't feel comfortable exposing them in a global phpstan.neon.
I'd like to be able to declare something like this at the top of the file:
/**
* @phpstan-type MyEventListener callable(very, complicated, callable, signature): void
*/and then just reference MyEventListener in docblocks in the same file.
I believe Psalm supports this to some extent via @psalm-type Alias=type, although it is apparently not documented.
"I may want to implement this" and in fact already have a working prototype of class-scoped aliases, i.e. you can specify a type alias in a class's docblock and use such alias within the class members docblocks. (This seemed to be the easiest direction to take and is imo a good first iteration.)
Before I polish and push the code, I'd like to get some feedback about the idea in general, firstly: is this something you'd want in PHPStan at all?