Skip to content

Commit

Permalink
fix HvyIndustries/crane#85 / function parameters can now contain expr…
Browse files Browse the repository at this point in the history
… statements
  • Loading branch information
ichiriac committed Jun 20, 2016
1 parent 49a5152 commit 69f3aec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/parser/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ module.exports = function(api, tokens, EOF) {
}
/**
* <ebnf>
* parameter ::= type? '&'? T_ELLIPSIS? T_VARIABLE ('=' scallar)?
* parameter ::= type? '&'? T_ELLIPSIS? T_VARIABLE ('=' expr)?
* </ebnf>
* @see https://github.com/php/php-src/blob/493524454d66adde84e00d249d607ecd540de99f/Zend/zend_language_parser.y#L640
*/
,read_parameter: function() {
var type = this.read_type();
Expand All @@ -126,7 +127,7 @@ module.exports = function(api, tokens, EOF) {
var name = this.expect(tokens.T_VARIABLE).text();
var value = [];
if (this.next().token == '=') {
value = this.next().read_scalar();
value = this.next().read_expr();
}
return [name, type, value, isRef, isVariadic];
}
Expand Down
2 changes: 2 additions & 0 deletions test/parser/function.parser
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Test function parser
--PASS--
function aa($a, $b = MY_CONST, $c = A | B) { }
--FAIL--
function aa();
--PASS ??--
Expand Down

0 comments on commit 69f3aec

Please sign in to comment.