Call the given Closure with the given value then return the value.

@param  mixed  $value
@param  callable|null  $callback
@return mixed
193393
public static function tap($value, $callback = null)
	{
		if(is_null($callback))
		{
			return new HigherOrderTapProxy($value);
		}
		$callback($value);
		return $value;
	}
702484
function wrap(value, callback) {
  return Promise.resolve(value).then(
    obj => {
      if (callback) {
        callback(null, obj);
      }
      return obj;
    },
    err => {
      if (callback) {
        callback(err);
      }
      throw err;
    }
  );
}
1053815
public function first(callable $callback = null, $default = null)
    {
        if (is_null($callback)) {
            return empty($this->items) ? $default : reset($this->items);
        }

        foreach ($this->items as $key => $value) {
            if (call_user_func($callback, $value, $key)) {
                return $value;
            }
        }

        return $default;
    }
953035
public function value(callable $callback, $value, $key = null): void
    {
        $input = $this->resolve($value);

        if (!$input->isValid()) {
            return;
        }

        call_user_func($callback, $input->value(), $key);
    }
507365
public static function help(callable $callback = null){
        $callback
          ? is_callable($callback) && static::$help = $callback
          : static::$help && call_user_func(static::$help);
    }
174198
public function max(?callable $callback = null)
    {
        return $this->reduce(function ($result, $value, $key) use ($callback) {
            if ($callback !== null) {
                $value = $callback($value, $key);
            }

            return ($result === null) || $value > $result ? $value : $result;
        });
    }
223809
public function extend(Closure $callback)
    {
        $instance = $this->retrieve();
        call_user_func($callback, $instance);

        return $instance;
    }
989458
private function remember($key, Closure $callback)
    {
        $value = $this->cache->get($key);

        if ($value !== null) {
            return $value;
        }

        $this->cache->set($key, $value = $callback());

        return $value;
    }
560645
public function pretend( Closure $callback ) {
		return $this->withFreshQueryLog( function () use ( $callback ) {
			$this->pretending = true;

			// Basically to make the database connection "pretend", we will just return
			// the default values for all the query methods, then we will return an
			// array of queries that were "executed" within the Closure callback.
			$callback( $this );

			$this->pretending = false;

			return $this->getLogger()->getQueryLog();
		} );
	}
1328994
public function getCallable($value)
    {
        if (is_string($value)) {
            $callable = $this->validateCallable([strpos($value, '::') ? explode('::', $value) : $value]);
        } else if (is_array($value) && count($value) === 1 && isset($value[0]) && is_string($value[0])) {
            $callable = $this->validateCallable([strpos($value[0], '::') ? explode('::', $value[0]) : $value[0]]);
        } else if (is_array($value) && count($value) === 2 && isset($value[0]) && is_string($value[0]) && isset($value[1]) && is_array($value[1])) {
            $callable = $this->validateCallable([strpos($value[0], '::') ? explode('::', $value[0]) : $value[0], $value[1]]);
        } else if (is_array($value) && count($value) === 2 && isset($value[0]) && isset($value[1])) {
            $callable = $this->validateCallable([$value]);
        } else if (is_array($value) && count($value) === 3 && isset($value[0]) && isset($value[1]) && isset($value[2])) {
            $callable = $this->validateCallable([[$value[0], $value[1]], $value[2]]);
        } else {
            $callable = null;
        }

        if (is_array($callable)) {
            $name = is_array($callable[0]) ? $callable[0][0] : $callable[0];
            $method = is_array($callable[0]) ? $callable[0][1] : null;
            $args = isset($callable[1]) ? $callable[1] : [];

            if (is_object($name)) {
                $object = $name;
            } else if ($this->container->has($name)) {
                $object = $this->container->get($name);
            } else if (is_callable($name.'::'.$method)) {
                return [$name.'::'.$method, $args];
            } else {
                return false;
            }
            if (is_null($method)) {
                return [$object, $args];
            } else {
                return [[$object, $method], $args];
            }
        }
        return false;
    }
937953
public function set($key, $value = null)
    {
        if (func_num_args() === 1) {
            $key === '{}' && $key = json_decode('{}');
            $this->results = $key;
            return;
        }

        if ($value instanceof Closure) {
            $factory = $this->getFactory();
            $value($factory);
            $this->results[$key] = $factory->getResults();
            return $this;
        }

        $value === '{}' && $value = json_decode('{}');
        $this->results[$key] = $value;

        return $this;
    }
942734
public function setCallbackWrapper(?callable $callbackWrapper): callable
    {
        $previousWrapper = $this->callbackWrapper;
        $this->callbackWrapper = $callbackWrapper ?? function (callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, \Closure $setMetadata, ?LoggerInterface $logger) {
            return $callback($item, $save);
        };

        return $previousWrapper;
    }
914261
protected function getCallable($value, $key)
    {
        // If the value is a string, a registrar is set and the value is
        // registred with the registrar, resolve it there.
        if (
            is_string($value) &&
            $this->hasRegistrar() &&
            $this->registrar->isRegistred($value)
        ) {
            $value = $this->registrar->resolve($value);
        }

        // If the value is now a callable, go ahead and return it...
        if (is_callable($value)) {
            return $value;
        }

        // However, if we've got an object and a filter method for the key
        // exists, we'll return that as a callable.
        if (
            is_object($value) &&
            method_exists($value, $method = $this->getFilterMethodName($key))
        ) {
            return [$value, $method];
        }

        throw new InvalidArgumentException(sprintf(
            'Could not resolve callable for [%s]', $value
        ));
    }
346606
protected function getCallback($callback)
	{
		if ( ! is_null($callback)) return $callback;

		$me = $this;

		return function($line) use ($me) { $me->display($line); };
	}
457542
public static function transform($value, callable $callback, $default = null)
    {
        if (self::filled($value)) {
            return $callback($value);
        }

        if (\is_callable($default)) {
            return $default($value);
        }

        return $default;
    }
890885
public static function object(\Closure $callback) {
		$obj = new Object;
		$callback->__invoke($obj);
		return json_encode($obj);
	}
341296
private function _first(callable $callback = null)
    {
        $values = $this->getValues();
        if ($callback){
            foreach($values as $key => $value){
                if ($callback($value, $key)){
                    return $value;
                }
            }
        }
        else{
            return empty($values) ? null : $values[0];
        }
        return null;
    }