Bind part if it's an variable

@param mixed                  $var
@param string                 $type
@param ServerRequestInterface $request
@param array                  $parts
@param array                  $part     OUTPUT
@return boolean
432468
protected function bindPartVar($var, $type, ServerRequestInterface $request, array $parts, &$part)
    {
        if (!is_string($var) || $var[0] !== '$') {
            return false;
        }
        
        $options = array_map('trim', explode('|', $var));
        $part = $this->bindVar($type, $request, $parts, $options);
        return true;
    }
120223
static function typecastVariable($variable, string $type) {
        if($variable === null) {
            return null;
        }
        
        switch($type) {
            case 'array':
                $variable = (array) $variable;
            break;
            case 'bool':
                $variable = (bool) $variable;
            break;
            case 'float':
                $variable = (float) $variable;
            break;
            case 'int':
                $variable = (int) $variable;
            break;
            case 'string':
                $variable = (string) $variable;
            break;
            default:
                throw new \InvalidArgumentException('Unsupported type "'.$type.'"');
            break;
        }
        
        return $variable;
    }
1018801
public function bind($param, $value, $type = null)
    {
        if (is_null($type)) {
            switch (true) {
                case is_int($value):
                    $type = PDO::PARAM_INT;
                    break;
                case is_bool($value):
                    $type = PDO::PARAM_BOOL;
                    break;
                case is_null($value):
                    $type = PDO::PARAM_NULL;
                    break;
                default:
                    $type = PDO::PARAM_STR;
            }
        }
        //then run PDO bindValue on the statement to bind the values
        self::$statement->bindValue($param, $value, $type);
    }
1009254
public function getBinds($parts = [], $clear = false)
    {
        $binds = [];

        if (!is_array($parts)) {
            $parts = [$parts];
        }

        if (!$parts) {
            $parts = array_keys($this->bind);
        }

        foreach ($parts as $part) {
            if (!isset($this->bind[$part])) {
                continue;
            }

            foreach ($this->bind[$part] as $key => $bind) {
                $binds[] = $bind;
                if ($clear) {
                    unset($this->bind[$part][$key]);
                }
            }
        }

        return $binds;
    }
519465
public function searchPartByKeyAndType($key, $type = '\\Zepi\\Web\\UserInterface\\Layout\\AbstractContainer')
    {
        foreach ($this->parts as $part) {
            if ((is_a($part, $type) || is_subclass_of($part, $type)) && $part->getKey() === $key) {
                return $part;
            }
            
            $result = $part->searchPartByKeyAndType($key, $type);
            if ($result !== false) {
                return $result;
            }
        }
        
        return false;
    }
1082152
protected function bindVarSingleUrlPart($option, array $parts, &$value)
    {
        if (ctype_digit(substr($option, 1))) {
            $i = (int)substr($option, 1);
            $part = array_slice($parts, $i - 1, 1);

            if (!empty($part)) {
                $value = $part;
                return true;
            }
        }
        
        return false;
    }
495688
public function bindValue($parameter, $value, int $dataType = \PDO::PARAM_STR): bool
    {
        $this->binds[$parameter] = $value;
        return true;
    }
866116
public function setPartOfSpeech($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\PartOfSpeech::class);
        $this->part_of_speech = $var;

        return $this;
    }
57824
protected function bindVarRequestHeader($option, ServerRequestInterface $request, &$value)
    {
        if (preg_match('/^\$(?:HTTP_)?([A-Z_]+)$/', $option, $matches)) {
            $sentence = preg_replace('/[\W_]+/', ' ', $matches[1]);
            $name = str_replace(' ', '-', ucwords($sentence));
            
            $value = [$request->getHeaderLine($name)];
            return true;
        }
        
        return false;
    }
244166
public function bindParam($paramNo, &$param, $type = null, $maxLength = null, $driverData = null)
    {
        $this->bindValue($paramNo, $param, $type);
        return true;
    }
