Exemplo n.º 1
0
 public function testPassNoFunctions()
 {
     $input = range(0, 10);
     $composed = compose();
     $composed_values = array_map(function ($x) use($composed) {
         return $composed($x);
     }, $input);
     $this->assertEquals($composed_values, $input);
 }
/**
 * Returns a comparison function that can be used with e.g. `usort()`
 *
 * @param callable $comparison A function that compares the two values. Pick e.g. strcmp() or strnatcasecmp()
 * @param callable $keyFunction A function that takes an argument and returns the value that should be compared
 * @return callable
 */
function compare_object_hash_on(callable $comparison, callable $keyFunction = null)
{
    $keyFunction = $keyFunction ? compose($keyFunction, 'spl_object_hash') : 'spl_object_hash';
    return compare_on($comparison, $keyFunction);
}