bmewburn / vscode-intelephense

PHP intellisense for Visual Studio Code
https://intelephense.com
Other
1.62k stars 94 forks source link

Diagnostics for duplicate/redundant union types #1493

Open bmewburn opened 3 years ago

bmewburn commented 3 years ago

https://wiki.php.net/rfc/union_types_v2

To catch some simple bugs in union type declarations, redundant types that can be detected without performing class loading will result in a compile-time error. This includes: Each name-resolved type may only occur once. Types like int|string|INT result in an error. If bool is used, false cannot be used additionally. If object is used, class types cannot be used additionally. If iterable is used, array and Traversable cannot be used additionally. This does not guarantee that the type is “minimal”, because doing so would require loading all used class types. For example, if A and B are class aliases, then A|B remains a legal union type, even though it could be reduced to either A or B. Similarly, if class B extends A {}, then A|B is also a legal union type, even though it could be reduced to just A.

umairkhan-dev commented 3 years ago

@bmewburn Just a thought. Isn't 1.6 milestone better suited for this instead of shortlist.

bmewburn commented 3 years ago

The goal is to get 1.6 released in the next week or so. This may or may not make it in.