@param StateMachineInterface|Callback $smOrCallback
@param callable                       $callback
@param array                          $spec

@return CallbackHandler
491634
public function addBefore($smOrCallback, $callback = null, array $spec = array())
    {
        $this->add($smOrCallback, FiniteEvents::PRE_TRANSITION, $callback, $spec);

        return $this;
    }
728551
private function assertCallback(callable $callback, string $message = 'failed callback assertion'): Validator
    {
        $variablesFailingAssertion = [];

        foreach ($this->variables as $variableName) {

            $variableValue = $this->loader->getVariable($variableName);

            if (call_user_func($callback, $variableValue) === false) {
                $variablesFailingAssertion[] = $variableName." $message";
            }
        }

        if (count($variablesFailingAssertion) > 0) {

            throw new RuntimeException(sprintf(
                'One or more environment variables failed validation: %s',
                implode(', ', $variablesFailingAssertion)
            ));
        }

        return $this;
    }
251825
public function createFromCallback($callback): StubVerifier
    {
        $stub = $this->stubFactory->create($callback);

        $verifier = new StubVerifier(
            $stub,
            $this->spyFactory->create($stub),
            $this->matcherFactory,
            $this->matcherVerifier,
            $this->generatorVerifierFactory,
            $this->iterableVerifierFactory,
            $this->callVerifierFactory,
            $this->assertionRecorder,
            $this->assertionRenderer,
            $this->generatorAnswerBuilderFactory
        );
        $verifier->setSelf($verifier);

        return $verifier;
    }
1353708
public function call($callback, array $parameters = array(), $defaultMethod = null)
    {
        if ($this->isCallableWithAtSign($callback) || $defaultMethod) {
            return $this->callClass($callback, $parameters, $defaultMethod);
        }

        $dependencies = $this->getMethodDependencies($callback, $parameters);

        return call_user_func_array($callback, $dependencies);
    }
1004981
public function setCallback($callback)
    {
        if ($callback instanceof \OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface) {
            $callback = array($callback, 'execute');
        }
        $this->callback = $callback;

        return $this;
    }
