Return an array of bound facts and parameters after the evaluation
@param array $vars (optional) An array of existing vars
@return array
438228
public function getBindingsAsVars( $vars = array() )
	{
		// $vars = array_merge( $existingVars, $this->parameters );
		$vars = $this->getParametersAsVars( $vars );

		foreach( $this->factVariableBindings as $bindingQName => /** @var \XBRL\Formulas\factVariableBinding $varBinding */ $varBinding )
		{
			if ( $varBinding->isFallback )
			{
				$current = $varBinding->yieldedFact;
			}
			else
			{
				// Using current makes sure the fact is set and the binding variables are correct
				if ( ! $varBinding->valid() ) $varBinding->rewind();
				$current = $varBinding->current();
			}
			if ( $current instanceof XPath2NodeIterator ) $current->Reset();
			$vars[ $bindingQName ] = $current;
			$vars = array_merge( $vars, $varBinding->getAdditionalVars() );
		}

		foreach( $this->generalVariableBindings as $bindingQName => /** @var VariableBinding $varBinding */ $varBinding )
		{
			// Using current makes sure the fact is set and the binding variables are correct
			// $vars[ $bindingQName ] = $this->variablesByQName[ $bindingQName ]->bindAsSequence ? $varBinding->facts : $varBinding->current();
			if ( ! $varBinding->valid() ) $varBinding->rewind();
			$current = $varBinding->current();
			if ( $current instanceof XPath2NodeIterator )
			{
				// BMS 2018-04-04 Test 0023 V-03 fails because the vars are being reset presumably because a var is not a clone
				$current = $current->CloneInstance();
				$current->Reset();
			}
			else if ( $current instanceof XPathNavigator)
			{
				$current = $current->CloneInstance();
			}
			$vars[ $bindingQName ] = $current;
		}

		return $vars;
	}
1119135
public function setVars($vars)
    {
        $context = $this->_context;

        $context->vars = array_merge($context->vars, $vars);

        return $this;
    }
432635
public function inflectPackageVars($vars)
    {
        $vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name']));
        $vars['name'] = str_replace(' ', '', ucwords($vars['name']));

        return $vars;
    }
855853
public function toQuery( $variableSet, $factVariableBinding )
	{
		if ( ! $this->substitutionGroups )
		{
			return null;
		}

		$clauses = array();

		if ( isset( $this->substitutionGroups['qnames'] ) && $this->substitutionGroups['qnames'] )
		foreach ( $this->substitutionGroups['qnames'] as $qname )
		{
			$name = qname( $qname );
			$clauses[] = $this->strict
				? "fn:QName('{$name->namespaceURI}','{$name->localName}') eq (xfi:concept-substitutions(fn:node-name(.)))[1]"
				: "fn:QName('{$name->namespaceURI}','{$name->localName}') = xfi:concept-substitutions(fn:node-name(.))";
		}

		if ( isset( $this->substitutionGroups['qnameExpressions'] ) && $this->substitutionGroups['qnameExpressions'] )
		foreach ( $this->substitutionGroups['qnameExpressions'] as $qnameExpression )
		{
			$clauses[] = $this->strict
				? "{$qnameExpression} eq (xfi:concept-substitutions(fn:node-name(.)))[1]"
				: "{$qnameExpression} = xfi:concept-substitutions(fn:node-name(.))";
		}

		return implode( " or ", $clauses );

	}
1036128
private function BindExpr( $vars )
	{
		/**
		 * @var XPath2RunningContext $runningContext
		 */
		$runningContext = new XPath2RunningContext();

		/**
		 * @var ReferenceLink[] $variables
		 */
		$variables = null;
		$variableValues = null;
		if ( ! is_null( $vars ) && ! empty( $vars ) )
		{
			/**
			 * @var array[ReferenceLink] $variables
			 */
			$variables = array(); // new ReferenceLink[$vars.Count];
			$variableValues = array(); // new object[$vars.Count];
			// $array = $vars; // new KeyValuePair<QName, object>[$vars.Count];
			$array = array();
			foreach ( $vars as $key => $value )
			{
				$variables[] = $runningContext->NameBinder->PushVar( $key );
				$variableValues[] = $value;
			}
		}

		$this->context->RunningContext = $runningContext;
		$this->context->availableCollections = isset( $vars['availableCollections'] ) ? $vars['availableCollections'] : array();
		$this->context->defaultCollection = isset( $vars['defaultCollection'] ) ? $vars['defaultCollection'] : null;

		$this->exprTree->Bind();

		/**
		 * @var object[] $datapool
		 */
		$dataPool = array(); // new object[ $runningContext->NameBinder->getLength() ];
		if ( ! is_null( $variables ) )
		{
			for ( $k = 0; $k < count( $variables ); $k++ )
			{
				$variables[ $k ]->Set( $dataPool, $this->PrepareValue( $variableValues[ $k ] ) );
			}
		}
		return $dataPool;
	}
278605
public function inflectPackageVars($vars)
    {
        $vars['name'] = explode("-", $vars['name']);
        foreach ($vars['name'] as $key => $name) {
            $vars['name'][$key] = ucfirst($vars['name'][$key]);
            if (strcasecmp($name, "Plugin") == 0) {
                unset($vars['name'][$key]);
            }
        }
        $vars['name'] = implode("",$vars['name']);

        return $vars;
    }
