Provision an Executable instance from any valid callable or class::method string

@param mixed $callableOrMethodStr A valid PHP callable or a provisionable ClassName::methodName string
@return \Auryn\Executable
190273
public function buildExecutable($callableOrMethodStr)
    {
        try {
            list($reflFunc, $invocationObj) = $this->buildExecutableStruct($callableOrMethodStr);
        } catch (\ReflectionException $e) {
            throw InjectionException::fromInvalidCallable(
                $this->inProgressMakes,
                $callableOrMethodStr,
                $e
            );
        }

        return new Executable($reflFunc, $invocationObj);
    }
1237077
public function removeMethod($nameOrMethod) {
		if ($nameOrMethod instanceof PhpMethod) {
			$nameOrMethod = $nameOrMethod->getName();
		}

		if (!$this->methods->has($nameOrMethod)) {
			throw new \InvalidArgumentException(sprintf('The method "%s" does not exist.', $nameOrMethod));
		}
		$m = $this->methods->get($nameOrMethod);
		$m->setParent(null);
		$this->methods->remove($nameOrMethod);

		return $this;
	}
581238
public function extend(string $offset, callable $callable): callable
    {
        isset($this->keys[$offset])
            || Exception::unknownProperty($offset);
        isset($this->frozen[$offset])
            && Exception::overrideService($offset);
        is_object($this->items[$offset])
            || Exception::unknownMethod('__invoke');
        method_exists($this->items[$offset], '__invoke')
            || Exception::unknownMethod('__invoke');
        isset($this->protect[$this->items[$offset]])
            && Exception::permission($offset);
        is_object($callable)
            || Exception::unknownMethod('__invoke');
        method_exists($callable, '__invoke')
            || Exception::unknownMethod('__invoke');

        $factory = $this->items[$offset];
        $extended = function ($c) use ($callable, $factory) {
            return $callable($factory($c), $c);
        };
        if (isset($this->factory[$factory])) {
            $this->factory->detach($factory);
            $this->factory->attach($extended);
        }
        return $this[$offset] = $extended;
    }
622941
public static function getKey($callable)
    {
        /** @var string|null $class */
        $class = null;
        /** @var string|null $method */
        $method = null;

        if (is_string($callable)) {
            $method = $callable; // works for 'Cls::method' case as well
        } elseif (is_array($callable)) {
            $class = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
            $method = $callable[1];
        } elseif (is_object($callable)) {
            if ($callable instanceof \ReflectionFunctionAbstract) {
                if ($callable->isClosure()) {
                    return null;
                }

                $class = $callable instanceof \ReflectionMethod ? $callable->class : null;
                $method = $callable->name;
            } else {
                if ($callable instanceof \Closure) {
                    return null;
                }

                $class = get_class($callable);
                $method = '__invoke';
            }
        }

        return strtolower(($class ? $class . '::' : '') . $method);
    }
239114
protected function parseClassMethod($userCallable)
    {
        list($class) = explode('@', $userCallable);

        $callable = str_replace('@', '::', $userCallable);

        try {
            $method = new ReflectionMethod($callable);

            $class = new ReflectionClass($class);
        } catch (ReflectionException $e) {
            throw new InvalidCallableException($e->getMessage());
        }

        return ($method->isStatic()) ? $callable : $this->getInstanceMethod($class, $method);
    }
788262
public function setCallable($callableExpression)
    {

        if (strpos("@", $callableExpression) === false) {
            $callableExpression .= "@indexAction";
        }

        list($controllerName, $action) = explode("@", $callableExpression);

        $controller = $this->pimple[$controllerName];

        $callable = array(
            $controller,
            $action
        );

        if (!is_callable($callable)) {

            $message = "The callable you have provided is not callable, if you did not provide a action then ";
            $message .= "indexAction will be called on your given controller";

            throw new \InvalidArgumentException($message);
        }

        $this->callable = $callable;
    }
726560
private function makeCallbackHumanReadable( Callable $callback )
    {
        if( is_string($callback) ) {
            return $callback;
        } elseif( is_array($callback) ) {
            return sprintf(
                "%s::%s",
                is_object( $callback[0] ) ? get_class($callback[0]) : $callback[0],
                $callback[1]
            );
        } elseif( !($callback instanceof \Closure) ) {
            return "<closure>";
        }
        throw new \Exception("Wow. I didn't know php could define a callable of this type. Pete __definately__ wants to know all about this.");
    }
434217
protected static function fromClassMethodString($uses)
    {
        [$class, $method] = Str::parseCallback($uses);

        if (! method_exists($class, $method) && is_callable($class, $method)) {
            return [];
        }

        return (new ReflectionMethod($class, $method))->getParameters();
    }
