diff --git a/src/Utils/PartiallyAppliedFunction.php b/src/Utils/PartiallyAppliedFunction.php index 3d75cfd..29af323 100644 --- a/src/Utils/PartiallyAppliedFunction.php +++ b/src/Utils/PartiallyAppliedFunction.php @@ -48,7 +48,7 @@ class PartiallyAppliedFunction implements Decorator { $result = []; foreach ($this->arguments as $argument) { - $result[] = $argument === PLACEHOLDER + $result[] = $argument === PLACEHOLDER && !empty($args) ? array_shift($args) : $argument; } diff --git a/tests/PartialApplicationTest.php b/tests/PartialApplicationTest.php index d29c63e..e79406b 100644 --- a/tests/PartialApplicationTest.php +++ b/tests/PartialApplicationTest.php @@ -102,4 +102,13 @@ class PartialApplicationTest extends \PHPUnit\Framework\TestCase $this->assertEquals(6, $applied(3)); $this->assertEquals(24, $applied(4)); } + + public function testPartialApplicationOfAppliedFunctionWithPlaceholders() + { + + $applied = f\partial('array_merge', _, _, ['c']); + $double = f\partial($applied, ['a']); + + $this->assertEquals(['a', 'b', 'c', 'd'], $double(['b'], ['d'])); + } } \ No newline at end of file