Return only the variables that are in the block.

@param Variable[] $variables

@return Variable[]
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);
        });
    }
1317649
public static function getVariables()
    {
        // Suppress return by-ref
        $vars = [ 'env' => static::$env ];
        // needs to use a for loop, using `array_merge([], $GLOBALS);` left reference traces somehow
        foreach ($GLOBALS as $varName => $varValue) {
            $vars[$varName] = $varValue;
        }

        return $vars;
    }
613022
public function getRedefinedVars(array $new_vars_in_scope, $include_new_vars = false)
    {
        $redefined_vars = [];

        foreach ($this->vars_in_scope as $var_id => $this_type) {
            if (!isset($new_vars_in_scope[$var_id])) {
                if ($include_new_vars) {
                    $redefined_vars[$var_id] = $this_type;
                }
                continue;
            }

            $new_type = $new_vars_in_scope[$var_id];

            if (!$this_type->failed_reconciliation
                && !$this_type->isEmpty()
                && !$new_type->isEmpty()
                && !$this_type->equals($new_type)
            ) {
                $redefined_vars[$var_id] = $this_type;
            }
        }

        return $redefined_vars;
    }
938025
protected function getSforInVariableNode($variable)
    {
        $env = new \Twig_Environment(new \Twig_Loader_Array());
        $parser = new \Twig_Parser($env);
        $lexer = new \Twig_Lexer($env);
        $stream = $lexer->tokenize(new \Twig_Source('{{'.$variable.'}}', 'variables'));

        return $parser->parse($stream)->getNode('body')->getNode(0)->getNode('expr')->getNode('node');
    }
1132298
public function variables()
    {
        return [
            'id'         => $this->elementId,
            'tools'      => $this->tools->render(),
            'items'      => $this->getItems(),
            'useCreate'  => $this->useCreate,
            'useSave'    => $this->useSave,
            'useRefresh' => $this->useRefresh,
        ];
    }
836452
public function getVariable($key)
    {
        if (!isset($this->variables[$key])) {
            return null;
        }
        return $this->variables[$key];
    }
423376
public static function getArray($var)
    {
        if (is_null($var) || empty($var)) {
            return [];
        }

        foreach ($var as $value) {
            if ((gettype($value) == 'object')
                && (get_class($value) == 'SimpleXMLElement')
            ) {
                return (array) $var;
            } elseif (!is_array($value)) {
                return [$var];
            }
        }

        return $var;
    }
97285
protected function resolveValue($name, $variables)
    {
        if (!empty($variables)) {
            foreach ($variables as $container => $vars) {
                foreach ($vars as $subname => $var) {
                    $value = $var['value'];

                    if(is_callable($value) && $var['name'] === $name) {
                        return $value($this->variables);
                    }

                    if (isset($var['name']) and $name == $value and isset($value)) {
                        return $value;
                    }
                    elseif (!isset($var['name']) and $subname == $name and isset($value)) {
                        return $value;
                    }
                }
            }
        }

        if (!isset($variables[$name])) {
            return false;
        }

        if (isset($variable['dataProvider'])) {
            $value = $this->resolveDataProviderValue($variable['dataProvider']);
            if (!$value) {
                return false;
            }
            return $value;
        }

        return array_get($variable, 'value', '');
    }
381359
private function filterVariablesUsedAsPlaceholders($string, array $variables)
    {
        if (empty($string)) {
            return $variables;
        }

        // array_filter() is not used because ARRAY_FILTER_USE_KEY requires PHP 5.6
        $filteredVariables = array();
        foreach ($variables as $key => $value) {
            if (false === strpos($string, '{'.$key.'}')) {
                $filteredVariables[$key] = $value;
            }
        }

        return $filteredVariables;
    }
884974
private function getTweetsVars($tweets, $vars)
    {
        /** @var string $firstTweetId */
        $firstTweetId = $tweets[0]->getId();

        $vars['previous'] = $this->tweetRepository
            ->getPreviousTweetId($firstTweetId);
        $vars['next'] = $this->tweetRepository
            ->getNextTweetId($firstTweetId);

        // Only update the cookie if the last Tweet Id is bigger than
        //  the one in the cookie
        if ($firstTweetId > $vars['cookieId']) {
            $vars['cookie'] = $this->createCookie($firstTweetId);
            $vars['cookieId'] = $firstTweetId;
        }

        $vars['number'] = $this->tweetRepository
            ->countPendingTweets($vars['cookieId']);

        $vars['first'] = $firstTweetId;

        return $vars;
    }
901157
public function setVariables($variables)
    {
        $this->variables = [];
        foreach ($variables as $var => $value) {
            $this->variables[$var] = Complex::parse($value);
        }
    }
1074761
public static function switchVars(array $vars)
    {
        $i = 0;
        foreach ($vars as $k => $v) {
            if ($i == 0) {
                $pk = $k;
                $pv = $v;
            } else {
                return array($pk => $v, $k => $pv);
            }
            $i++;
        }
    }
166283
public function inflectPackageVars($vars)
    {
        $restrictedWords = implode('|', array_keys($this->locations));

        $vars['name'] = strtolower($vars['name']);
        $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
            '$1',
            $vars['name']
        );

        return $vars;
    }
628733
protected function baseVariables(array &$variables = [])
    {
        parent::baseVariables($variables);

        // Page title
        $variables['title'] .= ': ' . Craft::t('patron', "Providers");

        // Breadcrumbs
        $variables['crumbs'][] = [
            'label' => Craft::t('patron', "Providers"),
            'url' => UrlHelper::url(Patron::getInstance()->getUniqueId() . '/providers')
        ];
    }
83047
public function getVariable(string $variable, $default = null)
    {
        if (isset($this->variables[$variable])) {
            return $this->variables[$variable];
        }

        return $default;
    }
779575
private function extractModifiedVariableNames(array $nodes)
    {
        $modifiedNames = array();
        foreach ($nodes as $node) {
            if (!$node) {
                continue;
            }

            $variableNameNode = $node;
            if ($node instanceof Node\Arg) {
                $variableNameNode = $node->value;
            }

            if ($node instanceof Node\Expr\ArrayDimFetch) {
                $variableNameNode = $node->var;
            }

            if (!($variableNameNode instanceof Node\Expr\Variable)) {
                continue;
            }

            $variableName = $this->convertVariableNameToString($variableNameNode);
            $modifiedNames[] = $variableName;
        }

        return array_unique($modifiedNames);
    }
394957
public function addRawVariable(Variable $variable)
    {
        if (!isset($this->branchVariables[1])) {
            $this->branchVariables[1] = [];
        }
        $this->branchVariables[1][$variable->getName()] = $variable;

        return $variable;
    }