Skip to content

Commit a5d9b45

Browse files
authored
[8.x] Support value callback arguments (#36506)
* test * feature: support value function callback arguments
1 parent 92a1ce8 commit a5d9b45

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Illuminate/Collections/helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ function last($array)
179179
* @param mixed $value
180180
* @return mixed
181181
*/
182-
function value($value)
182+
function value($value, ...$args)
183183
{
184-
return $value instanceof Closure ? $value() : $value;
184+
return $value instanceof Closure ? $value(...$args) : $value;
185185
}
186186
}

tests/Support/SupportHelpersTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public function testValue()
4040
$this->assertSame('foo', value(function () {
4141
return 'foo';
4242
}));
43+
$this->assertSame('foo', value(function ($arg) {
44+
return $arg;
45+
}, 'foo'));
4346
}
4447

4548
public function testObjectGet()

0 commit comments

Comments
 (0)