Try to execute a closure sending an error if necessary

@param   callable $value The closure to call
@param   array $arguments The arguments to pass to the closure
@return  mixed The result of the execution if so
434987
public static function __closurable($value, array $arguments = array())
    {
        if (is_callable($value)) {
            try {
                $val = call_user_func_array($value, $arguments);
                return $val;
            } catch (Exception $e) {
                self::__error(sprintf('Closure error: "%s"!', $e->getMessage()), $e->getFile(), $e->getLine());
            }
        } else {
            return $value;
        }
    }
1110259
public static function copy($value){
		
		if(\is_object($value)){
			
			if(\is_callable($value)){
				return \Closure::bind($value, null);
			}
			
			return clone $value;
			
		}
		
		return $value;
		
	}
98064
public function evaluate($values)
    {
        $returnValue = (bool) false;

        if ($this->hasOption('function')) {
			$function = $this->getOption('function');
            if (function_exists($function)) {
                $callback = array($function);
            } else {
                throw new common_Exception("callback function does not exist");
            }
        } else if ($this->hasOption('class')) {
			$class = $this->getOption('class');
			$method = $this->getOption('method');
            if (class_exists($class) && method_exists($class, $method)) {
                $callback = array($class, $method);
            } else {
                throw new common_Exception("callback method does not exist");
            }
        } else if ($this->hasOption('object')) {
			$object = $this->getOption('object');
			$method = $this->getOption('method');
            if (method_exists($object, $method)) {
                $callback = array($object, $method);
            } else {
                throw new common_Exception("callback method does not exist");
            }
		}

        if ($this->hasOption('param')) {
            $returnValue = (bool)call_user_func($callback, $values, $this->getOption('param'));
        } else {
            $returnValue = (bool)call_user_func($callback, $values);
        }

        return (bool)$returnValue;
    }
410786
function then(/*callable*/ $callable = null, /*callable*/ $failure = null)
    {
        if ($failure !== null)
            $this->onFailure($failure);

        if ($callable === null)
            return $this;
        
        
        if (! is_callable($callable) )
            throw new \Exception(sprintf(
                'The argument given is not callable; given: (%s).'
                , \Poirot\Std\flatten($callable)
            ));


        try {
            $result = call_user_func($callable, $this->collector(), $this);
        } catch(\Exception $e) {
            if ($this->failure)
                return call_user_func($this->failure, $e, $this);

            throw $e;
        }
        
        $this->then = $callable;
        return $result;
    }
766675
final protected function validateCallable($value, array $allowed) : bool
    {
        if (true === in_array('callable', $allowed)) {
            if (true === is_callable($value)) {
                return true;
            }
        }

        return false;
    }
22581
public static function isTrue($value, $format, $args = null, $_ = null) {
        if (!$value) {
            self::vfail($format, array_slice(func_get_args(), 2));
        }
        return $value;
    }
1315959
public function execute(string $view, array $arguments)
    {
        /**
         * @var Closure $sandbox
         * @var Context $content
         */

        /**
         * @param string $__flow__view
         *
         * @return string
         */
        $sandbox = function (string $__flow__view)
        {
            include $this->native->path($__flow__view);

            return $this->ext->blocks()->getExtends();
        };

        $content  = clone $this->content;
        $_view    = $view;
        $iterator = 0;

        $content->mergeData($arguments);

        do
        {
            if ($iterator >= $this->limit)
            {
                throw new Runtime('The application is not responding');
            }

            $iterator++;

            $_view = $sandbox->call(
                $content,
                $_view
            );
        }
        while ($_view);
    }
284861
static function object($value, &$error, $args)
    {
        $class = isset($args[0])? $args[0] : null;
        if (is_object($value) && (empty($class) || $value instanceof $class)){
            return $value;
        }
        $error = new Error(['Должен быть объектом класса "%s"', $class], 'object');
        return null;
    }
1264660
public function setArgument($name, $value)
    {
        if (!$value instanceof \Closure) {
            $value = function () use ($value) {
                return $value;
            };
        }

        $this->arguments[$name] = $value;
        unset($this->caches[$name]);

        return $this;
    }
370752
public function info($value, ...$args) {
        return call_user_func_array(
            [__CLASS__, 'event'],
            array_merge([self::INFO, $value], $args)
        );
    }
578982
public function _call($name, $arguments)
    {
        $object = $this->getObject();
		$callable = function() use ($name, $arguments, $object){
			if (!method_exists($object, $name)) {
				throw new \Exception('Unable to invoke method ' . $name . ' on object of class ' . get_class($object));
			}
			return call_user_func_array(array($object, $name), (array) $arguments);
		};
		return $this->breakScopeAndExecute($callable);
    }
761867
private function emit($value): Promise
    {
        if ($this->complete) {
            throw new \Error("Iterators cannot emit values after calling complete");
        }

        if ($value instanceof ReactPromise) {
            $value = Promise\adapt($value);
        }

        if ($value instanceof Promise) {
            $deferred = new Deferred;
            $value->onResolve(function ($e, $v) use ($deferred) {
                if ($this->complete) {
                    $deferred->fail(
                        new \Error("The iterator was completed before the promise result could be emitted")
                    );
                    return;
                }

                if ($e) {
                    $this->fail($e);
                    $deferred->fail($e);
                    return;
                }

                $deferred->resolve($this->emit($v));
            });

            return $deferred->promise();
        }

        $this->values[] = $value;
        $this->backPressure[] = $pressure = new Deferred;

        if ($this->waiting !== null) {
            $waiting = $this->waiting;
            $this->waiting = null;
            $waiting->resolve(true);
        }

        return $pressure->promise();
    }
867253
private static function flattenArgument (&$value, $key) {
        if ($value instanceof Closure) {
            $closureReflection = new ReflectionFunction($value);
            $value = sprintf('(Closure at %s:%s)', $closureReflection->getFileName(), $closureReflection->getStartLine());
        } elseif (is_object($value)) {
            $value = sprintf('object(%s)', get_class($value));
        } elseif (is_resource($value)) {
            $value = sprintf('resource(%s)', get_resource_type($value));
        }
    }
1239917
function parse(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) {
        return $value;
    }
837916
private function execute(array $arguments = []): ResponseInterface
    {
        ob_start();
        $level = ob_get_level();

        try {
            $return = call_user_func_array($this->callable, $arguments);

            if ($return instanceof ResponseInterface) {
                $response = $return;
                $return = '';
            } elseif (is_null($return)
                 || is_scalar($return)
                 || (is_object($return) && method_exists($return, '__toString'))
            ) {
                $responseFactory = $this->responseFactory ?: Factory::getResponseFactory();
                $response = $responseFactory->createResponse();
            } else {
                throw new UnexpectedValueException(
                    'The value returned must be scalar or an object with __toString method'
                );
            }

            while (ob_get_level() >= $level) {
                $return = ob_get_clean().$return;
            }

            $body = $response->getBody();

            if ($return !== '' && $body->isWritable()) {
                $body->write($return);
            }

            return $response;
        } catch (Exception $exception) {
            while (ob_get_level() >= $level) {
                ob_end_clean();
            }

            throw $exception;
        }
    }
797476
private function call(callable $handler, array $arguments): Promise
    {
        try {
            $result = $handler(...$arguments);
        } catch (\Throwable $error) {
            return new Failure($error);
        }

        if ($result instanceof \Generator) {
            return new Coroutine($this->recoil($result));
        }

        return $result instanceof Promise ? $result : new Success($result);
    }
54228
public function set($argument, $value = null)
    {
        if (!is_array($argument)) {
            $argument = array($argument => $value);
        }

        return $this->setArguments($argument);
    }