/** * Returns new partial function which will behave like $function with * predefined right arguments passed to rpartial * * @param callable $function * @param mixed $arg1 * @param mixed $arg2 * @param mixed ... * @return callable */ function rpartial(callable $function, $arg1) { $args = array_slice(func_get_args(), 1); return function () use($function, $args) { return call_user_func_array($function, a\extend(func_get_args(), $args)); }; }
public function testExtend() { $this->assertEquals([1, 2, 3, 4, 5, 6], extend([1, 2, 3], [4, 5, 6])); $this->assertEquals([1, 2, 3, 3, 4, 5], extend([1, 2, 3], [3, 4, 5])); $this->assertEquals([1, 2, 3, 3, 4, 5], extend(new \ArrayIterator([1, 2, 3]), [3, 4, 5])); $this->assertEquals([1, 2, 3, 3, 4, 5], extend([1, 2, 3], new \ArrayIterator([3, 4, 5]))); $this->assertEquals([4, 5, 6], extend([], [4, 5, 6])); $this->assertEquals([1, 2, 3], extend([1, 2, 3], [])); $this->assertEquals([1, 2, 3, 4, 5, 6], call_user_func(extend, [1, 2, 3], [4, 5, 6])); $this->assertEquals('\\nspl\\a\\merge', extend); }