Finds next optional valiable token

@param Variable $var

@return array
778377
private static function findNextOpt(Variable $var)
    {
        $nextIsOpt = true;

        $next = null;
        $n = $var->next;

        while (null !== $n) {
            if (!$n instanceof Variable) {
                $n = $n->next;
                $nextIsOpt = true;
                continue;
            }
            if (!$n->required) {
                $nextIsOpt = true;
                $next = $n;
                break;
            }

            $nextIsOpt = false;
            $n = $n->next;
        }

        return [$next, $nextIsOpt];
    }
117892
private static function getPhpVariableAsText($var)
    {
        if (is_string($var)) {
            return('"'.str_replace(array("\x00", "\x0a", "\x0d", "\x1a", "\x09"), array('\0', '\n', '\r', '\Z', '\t'), $var).'"');
        } elseif (is_int($var) || is_float($var)) {
            return($var);
        } elseif (is_bool($var)) {
            if ($var) {
                return('true');
            } else {
                return('false');
            }
        } elseif (is_array($var)) {
            $result = 'array( ';
            $comma = '';
            foreach ($var as $key => $val) {
                $result .= $comma.self::getPhpVariableAsText($key).' => '.self::getPhpVariableAsText($val);
                $comma = ', ';
            }
            $result .= ' )';

            return($result);
        } elseif (is_object($var)) {
            return 'Object '.get_class($var);
        } elseif (is_resource($var)) {
            return 'Resource '.get_resource_type($var);
        }

        return 'Unknown type variable';
    }
61039
public function getGlobalVariable($variable = NULL)
	{
		try {

			$result = FALSE;

			if (is_null($variable))
				throw new Exception("Global variable name not provided or is null", 503);

			$uri = "/asterisk/variable?variable=" . $variable;

			$jsonResult = $this->pestObject->get($uri);

			$result = json_decode($this->ariEndpointClient->get($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents());

			return $result;

		} catch (\GuzzleHttp\Exception\RequestException $e) {
			$this->phpariObject->lasterror = $e->getMessage();
			$this->phpariObject->lasttrace = $e->getTraceAsString();
			return (int)$e->getCode();
		} catch (\GuzzleHttp\Exception\ClientException $e) {
			$this->phpariObject->lasterror = $e->getMessage();
			$this->phpariObject->lasttrace = $e->getTraceAsString();
			return (int)$e->getCode();
		} catch (\GuzzleHttp\Exception\ServerException $e) {
			$this->phpariObject->lasterror = $e->getMessage();
			$this->phpariObject->lasttrace = $e->getTraceAsString();
			return (int)$e->getCode();
		} catch (Exception $e) {
			$this->phpariObject->lasterror = $e->getMessage();
			$this->phpariObject->lasttrace = $e->getTraceAsString();

			return FALSE;
		}
	}
597301
private function varToString($var): string
    {
        if (\is_object($var)) {
            return \sprintf('an object of type %s', \get_class($var));
        }

        if (\is_array($var)) {
            $a = [];
            foreach ($var as $k => $v) {
                $a[] = \sprintf('%s => ...', $k);
            }

            return \sprintf('an array ([%s])', \mb_substr(\implode(', ', $a), 0, 255));
        }

        if (\is_resource($var)) {
            return \sprintf('a resource (%s)', \get_resource_type($var));
        }

        if (null === $var) {
            return 'null';
        }

        if (false === $var) {
            return 'a boolean value (false)';
        }

        if (true === $var) {
            return 'a boolean value (true)';
        }

        if (\is_string($var)) {
            return \sprintf('a string ("%s%s")', \mb_substr($var, 0, 255), \mb_strlen($var) > 255 ? '...' : '');
        }

        if (\is_numeric($var)) {
            return \sprintf('a number (%s)', (string) $var);
        }

        return (string) $var;
    }
117180
public function extract(Parser $parser, Node\Variable $var, $data)
    {
        $value   = $data;
        $vals    = array_filter(explode($this->sep, $data));
        $options = $var->options;

        switch ($options['modifier']) {

            case '*':
                $data = array();
                foreach($vals as $val) {

                    if (strpos($val, '=') !== false) {
                        list($k, $v) = explode('=', $val);
                        $data[$k] = $v;
                    }

                    else {
                        $data[]   = $val;
                    }
                }

                break;
            case ':':
                break;
            default:
                $data = strpos($data, $this->sep) !== false ? $vals : $value;

        }

        return $this->decode($parser, $var, $data);
    }
278425
private function varIsXmlResource($var) {
			$xml_parser=xml_parser_create();
			xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
			xml_set_element_handler($xml_parser,array(&$this,"xmlStartElement"),array(&$this,"xmlEndElement"));
			xml_set_character_data_handler($xml_parser,array(&$this,"xmlCharacterData"));
			xml_set_default_handler($xml_parser,array(&$this,"xmlDefaultHandler"));

			$this->makeTableHeader("xml","xml document",2);
			$this->makeTDHeader("xml","xmlRoot");

		//attempt to open xml file
			$bFile=(!($fp=@fopen($var,"r"))) ? false : true;

		//read xml file
			if($bFile) {
				while($data=str_replace("\n","",fread($fp,4096)))
					$this->xmlParse($xml_parser,$data,feof($fp));
			}
		//if xml is not a file, attempt to read it as a string
			else {
				if(!is_string($var)) {
					echo $this->error("xml").$this->closeTDRow()."</table>\n";
					return;
				}
				$data=$var;
				$this->xmlParse($xml_parser,$data,1);
			}

			echo $this->closeTDRow()."</table>\n";

		}
500484
private static function getToken(GlobalVariables $globalVariable)
    {
        if (!$globalVariable->get('container')->has('security.token_storage')) {
            return;
        }

        return $globalVariable->get('container')->get('security.token_storage')->getToken();
    }
822976
public function post($var = null)
	{
		$this->id = 0;
		if (!empty($var)) {
			$routing = explode('/', $var);
			if (is_array($routing)) {
				$var = array_shift($routing);
				$this->id = empty($routing)
					? 0
					: array_shift($routing);
			} else {
				$var = $routing;
			}

			if ($this->checkAuth()) {
				// load action based off of naming conventions
				header('Content-Type: application/json');
				return $this->_autoaction($var, 'post');
			} else {
				return $this->getForbbiden($var);
			}
		} else {
			return $this->getNoop();
		}
	}
175535
public function getParam($var = null)
    {
        $param = $this->_parameters;
        if (null !== $var) {
            if (isset($this->_parameters[$var])) {
                $param = $this->_parameters[$var];
            } else {
                $param = null;
            }
        }

        return $param;
    }
83047
public function getVariable(string $variable, $default = null)
    {
        if (isset($this->variables[$variable])) {
            return $this->variables[$variable];
        }

        return $default;
    }
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++;
        }
    }