1296130
protected function bindParts($vars, $type, ServerRequestInterface $request, array $parts)
    {
        $values = [];
        
        foreach ($vars as $key => $var) {
            $part = null;
            
            $bound =
                $this->bindPartObject($var, $part) ||
                $this->bindPartArray($var, $request, $parts, $part) ||
                $this->bindPartVar($var, $type, $request, $parts, $part) ||
                $this->bindPartConcat($var, $request, $parts, $part) ||
                $this->bindPartValue($var, $part);
            
            if (!$bound) continue;
            
            if ($type === 'assoc') {
                $values[$key] = $part[0];
            } else {
                $values = array_merge($values, $part);
            }
        }

        return $values;
    }
1202259
protected function serialize($vars)
    {
        $data = '';
        if (is_array($vars)) {
            foreach ($vars as $var=>$value)
                $data .= $var.'|'.serialize($value);
        }
        else {
            $data = 'b:0;';
        }

        return $data;
    }
804082
protected function parsevars(array $s)
	{
		$this->method      = strtoupper($this->arrayGet('REQUEST_METHOD', $s));
		$this->host        = $this->arrayGet('HTTP_HOST', $s);
		$this->user_agent  = $this->arrayGet('HTTP_USER_AGENT', $s, false, false);
		$this->accept      = $this->arrayGet('HTTP_ACCEPT', $s, true);
		$this->languages   = $this->arrayGet('HTTP_ACCEPT_LANGUAGE', $s, true);
		$this->encodings   = $this->arrayGet('HTTP_ACCEPT_ENCODING', $s, true);
		$this->connection  = $this->arrayGet('HTTP_CONNECTION', $s);
		$this->referer     = $this->arrayGet('HTTP_REFERER', $s);
		$this->path        = $this->arrayGet('PATH', $s);
		$this->software    = $this->arrayGet('SERVER_SOFTWARE', $s);
		$this->name        = $this->arrayGet('SERVER_NAME', $s);
		$this->address     = $this->arrayGet('SERVER_ADDR', $s);
		$this->port        = $this->arrayGet('SERVER_PORT', $s);
		$this->remote_addr = $this->arrayGet('REMOTE_ADDR', $s);
		$this->remote_port = $this->arrayGet('REMOTE_PORT', $s);
		$this->admin       = $this->arrayGet('SERVER_ADMIN', $s);
		$this->filename    = $this->arrayGet('SCRIPT_FILENAME', $s);
		$this->scriptname  = $this->arrayGet('SCRIPT_NAME', $s);
		$this->uri         = $this->arrayGet('REQUEST_URI', $s);
		$this->time        = $this->arrayGet('REQUEST_TIME', $s);

        if($this->arrayGet('HTTPS', $s) || strtolower($this->arrayGet('HTTP_X_FORWARDED_PROTO', $s)) == 'https') {
            $this->protocol = 'https';
        } else {
            $this->protocol = 'http';
        }

		// Stripping GET and anchor from the URI.
		$this->route = $this->uri;
		$get_id = strpos($this->route, '?');
		if($get_id !== false) {
			$this->route = substr($this->route, 0, $get_id);
		}
		$anchor_id = strpos($this->route, '#');
		if($anchor_id !== false) {
			$this->route = substr($this->route, 0, $anchor_id);
		}
	}
432814
public function getVariablesInBlock(array $variables)
    {
        $blockVariableNames = array_map(function (Variable $variable) {
            return $variable->getName();
        }, $this->variables);

        return array_filter($variables, function (Variable $variable) use ($blockVariableNames) {
            return in_array($variable->getName(), $blockVariableNames);
        });
    }
12614
public function findCount($vars) {
        $sql = $this->buildSelectStatement(array_keys($vars), $sort, $limit, $options);
        return $this->findCountRaw($sql, $vars);
    }
796610
protected function resolveCompositeBinding($vars)
    {
        $keys = array_keys($vars);

        foreach ($this->compositeBindings as $binding) {
            if ($keys === $binding[0]) {
                $binder = $binding[1];
                $errorHandler = $binding[2];

                $callable = $this->getBindingCallable($binder, null);
                $r = $this->callBindingCallable($callable, $vars, $errorHandler, true);

                if (!is_array($r) || count($r) !== count($vars)) {
                    throw new Exception("Route-Model-Binding (composite-bind) : Return value should be an array and should be of the same count as the wildcards!");
                }

                // Combine the binding results with the keys
                return array_combine($keys, array_values($r));
            }
        }
    }
800034
public function parse(array $vars = [])
    {
        $this->engine->parse($this->string);

        return $this->engine->getAsHtml();
    }
57441
public function GetResultType($vars)
	{
		if ( is_null( $this->resultType ) )
			$this->resultType = $this->exprTree->GetReturnType( $this->BindExpr( $vars ) );
		return $this->resultType;
	}
1179846
public function getAspectsCovered( $variableSet, $factVariableBinding )
	{
		$result = array();

		foreach ( $this->filters as $filter )
		{
			if ( ! $filter->cover ) continue;
			$result = array_merge( $result, $filter->getAspectsCovered( $variableSet, $factVariableBinding ) );
		}

		return $result;
	}
636356
private function loadAndCheckVarPositions(): array
    {
        $varPositions = $this->findAllVariablePositions();

        if (!$varPositions) {
            throw (new CodeError(
                static::CODE_TAG_MISSING_VARIABLES,
                self::MESSAGE_TAG_MISSING_VARIABLES,
                $this->stackPos
            ))->setToken($this->token);
        }

        $this->varTokens = array_filter($this->tokens, function (array $token) use ($varPositions): bool {
            return in_array($token['pointer'], $varPositions, true);
        });

        return $varPositions;
    }
938523
public function inflectPackageVars($vars)
    {
        if ($vars['type'] == 'mautic-plugin') {
            $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) {
                return strtoupper($matches[0][1]);
            }, ucfirst($vars['name']));
        }

        return $vars;
    }