Permalink
Browse files

Adding type variables declaration for methods

Summary:
Up until now a function could have type variables:
function foo<T>( ...)
but we want this to work with methods too

Test Plan: unit test

Reviewers: pad

Differential Revision: https://phabricator.fb.com/D493001
  • Loading branch information...
pikatchu committed Jun 12, 2012
1 parent 5196e7f commit b17164e14a86afa558165341577f9a97cf3c4070
Showing with 3 additions and 2 deletions.
  1. +2 −2 lang_php/parsing/parser_php.mly
  2. +1 −0 lang_php/parsing/unit_parsing_php.ml
@@ -703,14 +703,14 @@ class_statement:
{ UseTrait ($1, $2, Right ($3, $4, $5)) }
method_declaration:
method_modifiers T_FUNCTION is_reference method_name
method_modifiers T_FUNCTION is_reference method_name type_params_opt
TOPAR parameter_list TCPAR
return_type_opt
method_body
{
Method {
m_modifiers = $1; m_tok = $2; m_ref = $3; m_name = Name $4;
m_params = ($5, $6, $7); m_return_type = $8; m_body = $9;
m_params = ($6, $7, $8); m_return_type = $9; m_body = $10;
}
}
@@ -166,6 +166,7 @@ let unittest =
t "class A { const ?A<T1, T2> X = 0; }";
t "$x = function(): ?int { return null; };";
t "function foo(A<A<int>> $x): ?int { return null; };";
t "class A { public static function foo<T>(): ?int { } }";
);
(*-----------------------------------------------------------------------*)

0 comments on commit b17164e

Please sign in to comment.