예제 #1
0
파일: f.php 프로젝트: rakesh-mohanta/Nspl
/**
 * 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));
    };
}
예제 #2
0
파일: ATest.php 프로젝트: ihor/Nspl
 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);
 }