Skip to content

Commit 268c79e

Browse files
committed
Verify first-class callables can be used as parameter defaults
See https://wiki.php.net/rfc/closures_in_const_expr#future_scope
1 parent 11b7f1a commit 268c79e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/test/php/lang/ast/unittest/emit/ParameterTest.class.php

+6
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ public function closure_as_default() {
135135
Assert::equals(2, $function(1));
136136
}
137137

138+
#[Test]
139+
public function first_class_callable_as_default() {
140+
$function= $this->param('$op= strlen(...)')->default();
141+
Assert::equals(4, $function('Test'));
142+
}
143+
138144
#[Test]
139145
public function trailing_comma_allowed() {
140146
$p= $this->declare('class %T { public function fixture($param, ) { } }')

0 commit comments

Comments
 (0)