Ecnode un paramètre js

@param $var
@return mixed
760193
protected function encode($var)
    {

        $functions = [];

        // on force un niveau supérieur
        $var = [$var];

        // bind toutes les functions
        array_walk_recursive($var, function(&$item, $key) use (&$functions){
            if (substr($item,0,8) == 'function') {
                $index = '###___' . count($functions) . '___###';
                $functions['"' . $index . '"'] = $item;
                $item = $index;
            }
        });

        // Encodage
        $var = json_encode($var[0], JSON_PRETTY_PRINT );

        // Rebind des functions
        $var = str_replace(array_keys($functions), array_values($functions), $var);

        return $var;
    }
579010
public function setNodes($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dataproc\V1beta2\WorkflowNode::class);
        $this->nodes = $arr;

        return $this;
    }
648730
private function staticVariable() {
    $node = new StaticVariableNode();
    $this->mustMatch(T_VARIABLE, $node, 'name', TRUE);
    if ($this->tryMatch('=', $node)) {
      $node->addChild($this->staticScalar(), 'initialValue');
    }
    return $node;
  }
720254
public function setLinks($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\Span_Links::class);
        $this->links = $var;

        return $this;
    }
215012
protected function _children($var)
    {
        $found = array();

        // Look for access of the form {ns:var}.
        if (strpos($var, ':') !== false) {
            list($ns, $elt) = explode(':', $var, 2);
            foreach ($this->_element->childNodes as $child) {
                if ($child->localName == $elt && $child->prefix == $ns) {
                    $found[] = $child;
                }
            }
        } else {
            foreach ($this->_element->childNodes as $child) {
                if ($child->localName == $var) {
                    $found[] = $child;
                }
            }
        }

        return $found;
    }
801526
protected function encode($var)
    {
        $string = '';
        foreach ($var as $key => $value) {
            $string .= $key . '="' .  preg_replace(
                    ['/"/', '/\\\/', "/\t/", "/\n/", "/\r/"],
                    ['\"',  '\\\\', '\t',   '\n',   '\r'],
                    $value
                ) . "\"\n";
        }
        return $string;
    }
374564
public function frontmatter($var = null)
    {
        $content = $this->content();

        if ($var !== null) {
            $content['frontmatter'] = (string) $var;
            $this->content($content);
        }

        return $content['frontmatter'];
    }
860767
private function _compoundVariable() {
    $node = new CompoundVariableNode();
    $this->mustMatch('$', $node);
    $this->mustMatch('{', $node);
    $node->addChild($this->expr(), 'expression');
    $this->mustMatch('}', $node, NULL, TRUE);
    return $node;
  }
1291137
public function setValidNodeVersions($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
        $this->valid_node_versions = $arr;

        return $this;
    }
1192836
public function escape($var)
	{
		if (in_array($this->_escape, array('htmlspecialchars', 'htmlentities')))
		{
			return call_user_func($this->_escape, $var, ENT_COMPAT, $this->_charset);
		}

		return call_user_func($this->_escape, $var);
	}
1183005
protected function lexVariable(): VariableNode
    {
        $start = $this->lexer->getToken();

        $this->expect(TokenKindEnum::DOLLAR);

        return new VariableNode($this->lexName(), $this->createLocation($start));
    }
