facebookarchive / pfff

Tools for code analysis, visualizations, or style-preserving source transformation.
http://github.com/facebook/pfff/wiki/Main
Other
2.44k stars 204 forks source link

Variadic parameters with type hint #154

Closed soutaro closed 7 years ago

soutaro commented 7 years ago

This PR is to support variadic parameters with type hint.

function foo(int ...$xs) {
  return $xs[0];
}

Variadic parameters will have array type concerning its type hint. The return type of foo will be int in the example.

Typing function(1/0)[0]: foo
^Fun:foo = fun (array(int => int) $xs) -> int

This would improve the precision of analysis of function body. However, application of foo still have an issue. Typing foo(a) tells a is array of int, not int.