Create a class based binding using the IoC container.

@param  string    $binding
@return \Closure
2529
public function createClassBinding($binding)
    {
        return function ($value, $route) use ($binding)
        {
            // If the binding has an @ sign, we will assume it's being used to delimit
            // the class name from the bind method name. This allows for bindings
            // to run multiple bind methods in a single class for convenience.
            list($className, $method) = array_pad(explode('@', $binding, 2), 2, 'bind');

            $instance = $this->container->make($className);

            return call_user_func(array($instance, $method), $value, $route);
        };
    }
116834
public function get($class, $mapping)
    {
        if (is_object($class)) {
            $class = get_class($class);
        }
        if (array_key_exists($class, $this->handlers)) {
            $handler = $this->handlers[$class];

            $field = call_user_func($handler, $mapping, $this->em);
        } else {
            $field = new $class($mapping, $this->em);
        }

        if ($field instanceof SanitiserAwareInterface) {
            $field->setSanitiser($this->sanitiser);
        }

        return $field;
    }
1060820
final public function bindToValidation(array $bindings): self
    {
        $this->validationBindings = \array_merge($this->validationBindings, $bindings);

        return $this;
    }
1153316
public function setBindings($bindings): Query
    {
	    if (is_array($bindings)) {
		    $this->bindings = new Bindings();
		    $this->bindings->setFromArray($bindings);

	    } else if ($bindings instanceof Bindings) {
		    $this->bindings = $bindings;

	    } else {
		    throw new \InvalidArgumentException('Invalid second argument provided, expected null, array or instance of Bindings');
	    }

        return $this;
    }
1262491
protected function share($binding, $class, $params = [], $alias = false)
    {
        if (is_string($class)) {
            $closure = function ($app) use ($class, $params) {
                return $app->build($class, $params);
            };
        } else {
            $closure = $class;
        }
        $this->app[ $binding ] = $this->app->share($closure);
        if ($alias) {
            $this->app->alias($binding, $class);
        }
    }
812458
public function setBindings(array $bindings)
    {
        foreach ($bindings as $key => $binding) {
            if (!$binding instanceof BoundArgument) {
                $bindings[$key] = new BoundArgument($binding);
            }
        }

        $this->bindings = $bindings;

        return $this;
    }
1220119
public function fromRaw($expression, $bindings = [])
    {
        $this->from = new Expression($expression);

        $this->addBinding($bindings, 'from');

        return $this;
    }
252438
public function bind(Form $form, $class)
    {
        if (!((is_string($class) && class_exists($class)) || ($class instanceof ReflectionClass)))
            throw new BinderException("Provide a classname or a reflection class to bind");

        if ($class instanceof ReflectionClass)
        {
            $refl = $class;
            $class = $refl->getName();
            $isModel = $refl->isSubclassOf(Model::class);
            $isForm = $refl->isSubclassOf(BaseForm::class);
        }
        else
        {
            $refl = new ReflectionClass($class);
            $isModel = $refl->isSubclassOf(Model::class);
            $isForm = $refl->isSubclassOf(BaseForm::class);
        }

        if (!$isModel && !$isForm)
            throw new BinderException("Can only bind subclasses of BaseForm and Model");

        $instance = new $class;
        foreach ($form as $key => $formelement)
        {
            if ($formelement instanceof Form)
                throw new BinderException("Cannot bind nested forms");

            $this->bindValue($formelement, $refl, $instance);
        }
        return $instance;
    }
176406
protected function createCallback(string $method): \Closure
    {
        return \Closure::bind(static function (...$args) use ($method) {
            return self::$method(...$args);
        }, null, $this->type);
    }
390426
public function acceptsBinding($binding)
    {
        return $binding instanceof $this->acceptedBindingClass
            || $binding === $this->acceptedBindingClass
            || is_subclass_of($binding, $this->acceptedBindingClass);
    }
56105
public function bind($bind, $password)
    {
        $this->_setErrorHandler();
        $result = ldap_bind($this->getConnection(), $bind, $password);
        $this->_unsetErrorHandler();

        return $result;
    }
1099234
public static function bindInstance($instance, $methodName, $args = null)
    {
        $helper = new self();
        return $helper->createClosure($methodName, $args)->bindTo($instance, get_class($instance));
    }
214110
protected function addBinding(string $interface, IBinding $binding)
    {
        if (!isset($this->bindings[$this->currentTarget])) {
            $this->bindings[$this->currentTarget] = [];
        }

        $this->bindings[$this->currentTarget][$interface] = $binding;
    }
935608
public function get($container = null)
    {
        if ($container) {
            return $container->get($this->id);
        }
        return Ioc::container()->get($this->id);
    }
349250
protected function bindParam($bind)
    {
        foreach ($bind as $key => $val) {
            $param = is_numeric($key) ? $key + 1 : ':' . $key;

            if (is_array($val)) {
                array_unshift($val, $param);
                $result = call_user_func_array([$this->PDOStatement, 'bindParam'], $val);
            } else {
                $result = $this->PDOStatement->bindValue($param, $val);
            }

            if (!$result) {
                $param = array_shift($val);

                throw new BindParamException(
                    "Error occurred  when binding parameters '{$param}'",
                    $this->config,
                    $this->getLastsql(),
                    $bind
                );
            }
        }
    }
766419
public function bind($contract, $class, $args = [])
    {
        $closure = function($class, $args) {
            $reflect = new \ReflectionClass($class);
            return $reflect->newInstanceArgs($args);
        };

        $this->bindings[$contract] = [
            'type' => 'closure',
            'closure' => $closure,
            'class' => $class,
            'args' => $args
        ];

        if (!class_exists($contract, false)) {
            eval("class {$contract} extends \Hades\Container\Facade {} ");
        }
    }
313160
protected function compileSetterInjector(Binding $binding, $wrapClosure = true)
	{
		$setters = $binding->getMarkers(SetterInjection::class);
		
		if(empty($setters))
		{
			return 'NULL';
		}
		
		$setterTypeName = $binding->isImplementationBinding() ? $binding->getTarget() : $binding->getTypeName();
		
		$code = $wrapClosure ? 'function($obj) { ' : '';
		$ref = new \ReflectionClass($setterTypeName);
		
		foreach($setters as $setter)
		{
			foreach($this->collectSetterMethods($ref, $setter) as $method)
			{
				$params = $method->getParameters();
					
				if(empty($params))
				{
					continue;
				}
				
				$injector = '$obj->' . $method->getName() . '(';
					
				foreach($params as $i => $param)
				{
					if(NULL === ($paramTypeName = $param->getClass()))
					{
						continue 2;
					}
						
					if($i != 0)
					{
						$injector .= ', ';
					}
					
					$nullable = $param->isOptional() ? 'Nullable' : '';
				
					$injector .= '$this->get' . $nullable . '(' . var_export($paramTypeName->name, true) . ', new InjectionPoint(';
					$injector .= 'get_class($obj), ' . var_export($method->getName(), true) . '))';
				}
					
				$code .= $injector . '); ';
			}
		}
		
		return $wrapClosure ? ($code . '}') : $code;
	}