233674
public function setCallback($callback = null)
    {
        if (null !== $callback) {
            // partially taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/
            // partially taken from https://github.com/willdurand/JsonpCallbackValidator
            //      JsonpCallbackValidator is released under the MIT License. See https://github.com/willdurand/JsonpCallbackValidator/blob/v1.1.0/LICENSE for details.
            //      (c) William Durand <william.durand1@gmail.com>
            $pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*(?:\[(?:"(?:\\\.|[^"\\\])*"|\'(?:\\\.|[^\'\\\])*\'|\d+)\])*?$/u';
            $reserved = [
                'break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while',
                'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super',  'const', 'export',
                'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false',
            ];
            $parts = explode('.', $callback);
            foreach ($parts as $part) {
                if (!preg_match($pattern, $part) || \in_array($part, $reserved, true)) {
                    throw new \InvalidArgumentException('The callback name is not valid.');
                }
            }
        }

        $this->callback = $callback;

        return $this->update();
    }
731015
static function executeCallback($callback, array $params = array()) {
    // If callback has @
    if (is_string($callback) && strpos($callback, '@') !== false) {
      // Split
      $arrCallback = explode('@', $callback);
      // Set object
      $object = class_exists($arrCallback[0]) ? (new $arrCallback[0]()) : null;
      // Set method
      $method = isset($arrCallback[0]) ? $arrCallback[0] : null;
      // Set callback
      $callback = array($object, $method);
    }
    // If not callable
    if ( ! is_callable($callback)) {
      // Throw error
      throw new InvalidCallback('Callback must be callable');
    }
    // Execute and return
    return call_user_func_array($callback, $params);
  }
1255587
public function handleNotify(callable $callback)
    {
        $notify = $this->getNotify();

        if (!$notify->isValid()) {
            throw new FaultException('Invalid request payloads.', 400);
        }

        $notify = $notify->getNotify();
        $successful = $notify->get('result_code') === 'SUCCESS';

        $handleResult = call_user_func_array($callback, [$notify, $successful]);

        if (is_bool($handleResult) && $handleResult) {
            $response = [
                'return_code' => 'SUCCESS',
                'return_msg'  => 'OK',
            ];
        } else {
            $response = [
                'return_code' => 'FAIL',
                'return_msg'  => $handleResult,
            ];
        }

        return new Response(XML::build($response));
    }
1369834
protected function callMessageBuilder($callback, $message)
    {
        if ($callback instanceof Closure) {
            return call_user_func($callback, $message);
        } else if (is_string($callback)) {
            return $this->container[$callback]->mail($message);
        }

        throw new \InvalidArgumentException("Callback is not valid.");
    }
1203745
protected function withErrorBag($errorBag, callable $callback)
    {
        $this->validatesRequestErrorBag = $errorBag;

        call_user_func($callback);

        $this->validatesRequestErrorBag = null;
    }
1216230
protected function add($smOrCallback, $event, $callable = null, array $specs = array())
    {
        if ($smOrCallback instanceof Callback) {
            $this->dispatcher->addListener($event, $smOrCallback);

            return $this;
        }

        trigger_error(
            'Use of CallbackHandler::add without a Callback instance is deprecated and will be removed in 2.0',
            E_USER_DEPRECATED
        );

        $specs = $this->specResolver->resolve($specs);
        $callback = CallbackBuilder::create($smOrCallback, $specs['from'], $specs['to'], $specs['on'], $callable)->getCallback();

        $this->dispatcher->addListener($event, $callback);

        return $this;
    }
1004289
public function make(?callable $callback = null)
    {
        $mcb = function ($type, $buffer) use ($callback) {
            if (! $this->locked && AppProcess::OUT === $type && $event = FSEventParser::toEvent($buffer)) {
                $this->locked = true;
                ($callback) ? $callback($event) : null;
                $this->locked = false;
                unset($event);
            }
        };

        return new SwooleProcess(function () use ($mcb) {
            (new AppProcess($this->configure()))->setTimeout(0)->run($mcb);
        }, false, false);
    }
224940
function makeSpecExposer(spec) {
  const defn = clone(spec);
  return async function specExposer(ctx, next) {
    ctx.state.route = defn;
    await next();
  };
}
134347
protected function callClassBasedReplacer($callback, $message, $attribute, $rule, $parameters, $validator)
    {
        [$class, $method] = Str::parseCallback($callback, 'replace');

        return call_user_func_array([$this->container->make($class), $method], array_slice(func_get_args(), 1));
    }
1198831
protected function callMessageBuilder( $callback, $message )
	{
		if ( $callback instanceof Closure )
			return call_user_func( $callback, $message );

		if ( is_string( $callback ) )
			return UniversalBuilder::resolve( $callback )->mail( $message );

		throw new InvalidArgumentException( 'Callback is not valid.' );
	}
392039
public function handleRemaining(callable $callback)
    {
        $properties = $this->getRemainingMutations();
        if (!$properties) {
            // Nothing to do, don't register callback
            return;
        }

        foreach ($properties as $propertyName) {
            // HTTP Accepted
            $this->result[$propertyName] = 202;

            $this->propertyUpdateCallbacks[] = [
                $properties,
                $callback,
            ];
        }
    }
426454
function run(callable $callback = null) {
        if (isset($this->res))
            return null;
        $this->res = proc_open($this->cmd, $this->descriptor_spec, $this->pipes, $this->cwd, $this->env);
        if ($this->res) {
            $this->stdout = new TcpConnection($this->pipes[1]);
            if (is_callable($this->onMessage))
                $this->stdout->onMessage = function ($conn, $data) {
                    ($this->onMessage)($this, $data);
                };
            if (is_callable($this->onClose))
                $this->stdout->onClose = function () {
                    ($this->onClose)($this);
                };
            stream_set_blocking($this->pipes[0], false);
            if (is_callable($callback))
                $callback($this);
            return true;
        }
        unset ($this->res);
        return false;
    }