766326
public function routeCanonical($var = null)
    {
        if ($var !== null) {
            $this->routes['canonical'] = $var;
        }

        if (!empty($this->routes) && isset($this->routes['canonical'])) {
            return $this->routes['canonical'];
        }

        return $this->route();
    }
1254093
protected function getVarDump($var)
    {
        $varType = gettype($var);
        switch ($varType) {
            case 'boolean':
            case 'integer':
            case 'double':
            case 'NULL':
            case 'ressource':
                return print_r($var, 1);
            case 'string':
                return (250 < strlen($var)) ? substr($var, 0, 250).'...' : $var;
            case 'object':
                return 'Object instance of ' . get_class($var);
            case 'array':
                $formated_array = array();

                foreach ($var as $key => $value) {
                    $formated_array[$key] = $this->getVarDump($value);
                }

                return print_r($formated_array, 1);
        }
    }
1050817
function findVariables(string, syntax, options) {
  string = ignoreBlock.removeIgnoredBlocks(string);
  var parser = getParserForSyntax(syntax, options);
  if (parser) {
    return parser.findVariables(string);
  }
  return [];
}
748828
protected function varToString($var)
    {
        if (is_object($var)) {
            return get_class($var);
        }

        if (is_array($var)) {
            return 'Array';
        }

        if (is_resource($var)) {
            return sprintf('Resource(%s)', get_resource_type($var));
        }

        if (null === $var) {
            return 'null';
        }

        if (false === $var) {
            return 'false';
        }

        if (true === $var) {
            return 'true';
        }

        return (string) gettype($var);
    }
1257837
public function get(string $var){
		$var = strtoupper($var);
		$env = null;

		if($this->global === true){

			if(array_key_exists($var, $_ENV)){
				$env = $_ENV[$var];
			}
			elseif(function_exists('getenv')){
				$env = getenv($var);
			}
			// @codeCoverageIgnoreStart
			elseif(function_exists('apache_getenv')){
				/** @noinspection PhpComposerExtensionStubsInspection */
				$env = apache_getenv($var);
			}
			// @codeCoverageIgnoreEnd

		}

		return $env ?? $this->_ENV[$var] ?? null;
	}
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');
    }