147343
protected function encode($var)
    {
        return (string) YamlParser::dump($var, $this->setting('inline', 5), $this->setting('indent', 2), true, 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;
    }
870344
public function templateFormat($var = null)
    {
        if ($var !== null) {
            $this->template_format = $var;
            return $this->template_format;
        }

        if (isset($this->template_format)) {
            return $this->template_format;
        }

        // Set from URL extension set on page
        $page_extension = trim($this->header->append_url_extension ?? '' , '.');
        if (!empty($page_extension)) {
            $this->template_format = $page_extension;

            return $this->template_format;
        }

        // Set from uri extension
        $uri_extension = Grav::instance()['uri']->extension();
        if (is_string($uri_extension)) {
            $this->template_format = $uri_extension;

            return $this->template_format;
        }

        // Use content negotitation via the `accept:` header
        $http_accept = $_SERVER['HTTP_ACCEPT'] ?? false;
        if (is_string($http_accept)) {
            $negotiator = new Negotiator();

            $supported_types = Grav::instance()['config']->get('system.pages.types', ['html', 'json']);
            $priorities = Utils::getMimeTypes($supported_types);

            $media_type = $negotiator->getBest($http_accept, $priorities);
            $mimetype = $media_type instanceof Accept ? $media_type->getValue() : '';

            $this->template_format = Utils::getExtensionByMime($mimetype);

            return $this->template_format;
        }

        // Last chance set a default type
        $this->template_format = 'html';
        return $this->template_format;
    }
1212002
public function match($var)
    {
        $ret = false;

        foreach ($this->_types as $type) {
            if (array_search($type, array("*", "mixed")) !== false) {
                $ret = true;
            } elseif (array_search($type, array("number", "numeric")) !== false) {
                $ret = is_numeric($var);
            } elseif (array_search($type, array("bool", "boolean")) !== false) {
                $ret = is_bool($var);
            } elseif ($type == "string") {
                $ret = is_string($var);
            } elseif ($type == "array") {
                $ret = is_array($var);
            } elseif ($type == "object") {
                $ret = is_object($var);
            } elseif ($type == "resource") {
                $ret = is_resource($var);
            } elseif ($type == "function") {
                $ret = is_callable($var);
            } elseif ($type == "scalar") {
                $ret = is_scalar($var);
            } else {
                $ret = is_a($var, $type);
            }

            if ($ret) {
                break;
            }
        }

        return $ret;
    }
1067526
public function metadata($var = null)
    {
        if ($var !== null) {
            $this->metadata = (array)$var;
        }

        // if not metadata yet, process it.
        if (null === $this->metadata) {
            $header_tag_http_equivs = ['content-type', 'default-style', 'refresh', 'x-ua-compatible'];

            $this->metadata = [];

            $metadata = [];
            // Set the Generator tag
            $metadata['generator'] = 'GravCMS';

            // Get initial metadata for the page
            $metadata = array_merge($metadata, Grav::instance()['config']->get('site.metadata'));

            if (isset($this->header->metadata)) {
                // Merge any site.metadata settings in with page metadata
                $metadata = array_merge($metadata, $this->header->metadata);
            }

            // Build an array of meta objects..
            foreach ((array)$metadata as $key => $value) {
                // Lowercase the key
                $key = strtolower($key);
                // If this is a property type metadata: "og", "twitter", "facebook" etc
                // Backward compatibility for nested arrays in metas
                if (is_array($value)) {
                    foreach ($value as $property => $prop_value) {
                        $prop_key = $key . ':' . $property;
                        $this->metadata[$prop_key] = [
                            'name' => $prop_key,
                            'property' => $prop_key,
                            'content' => htmlspecialchars($prop_value, ENT_QUOTES, 'UTF-8')
                        ];
                    }
                } else {
                    // If it this is a standard meta data type
                    if ($value) {
                        if (\in_array($key, $header_tag_http_equivs, true)) {
                            $this->metadata[$key] = [
                                'http_equiv' => $key,
                                'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
                            ];
                        } elseif ($key === 'charset') {
                            $this->metadata[$key] = ['charset' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')];
                        } else {
                            // if it's a social metadata with separator, render as property
                            $separator = strpos($key, ':');
                            $hasSeparator = $separator && $separator < strlen($key) - 1;
                            $entry = [
                                'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
                            ];

                            if ($hasSeparator && !Utils::startsWith($key, 'twitter')) {
                                $entry['property'] = $key;
                            } else {
                                $entry['name'] = $key;
                            }

                            $this->metadata[$key] = $entry;
                        }
                    }
                }
            }
        }

        return $this->metadata;
    }
974964
public function getMagicVariableValue($variable)
    {
        $base_path_name = basename(realpath("."));

        switch ($variable) {
            case self::MAGIC_VAR_BASENAME:
                return $base_path_name;
                break;

            case self::MAGIC_VAR_UCFIRST_BASENAME:
                return ucfirst($base_path_name);
                break;

            case self::MAGIC_VAR_UPPER_CAMEL_CASE_BASENAME:
                return $this->toUpperCamelCase($base_path_name);
                break;

            case self::MAGIC_VAR_LOWER_CAMEL_CASE_BASENAME:
                return $this->toLowerCamelCase($base_path_name);
                break;
        }

        return null;
    }