创建(类实例/类的方法)回调
@param mixed $target
@param array $arguments
@param array $props
@return callable
@throws \InvalidArgumentException
@throws \Inhere\Exceptions\DependencyResolutionException
186177
public function createCallback($target, array $arguments = [], array $props = []): callable
    {
        // a Closure OR a callable Object
        if (\is_object($target) && method_exists($target, '__invoke')) {
            return $target;
        }

        $arguments = array_values($arguments);
        /** @see $this->set() $definition is array */
        $target = trim($target);

        if (($pos = strpos($target, '::')) !== false) {
            $callback = function (self $self) use ($target, $arguments) {
                if ($arguments) {
                    return $target(...$arguments);
                }

                return $target($self);
            };
        } elseif (($pos = strpos($target, '->')) !== false) {
            $class = substr($target, 0, $pos);
            $method = substr($target, $pos + 2);

            $callback = function (self $self) use ($class, $method, $arguments, $props) {
                $object = new $class;

                Obj::init($object, $props);

                if ($arguments) {
                    return $object->$method(...$arguments);
                }

                return $object->$method($self);
            };
        } else {
            // 仅是个 class name
            $class = $target;

            try {
                $reflection = new \ReflectionClass($class);
            } catch (\Exception $e) {
                throw new \InvalidArgumentException($e->getMessage());
            }

            /** @var \ReflectionMethod */
            $reflectionMethod = $reflection->getConstructor();

            // If there are no parameters, just return a new object.
            if (null === $reflectionMethod) {
                $callback = function () use ($class, $props) {
                    return Obj::init(new $class, $props);
                };
            } else {
                $arguments = $arguments ?: Obj::getMethodArgs($reflectionMethod);

                // Create a callable
                $callback = function () use ($reflection, $arguments, $props) {
                    $object = $reflection->newInstanceArgs($arguments);

                    return Obj::init($object, $props);
                };
            }

            unset($reflection, $reflectionMethod);
        }

        return $callback;
    }
763611
public function symlink($target, $link)
    {
        if (!file_exists($target)) {
            throw new \InvalidArgumentException('Target not found: ' . $target);
        }
        if ($this->relative) {
            $target = $this->makePathRelative($target, dirname($link));
        }
        $this->fs->symlink($target, $link, $this->copyOnWindows);
    }
