Parses directive
@param string $name
@param null $space
@param array $params
@return Directive
547278
protected function parseDirective(string $name, $space = null, $params = []) : Directive
    {
        return new Directive($name, is_null($params) ? [] : $params);
    }
1154796
public function post($name, $spaceId = null, $threadId = null, $guestSpaceId = null): array
    {
        $options = ['json' => ['name' => $name]];
        if ($spaceId !== null) {
            $options['json']['space'] = $spaceId;
            $options['json']['thread'] = $threadId;
        }

        /** @var JsonStream $stream */
        $stream = $this->client
            ->post(KintoneApi::generateUrl('preview/app.json', $guestSpaceId), $options)
            ->getBody();

        return $stream->jsonSerialize();
    }
35449
public function generate($name, $params = []) {
		$url = '';
		$path = $this->generatePath($name, $params);

		if ($path) {
			if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
				&& $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'
			) {
				$scheme = 'https';
			} else {
				$scheme = 'http';
			}
			$url = $scheme . '://' . $_SERVER['HTTP_HOST'] . $path;
		}

		return $url;
	}
1222865
protected function _parseFunction($name, $args)
    {
        $res = '';
        switch ($name) {
            case 'if':
                $res = 'if('.$this->_parseFinal($args, $this->_allowedInExpr).'):';
                array_push($this->_blockStack, 'if');
                break;

            case 'else':
                if (substr(end($this->_blockStack), 0, 2) != 'if') {
                    $this->doError1('errors.tpl.tag.block.end.missing', end($this->_blockStack));
                } else {
                    $res = 'else:';
                }
                break;

            case 'elseif':
                if (end($this->_blockStack) != 'if') {
                    $this->doError1('errors.tpl.tag.block.end.missing', end($this->_blockStack));
                } else {
                    $res = 'elseif('.$this->_parseFinal($args, $this->_allowedInExpr).'):';
                }
                break;

            case 'foreach':
                if ($this->trusted) {
                    $notallowed = array(';','!');
                } else {
                    $notallowed = array(';','!','(');
                }

                if (preg_match("/^\s*\((.*)\)\s*$/", $args, $m)) {
                    $args = $m[1];
                }

                $res = 'foreach('.$this->_parseFinal($args, $this->_allowedInForeach, $notallowed).'):';
                array_push($this->_blockStack, 'foreach');
                break;

            case 'while':
                $res = 'while('.$this->_parseFinal($args, $this->_allowedInExpr).'):';
                array_push($this->_blockStack, 'while');
                break;

            case 'for':
                if ($this->trusted) {
                    $notallowed = array();
                } else {
                    $notallowed = array('(');
                }
                if (preg_match("/^\s*\((.*)\)\s*$/", $args, $m)) {
                    $args = $m[1];
                }
                $res = 'for('.$this->_parseFinal($args, $this->_allowedInExpr, $notallowed).'):';
                array_push($this->_blockStack, 'for');
                break;

            case '/foreach':
            case '/for':
            case '/if':
            case '/while':
                $short = substr($name, 1);
                if (end($this->_blockStack) != $short) {
                    $this->doError1('errors.tpl.tag.block.end.missing', end($this->_blockStack));
                } else {
                    array_pop($this->_blockStack);
                    $res = 'end'.$short.';';
                }
                break;

            case 'assign':
            case 'eval':
                $res = $this->_parseFinal($args, $this->_allowedAssign).';';
                break;

            case 'literal':
                if (count($this->_literals)) {
                    $res = '?>'.array_shift($this->_literals).'<?php ';
                } else {
                    $this->doError1('errors.tpl.tag.block.end.missing', 'literal');
                }
                break;

            case '/literal':
                $this->doError1('errors.tpl.tag.block.begin.missing', 'literal');
                break;

            case 'meta':
                $this->_parseMeta($args);
                break;

            case 'meta_if':
                $metaIfArgs = $this->_parseFinal($args, $this->_allowedInExpr);
                $this->_metaBody .= 'if('.$metaIfArgs.'):'."\n";
                array_push($this->_blockStack, 'meta_if');
                break;

            case 'meta_else':
                if (substr(end($this->_blockStack), 0, 7) != 'meta_if') {
                    $this->doError1('errors.tpl.tag.block.end.missing', end($this->_blockStack));
                } else {
                    $this->_metaBody .= "else:\n";
                }
                break;

            case 'meta_elseif':
                if (end($this->_blockStack) != 'meta_if') {
                    $this->doError1('errors.tpl.tag.block.end.missing', end($this->_blockStack));
                } else {
                    $elseIfArgs = $this->_parseFinal($args, $this->_allowedInExpr);
                    $this->_metaBody .= 'elseif('.$elseIfArgs."):\n";
                }
                break;

            case '/meta_if':
                $short = substr($name, 1);
                if (end($this->_blockStack) != $short) {
                    $this->doError1('errors.tpl.tag.block.end.missing', end($this->_blockStack));
                } else {
                    array_pop($this->_blockStack);
                    $this->_metaBody .= "endif;\n";
                }
                break;

            default:
                if (preg_match('!^/(\w+)$!', $name, $m)) {
                    if (end($this->_blockStack) != $m[1]) {
                        $this->doError1('errors.tpl.tag.block.end.missing', end($this->_blockStack));
                    } else {
                        array_pop($this->_blockStack);
                        if (function_exists($fct = 'jtpl_block_'.$this->outputType.'_'.$m[1])) {
                            $res = $fct($this, false, null);
                        } elseif (function_exists($fct = 'jtpl_block_common_'.$m[1])) {
                            $res = $fct($this, false, null);
                        } else {
                            $this->doError1('errors.tpl.tag.block.begin.missing', $m[1]);
                        }
                    }
                } elseif (preg_match('/^meta_(\w+)$/', $name, $m)) {
                    if ($path = $this->_getPlugin('meta', $m[1])) {
                        $this->_parseMeta($args, $path[1]);
                        $this->_pluginPath[$path[0]] = true;
                    } else {
                        $this->doError1('errors.tpl.tag.meta.unknown', $m[1]);
                    }
                    $res = '';
                } elseif ($path = $this->_getPlugin('block', $name)) {
                    require_once $path[0];
                    $argfct = $this->_parseFinal($args, $this->_allowedAssign, array(';'), true);
                    $fct = $path[1];
                    $res = $fct($this, true, $argfct);
                    array_push($this->_blockStack, $name);
                } elseif ($path = $this->_getPlugin('cfunction', $name)) {
                    require_once $path[0];
                    $argfct = $this->_parseFinal($args, $this->_allowedAssign, array(';'), true);
                    $fct = $path[1];
                    $res = $fct($this, $argfct);
                } elseif ($path = $this->_getPlugin('function', $name)) {
                    $argfct = $this->_parseFinal($args, $this->_allowedAssign);
                    $res = $path[1].'( $t'.(trim($argfct) != '' ? ','.$argfct : '').');';
                    $this->_pluginPath[$path[0]] = true;
                } elseif (isset($this->_userFunctions[$name])) {
                    $argfct = $this->_parseFinal($args, $this->_allowedAssign);
                    $res = $this->_userFunctions[$name].'( $t'.(trim($argfct) != '' ? ','.$argfct : '').');';
                } else {
                    $this->doError1('errors.tpl.tag.function.unknown', $name);
                }
        }

        return $res;
    }
