/**
 * Takes a function and returns a new function that wraps the callback and suppresses the PHP error
 *
 * @param callable $callback
 * @throws ErrorException Throws exception if PHP error happened
 * @return mixed
 */
function suppress_error(callable $callback)
{
    return function (...$arguments) use($callback) {
        try {
            set_error_handler(const_function(null));
            return $callback(...$arguments);
        } finally {
            restore_error_handler();
        }
    };
}
 public function testWithValue()
 {
     $const = const_function('value');
     $this->assertSame('value', $const());
 }
 public function testCompareWithReducer()
 {
     $compare = compare_object_hash_on('strcmp', const_function(new stdClass()));
     $this->assertSame(0, $compare($this, new stdClass()));
 }
 public function testCompareWithReducer()
 {
     $comparator = compare_on('strcmp', const_function(1));
     $this->assertSame(0, $comparator(0, 1));
 }