1273415
public function setTarget($target)
    {
        if (!is_string($target) || $target == '') {
            throw new \InvalidArgumentException('No valid URL given.');
        }

        $this->target = $target;

        // Set meta refresh content if header location is ignored
        $this->setContent(
            sprintf('<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="0; url=%1$s" />
    </head>
    <body>
        <p>Redirecting to <a href="%1$s">%1$s</a>.
    </body>
</html>', htmlspecialchars($target, ENT_QUOTES, 'UTF-8')));

        // Set header location
        $this->setHeader('Location', $target);

        return $this;
    }
1065577
public function evaluate($method, $arguments = array())
    {
        $callable = $this->mapper->getCallable($method);
        $arguments = $this->mapper->getArguments($callable, $arguments);

        return $this->execute($callable, $arguments);
    }
1146579
public function call($callback, $arguments = [])
    {
        $dependencies = $this->getMethodDependencies($callback, $arguments);

        return call_user_func_array($callback, $dependencies);
    }
1144805
protected function withProps($model, array $props): array
    {
        if (!(\is_array($model) || $model instanceof \ArrayAccess)) {
            throw new \InvalidArgumentException('Expect array or object implementing \ArrayAccess');
        }

        // Given an array of props (which may include a definition value), we
        // cycle through each, resolve the value from the model, and apply any
        // conversions to the value as necessary.
        $data = [];
        foreach ($props as $key => $definition) {
            if (\is_int($key)) {
                // This isn't a key => value pair, so there is no definition.
                $key = $definition;
                $definition = null;
            }

            // Convert property to a snake-case version.
            // It may be a nested (dot-notation) key.
            $propKey = StrHelper::snakeCase($key);
            if ($definition instanceof \Closure) {
                // If the definition is a function, execute it on the value
                $value = $definition->bindTo($this)($model, $propKey);
            } else {
                // Format the field according to the definition
                $value = $this->getPropValue($model, $this->parsePropDefinition($propKey, $definition));
            }

            // Set the prop value in the array
            ArrayHelper::mutate($data, $key, $value);
        }

        return $data;
    }
282914
public function rename($source, $target)
    {
        if ($source instanceof NodeObject) {
            if (!$source->isBlob()) {
                throw new \InvalidArgumentException("The given object is not a blob, it couldn't be renamed");
            }
            $sourceName = $source->getFullPath();
        } else {
            $sourceName = $source;
        }
        $this->clearAll();
        $this->addCommandName(self::MV_COMMAND);
        // Skip move or rename actions which would lead to an error condition
        $this->addCommandArgument('-k');
        $this->addCommandSubject($sourceName);
        $this->addCommandSubject2($target);

        return $this->getCommand();
    }
860784
public function setTarget($target)
    {
        if (!file_exists(dirname($target))) {
            throw new Exception\InvalidArgumentException("The directory '$target' does not exist");
        }

        $target = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, (string) $target);
        $this->options['target'] = $target;
        return $this;
    }
848111
public function on($target, $type, $callback = null)
    {
        if (is_null($callback)) {
            $callback = $type;
            $type     = '*';
        }

        if (!is_callable($callback)) {
            throw new Exception("$callback 不是一个可调用的函数或方法");
        }

        $type = strtolower($type);

        $listeners = $this->listeners->get("{$target}.{$type}") ?: array();

        array_push($listeners, $callback);

        $this->listeners->set("{$target}.{$type}", $listeners);

        return $this;
    }
326622
public function make($host, array $arguments = [])
    {
        return $host === null ? $this->makeRelative($arguments) : $this->makeAbsolute($host, $arguments);
    }
841143
public function setTarget($target = null)
        {
            if (null !== $target && !is_string($target)) {
                throw new Exception(
                        'Invalid argument: $target must be a string or null');
            }

            $this->_target = $target;

            return $this;
        }
381588
public static IVarargDependencyInjector bean(final Object target) {
		return new AbstractVarargDependencyInjector() {
			public void with(Object... dependencies) {
				TypeBasedInjector injector = new TypeBasedInjector();
				for (Object dependency : dependencies) {
					injector.validateInjectionOf(target, dependency);
				}
				for (Object dependency : dependencies) {
					injector.inject(target, dependency);
				}
			}
		};
	}
133001
public function refresh($abstract, $target, $method)
    {
        return $this->rebinding($abstract, function ($app, $instance) use ($target, $method) {
            $target->{$method}($instance);
        });
    }
932560
public function mapTarget(PersistenceTarget $target): Target
    {
        try {
            $targetType = $this->targetTypeRegistry->getTargetType(
                $target->type
            );
        } catch (TargetTypeException $e) {
            $targetType = new NullTargetType();
        }

        $targetData = [
            'id' => $target->id,
            'status' => $target->status,
            'ruleId' => $target->ruleId,
            'targetType' => $targetType,
            'value' => $target->value,
        ];

        return Target::fromArray($targetData);
    }
937201
public function withTargets(Target ...$targets): self
    {
        $obj = clone $this;
        $obj->_targets = $targets;
        return $obj;
    }
26307
protected function invokeMethod($object, $method, array $arguments = array())
    {
        return $this->getReflectionMethod($object, $method)->invokeArgs($object, $arguments);
    }
37697
protected function newEvent(
        $event,
        $target = null,
        array $parameters = []
    )/*# : EventInterface */ {
        if (is_object($event)) {
            return $event;
        } elseif (is_null($this->event_proto)) {
            return new Event($event, $target, $parameters);
        } else {
            // clone the prototype
            $evt = clone $this->event_proto;
            $evt->setName($event);
            $evt->setTarget($target);
            $evt->setParams($parameters);
            return $evt;
        }
    }