827158
public function invoke(Callable $callable, array $args = [])
    {
        // object/class method
        if (is_string($callable) && false !== strpos($callable, '::')) {
            $callable = explode('::', $callable);
        }
        if (is_array($callable)) {
            $reflection = new \ReflectionMethod($callable[0], $callable[1]);
        }

        // closures, functions and any other callable
        if (!isset($reflection)) {
            $reflection = new \ReflectionFunction($callable);
        }

        // inject arguments
        $arguments = $this->inject($reflection, $args);
        return $callable(...$arguments);
    }
443175
protected function getCallableParameters(callable $callable)/*# : array */
    {
        // array type
        if (is_array($callable)) {
            $reflector = new \ReflectionClass($callable[0]);
            $method = $reflector->getMethod($callable[1]);

        // object with __invoke() defined
        } elseif ($this->isInvocable($callable)) {
            $reflector = new \ReflectionClass($callable);
            $method = $reflector->getMethod('__invoke');

        // simple function
        } else {
            $method = new \ReflectionFunction($callable);
        }

        return $method->getParameters();
    }
701459
public static function call($callable, $args)
    {
        if (is_scalar($callable) && mb_orig_strpos($callable, '::') === false) {
            return self::callFunction('', $callable, $args);
        }

        if (is_scalar($callable)) {
            $parts = explode('::', $callable);
            if (count($parts) != 2) {
                throw new \RuntimeException("Invalid callable format for '$callable', expected single '::'");
            }
            list($obj, $method) = $parts;
        } else if (is_array($callable)) {
            if (count($callable) != 2) {
                throw new \RuntimeException("Invalid callable format, expected array of exactly 2 elements");
            }
            list($obj, $method) = $callable;
        } else {
            return call_user_func_array($callable, $args);
        }

        if (is_object($obj)) {
            return self::callMethod($obj, null, $method, $args, true);
        } else if (is_scalar($obj)) {
            return self::callStaticMethod($obj, $method, $args, true);
        }

        throw new \RuntimeException("Invalid callable format, expected first array element to be object or scalar, " . gettype($obj) . " given");
    }
562038
protected function resolveCallableArguments(
        callable $callable,
        array $providedArguments
    )/*# : array */ {
        // object with __invoke defined or \Closure
        if (is_object($callable) && !$callable instanceof \Closure) {
            $reflector = new \ReflectionClass($callable);
            $method = $reflector->getMethod('__invoke');

        // array-like callable
        } elseif (is_array($callable)) {
            $reflector = new \ReflectionClass($callable[0]);
            $method = $reflector->getMethod($callable[1]);

        // simple function
        } else {
            $method = new \ReflectionFunction($callable);
        }

        // dereference the provided arguments
        $this->dereferenceArray($providedArguments);

        // match provided arguments with method parameter definitions
        return $this->matchMethodArguments(
            $method->getParameters(),
            $providedArguments
        );
    }
23656
public function setStrainerDateRange($callable = null, $attr = [])
    {

        // if callable is a string , it's a field
        if (is_string($callable) || $callable instanceof Expression) {
            $field = $callable;
            $callable = null;
        }

        // create the strainer
        $strainer = new DateRange($this, $callable, $attr);

        //if a fields is set, we configure the strainer
        if (isset($field)) {
            $strainer->setField($field);
        }

        return $this->setStrainer($strainer);
    }
685889
public function setCallable($callable)
    {
        $matches = array();
        if (is_string($callable) && preg_match('!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!', $callable, $matches)) {
            $class = $matches[1];
            $method = $matches[2];
            $callable = function() use ($class, $method) {
                static $obj = null;
                if ($obj === null) {
                    $obj = new $class;
                }
                return call_user_func_array(array($obj, $method), func_get_args());
            };
        }

        if (!is_callable($callable)) {
            throw new \InvalidArgumentException('Route callable must be callable');
        }

        $this->callable = $callable;
    }
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);
    }
228913
protected function callableOptions($callable)
    {
        // resolve closure
        if (is_callable($callable)) {
            return $callable;
        }

        // resolve callable "Class@method" style
        if (is_string($callable) && list($class, $method) = explode('@', $callable)) {
            return [app()->make($class), $method];
        }

        // resolve callable [$object, "method"]
        if (2 === count($callable) && array_key_exists(0, $callable) && array_key_exists(1, $callable)) {
            if (is_object($class = $callable[0]) && is_string($method = $callable[1]) && method_exists($class, $method)) {
                return [$class, $method];
            }
        }

        return false;
    }
209564
public static function addMethod($methodName, $methodCallable)
    {
        if (!is_callable($methodCallable)) {
            throw new InvalidArgumentException('Second param must be callable');
        }
        self::$methods[$methodName] = \Closure::bind($methodCallable, Mailer::instance(), get_class());
    }