Translate the array of PHP variables to a JavaScript syntax.

@param  array $variables
@return array
489840
public function constructJavaScript($variables)
    {
        return $this->constructNamespace() . collect($variables)->map(function ($value, $name) {
            return $this->initializeVariable($name, $value);
        })->implode('');
    }
713200
public function actionDeleteToken(array $variables = array())
    {
        $this->requirePostRequest();

        $id = craft()->request->getRequiredPost('id');

        $token = craft()->oauth->getTokenById($id);

        if (craft()->oauth->deleteToken($token))
        {
            if (craft()->request->isAjaxRequest())
            {
                $this->returnJson(array('success' => true));
            }
            else
            {
                craft()->userSession->setNotice(Craft::t('Token deleted.'));
                $this->redirectToPostedUrl($token);
            }
        }
        else
        {
            if (craft()->request->isAjaxRequest())
            {
                $this->returnJson(array('success' => false));
            }
            else
            {
                craft()->userSession->setError(Craft::t('Couldn’t delete token.'));

                // Send the token back to the template
                craft()->urlManager->setRouteVariables(array(
                    'token' => $token
                ));
            }
        }
    }
451028
public function return(string ...$variables): self
    {
        $query = new self;
        $query->clauses = $this->clauses->add(
            new Clause\ReturnClause(...$variables)
        );

        return $query;
    }
274223
public function renderTemplate(string $template, array $variables = []): string
    {
        return $this->renderTemplateString($this->getTemplate($template), $variables);
    }
849396
public static function fromTemplate($template, array $variables)
    {
        if (strpos($template, '{') !== false) {
            $url = uri_template($template, $variables);
        } else {
            $url = $template;
        }

        return self::fromString($url);
    }
1182297
public function actionProvider(array $variables = array())
    {
        $handle = $variables['providerHandle'];


        // token

        $token = false;
        $tokenArray = craft()->httpSession->get('oauth.console.token.'.$handle);

        if($tokenArray)
        {
            $token = OauthHelper::arrayToToken($tokenArray);
        }

        // provider

        $provider = craft()->oauth->getProvider($handle);


        // render

        $variables['provider'] = $provider;
        $variables['token'] = $token;

        $this->renderTemplate('oauth/console/_provider', $variables);
    }
23157
private function convert($callback, $variables = []) {

		$this -> number = preg_replace_callback('~[0-9\.,]+~', function($number) use ($callback, $variables) {
			return call_user_func_array($callback, array_merge([(float) str_replace(',', '', $number[0])], $variables));
		}, $this -> number);

		return $this;
	}
663994
private function automate($viewVars)
    {
        $rawDataObj = new \stdClass();
        foreach ($viewVars as $key => $var) {
            $rawDataObj->$key = $var;
            $viewVars[$key]   = $this->escape($var);
        }
        $viewVars['raws'] = $rawDataObj;

        return $viewVars;
    }
312535
public function codes($variable)
    {
        foreach ($this->keywordList('CODES') as $keyword) {
            if ($keyword->subKeys[0] == $variable) {
                return $keyword->values;
            }
        }

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

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

        return $this;
    }
576477
protected function buildJavaScriptSyntax(array $vars)
    {
        foreach ($vars as $key => $value) {
            $this->vars[] = $this->buildVariableInitialization($key, $value);
        }
    }
336687
public static function getString(&$var, $values = null)
    {
        if (!is_string($var)) {
            $var = '';
        }
        if ($values !== null) {
            return in_array($var, $values, true) ? $var : $values[0];
        }

        return $var;
    }
881351
protected function getJSTemplateVars($vars)
    {
        if (is_array($vars)) {
            return $vars;
        }
        
        if ($this->hasMethod($vars)) {
            return $this->{$vars}();
        }
        
        return [];
    }
711321
protected function serializeContext(array $contextVariables)
    {
        $serializedContextArray = [];
        foreach ($contextVariables as $variableName => $contextValue) {
            // TODO This relies on a converter being available from the context value type to string
            if ($contextValue !== null) {
                $serializedContextArray[$variableName]['type'] = $this->getTypeForContextValue($contextValue);
                $serializedContextArray[$variableName]['value'] = $this->propertyMapper->convert($contextValue, 'string');
            }
        }

        return $serializedContextArray;
    }
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;
	}
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;
	}
630320
protected function createJsonResponse(array $variables)
    {
        $response = $this->getResponse();
        $json     = Json::encode($variables);
        $response->setContent($json);

        return $response;
    }