922059
private <T> ParameterMetadata<T> next(Part part, Class<T> type, Parameter parameter) {
        Assert.notNull(type, "Type must not be null!");

        ParameterMetadata<T> value = new ParameterMetadata<T>(type, parameter.getName().get(), part.getType(),
                bindableParameterValues == null ? ParameterMetadata.PLACEHOLDER : bindableParameterValues.next());
        expressions.add(value);

        return value;
    }
1066168
public function bind($variable, $callback = null)
    {
        $name = 'bind.'.$variable;

        // If callback pass, so put in a queue.
        if (! empty($callback)) {
            // Preparing callback in to queues.
            $this->events->listen($name, function() use ($callback, $variable) {
                return ($callback instanceof Closure) ? $callback() : $callback;
            });
        }

        // Passing variable to closure.
        $_events   =& $this->events;
        $_bindings =& $this->bindings;

        // Buffer processes to save request.
        return array_get($this->bindings, $name, function() use (&$_events, &$_bindings, $name) {
            $response = current($_events->fire($name));
            array_set($_bindings, $name, $response);
            return $response;
        });
    }
306025
public function setRequestType ($type = FALSE)
	{
		
		// If there is a request argument
		
		if ($type !== FALSE)
		{
			
			// Set it
			
			$this->requestType	= $type;
			
		}
		
		// Else if there is a request format URL variable
		
		else if (isset ($_GET['request_type']))
		{
			
			// Set it
			
			$this->requestType	= $_GET['request_type'];
			
		}
		
	}
108025
public static function partial(&$context, $vars) {
        Parser::getBlockParams($vars);
        $pid = Parser::getPartialBlock($vars);
        $p = array_shift($vars);
        if ($context['flags']['runpart']) {
            if (!isset($vars[0])) {
                $vars[0] = $context['flags']['partnc'] ? array(0, 'null') : array();
            }
            $v = static::getVariableNames($context, $vars);
            $tag = ">$p[0] " .implode(' ', $v[1]);
            if (Parser::isSubExp($p)) {
                list($p) = static::compileSubExpression($context, $p[1]);
            } else {
                $p = "'$p[0]'";
            }
            $sp = $context['tokens']['partialind'] ? ", '{$context['tokens']['partialind']}'" : '';
            return $context['ops']['seperator'] . static::getFuncName($context, 'p', $tag) . "\$cx, $p, $v[0],$pid$sp){$context['ops']['seperator']}";
        }
        return isset($context['usedPartial'][$p[0]]) ? "{$context['ops']['seperator']}'" . Partial::compileStatic($context, $p[0]) . "'{$context['ops']['seperator']}" : $context['ops']['seperator'];
    }
161089
protected function bindVar($type, ServerRequestInterface $request, array $parts, array $options)
    {
        foreach ($options as $option) {
            $value = null;
            
            $bound = 
                $this->bindVarString($option, $value) ||
                $this->bindVarSuperGlobal($option, $request, $value) ||
                $this->bindVarRequestHeader($option, $request, $value) ||
                $this->bindVarMultipleUrlParts($option, $type, $parts, $value) ||
                $this->bindVarSingleUrlPart($option, $parts, $value);
            
            if ($bound && isset($value)) {
                return $value;
            }
        }
        
        return [null];
    }
270841
protected function bindVarMultipleUrlParts($option, $type, array $parts, &$value)
    {
        if (substr($option, -3) === '...' && ctype_digit(substr($option, 1, -3))) {
            $i = (int)substr($option, 1, -3);

            if ($type === 'assoc') {
                throw new \InvalidArgumentException("Binding multiple parts using '$option' is only allowed in numeric arrays");
            } else {
                $value = array_slice($parts, $i - 1);
            }
            
            return true;
        }
        
        return false;
    }
1134829
public function loadPartial($name, array $vars = array())
    {
        $partialTemplateFile = $this->getPartialBag()->getPartialFile($name);

        if (is_file($partialTemplateFile)) {
            extract(array_replace_recursive($vars, $this->variables));
            include($partialTemplateFile);
        } else {
            return false;
        }
    }