Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

Commit

Permalink
Adding type variables declaration for methods
Browse files Browse the repository at this point in the history
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
julienv committed Jun 12, 2012
1 parent 5196e7f commit b17164e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lang_php/parsing/parser_php.mly
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
1 change: 1 addition & 0 deletions lang_php/parsing/unit_parsing_php.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 { } }";
);

(*-----------------------------------------------------------------------*)
Expand Down

0 comments on commit b17164e

Please sign in to comment.