Skip to content

Commit b68fbf4

Browse files
committed
Add support for short methods.
1 parent 2eca4d2 commit b68fbf4

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Basic short functions return values.
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
8+
public function __construct(private int $b) {}
9+
10+
public function addUp(int $a) => $a + $this->b;
11+
}
12+
13+
$t = new Test(1);
14+
15+
print $t->addUp(5);
16+
17+
?>
18+
--EXPECT--
19+
6

Zend/zend_language_parser.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ absolute_trait_method_reference:
927927
method_body:
928928
';' /* abstract method */ { $$ = NULL; }
929929
| '{' inner_statement_list '}' { $$ = $2; }
930+
| T_DOUBLE_ARROW inner_statement { $$ = zend_ast_create(ZEND_AST_RETURN, $2); }
930931
;
931932

932933
variable_modifiers:

0 commit comments

Comments
 (0)