319648
protected function findNamespacedView($name)
    {
        list($namespace, $view) = $this->parseNamespaceSegments($name);
        
        $this->addThemeNamespaceHints($namespace);

        return $this->findInPaths($view, $this->hints[$namespace]);
    }
363294
protected function _service($name, $definition, $params)
    {
        if ($definition instanceof Closure) {
            $type = 'singleton';
            $definition = call_user_func_array($definition, $params);
            $this->_definitions[$name] = compact('definition', 'type');
        }
        return $definition;
    }
34414
public static function __callstatic($name, $params)
    {
        $matches = static::isFigletCall($name);

        if (null === $matches) {
            throw new Exception("Unknown figlet function name $name");
        }

        $fontName = $matches[2];

        // target string is expected to be:
        $targetString = $params[0][0];

        return static::render($targetString, $fontName);
    }
896599
protected function parseFragment($name) {
		$fileName = $this->loader->findFilename($name);
		$html5 = new HTML5();
		$dom = $html5->loadHTMLFragment(file_get_contents($fileName));

		if($html5->getErrors()) {
			$errors = "";
			foreach($html5->getErrors() as $error) {
				$errors .= "\n". $error;
			}
			throw new \Exception("Parsing error for template " . $name . " Errors: " . $errors);
		}

		return $dom;
	}
492186
private function fileNameToNamespaceParts(string $name)
    {
        $name = preg_replace('/(.*)(\.[\w\d]+)$/', '$1', $name);
        return array_map(function ($e) {
            $e = ucfirst($e);
            $e = implode("", array_map('ucfirst', explode(".", $e)));
            $e = implode("", array_map('ucfirst', explode("-", $e)));
            return $e;
        }, explode('/', $name));
    }
1248477
protected function view($name, array $data = [])
    {
        $name = is_null($this->viewNamespace) ? $name : "{$this->viewNamespace}::$name";

        return parent::view($name, $data);
    }
939882
protected function parseName($name)
    {
        $this->checkNamespace();

        $rootNamespace = $this->getPackageNamespace();

        if (Str::startsWith($name, $rootNamespace)) {
            return $name;
        }

        if (Str::contains($name, '/')) {
            $name = str_replace('/', '\\', $name);
        }

        return $this->parseName($this->getDefaultNamespace(trim($rootNamespace, '\\')).'\\'.$name);
    }
460467
public function render($name = null, ...$params)
    {
        return new HtmlString(
            view($this->getView(), [
                'breadcrumbs' => $this->generate($name, $params)
            ])->render()
        );
    }
15600
public static function createFromArray($name, array $params)
    {
        $argument = new Argument($name);
        $params   = self::getSettableArgumentParams($params);

        foreach ($params as $key => $value) {
            $method = 'set' . ucwords($key);
            $argument->{$method}($value);
        }

        return $argument;
    }
924693
public function staticRef($name, $params = null)
    {
        $name = (string)$name;
        if (!isset($this->static_refs[$name])) {
            try {
                $this->static_refs[$name] = $this->provider->url($name);
            } catch (UnsupportedException $e) {
                $this->static_refs[$name] = '/[static_reference: ' . $name . ']';
            }
        }

        $ret = $this->static_refs[$name];
        if ($params) {
            $ret .= '?' . http_build_query($params, 0, '&');
        }

        return $ret;
    }
897942
public function parse(array $existing = [], string &$name = null): array
    {
        if($this->type !== AnnotationReader::ANNOTATION_TYPE_PROPERTY)
            throw new \Exception("[MVQN\Annotations\AnnotationReader] @KeepNullElements is only supported for properties!");

        $name = "keepNullElements";

        if($this->isValueEval($this->value))
        {
            $existing[$name] = "`{$this->value}`";
            return $existing;
        }
        elseif($this->value === null || $this->value === "")
        {
            $existing[$name] = true;
            return $existing;
        }
        else
        {
            // Exclude the item, as we do not know how to handle the 'value' specifically!
            return $existing;
        }
    }
497406
public function getNamespaceByName( $name ) {
		$result = $this->getNamespaceResult()['query'];
		foreach ( $result['namespaces'] as $nsInfo ) {
			if ( ( !empty( $nsInfo['canonical'] ) && $nsInfo['canonical'] === $name ) ||
				$nsInfo['*'] === $name ) {
				return $this->createNamespaceFromQuery( $nsInfo, $result['namespacealiases'] );
			}
		}
		foreach ( $result['namespacealiases'] as $alias ) {
			if ( $alias['*'] === $name && !empty( $result['namespaces'][$alias['id']] ) ) {
				return $this->createNamespaceFromQuery(
					$result['namespaces'][$alias['id']],
					$result['namespacealiases']
				);
			}
		}
		return null;
	}
49620
public static function extractNamespaceFromQualifiedName($name)
    {
        if (($pos = strrpos($name, '\\')) !== false) {
            return substr($name, 0, $pos);
        } else {
            return null;
        }
    }