Directive[Const] : @ Name Arguments[?Const]?

@param bool $isConst
@return DirectiveNode
@throws SyntaxErrorException
515103
protected function lexDirective(bool $isConst = false): DirectiveNode
    {
        $start = $this->lexer->getToken();

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

        return new DirectiveNode(
            $this->lexName(),
            $this->lexArguments($isConst),
            $this->createLocation($start)
        );
    }
325817
private function buildNestedParams($nestedParams, $origParam, $isProto = false)
    {
        $paramsArray = [];

        foreach ($nestedParams as $param) {
            $nestedParam = explode(' ', trim($param), 3);

            // START proto nested arg missing description workaround
            if (count($nestedParam) < 3 && !$isProto) {
                throw new \Exception('nested param is in an invalid format: '. $param);
            }
            // END proto nested arg missing description workaround

            list($type, $name, $description) = $nestedParam;
            $name = substr($name, 1);
            $description = preg_replace('/\s+/', ' ', $description);

            $types = new Collection(
                array($type),
                $origParam->getDocBlock() ? $origParam->getDocBlock()->getContext() : null
            );

            $paramsArray[] = [
                'name' => substr($origParam->getVariableName(), 1) . '.' . $name,
                'description' => $this->buildDescription($origParam->getDocBlock(), $description, $origParam),
                'types' => $this->handleTypes($types),
                'optional' => null, // @todo
                'nullable' => null //@todo
            ];
        }

        return $paramsArray;
    }
642832
protected function lexArguments(bool $isConst = false): ?array
    {
        /**
         * @return ArgumentNode
         */
        $parseFunction = function () use ($isConst): ArgumentNode {
            return $this->lexArgument($isConst);
        };

        return $this->peek(TokenKindEnum::PAREN_L)
            ? $this->many(
                TokenKindEnum::PAREN_L,
                $parseFunction,
                TokenKindEnum::PAREN_R
            )
            : [];
    }
701609
function compileElement(node, scope, isRoot) {
        var tagName = node.tagName
        var inst
        switch(true) {
            /**
             *  <*-if></*-if>
             */
            case is.IfElement(tagName):
                var children = _slice(node.children)
                var exprs = [$(node).attr('is')]
                children.forEach(function(c) {
                    if (is.ElseElement(c)) {
                        exprs.push($(c).attr(conf.namespace + 'else') || '')
                    }
                })
                inst = new ElementDirective(
                        vm, 
                        scope,
                        node, 
                        elements['if'], 
                        NS + 'if', 
                        exprs
                )
                if (!isRoot) {
                    inst.$mount(node)
                }
                // save elements refs
                _directives.push(inst)
                // save bindins to scope
                _setBindings2Scope(scope, inst)
                return inst
            /**
             *  <*-repeat></*-repeat>
             */
            case is.RepeatElement(tagName):
                inst = new ElementDirective(
                        vm, 
                        scope,
                        node, 
                        elements.repeat,
                        NS + 'repeat', 
                        $(node).attr('items')
                )
                if (!isRoot) {
                    inst.$mount(node)
                }
                _directives.push(inst)
                _setBindings2Scope(scope, inst)
                return inst
        }
    }
142482
static function laraform($name = '', $options, $is_inline = true) {
        $gr = new ElementGroupRadioTwbs();
        if ($is_inline) {
            $gr->setIsInline(true);
        }
        foreach ($options as $k => $v) {
            $gr->putRadioTwbs($name, $k)
               ->setLabel($v);
        }
        return $gr;
    }
516595
public function isTrustedConstant($const, $compiler)
    {
        if (in_array($const, array('true', 'false', 'null'))) {
            return true;
        }
        if (!empty($this->trusted_constants)) {
            if (!in_array($const, $this->trusted_constants)) {
                $compiler->trigger_template_error("Security: access to constant '{$const}' not permitted");
                return false;
            }
            return true;
        }
        if ($this->allow_constants) {
            return true;
        }
        $compiler->trigger_template_error("Security: access to constants not permitted");
        return false;
    }
826047
public function removeConstant($nameOrConstant) {
		if ($nameOrConstant instanceof PhpConstant) {
			$nameOrConstant = $nameOrConstant->getName();
		}

		if (!$this->constants->has($nameOrConstant)) {
			throw new \InvalidArgumentException(sprintf('The constant "%s" does not exist.', $nameOrConstant));
		}

		$this->constants->remove($nameOrConstant);

		return $this;
	}
84907
def parse_directives(lexer: Lexer, is_const: bool) -> List[DirectiveNode]:
    """"""
    directives: List[DirectiveNode] = []
    append = directives.append
    while peek(lexer, TokenKind.AT):
        append(parse_directive(lexer, is_const))
    return directives
1183199
private function persist($match, $subject, $directive, $isstring = false)
	{
		$match = isset($match[1]) ? $match[1] : null;
		$uses = $directive->uses() !== false ? $directive->uses() : null;

		$e = $this->__engine;

		if ($uses !== null && $directive->name() !== false && $this->_control($uses)) {
			return "<?php $uses ((new $subject)->message($match)) : ?>";
		}
		else if ($uses !== null && $directive->name() !== false && $this->_control($uses) === false) {
			return "<?php $uses((new $subject)->message($match)); ?>";
		}
		else if ($directive->name() !== true && $uses === null) {
			return $directive->message($match);
		}
	}
1227711
public function condition($name, callable $callback)
    {
        $this->conditions[$name] = $callback;

        // If
        $this->directive($name, function($expr) use ($name) {
            return $expr ? '<?php if ($__parser->check(\'' . $name . '\', $expr)): ?>'
                : '<?php if ($__parser->check(\'' . $name . '\')): ?>';
        });

        // elseif
        $this->directive('else' . $name, function($expr) use ($name) {
            return $expr ? '<?php elseif ($__parser->check(\'' . $name . '\', $expr)): ?>'
                : '<?php elseif ($__parser->check(\'' . $name . '\')): ?>';
        });

        // end
        $this->directive('end' . $name, function() {
            return '<?php endif; ?>';
        });
    }
1059531
public function getSlideAttributesHTML($isFirst = false, $isMiddle = false, $isLast = false)
    {
        return $this->getAttributesHTML($this->getSlideAttributes($isFirst, $isMiddle, $isLast));
    }
491762
public function configure(...$definitions): ContainerConfiguration
    {
        $builder = new ContainerBuilder(ContainerConfiguration::class);

        $builder->useAutowiring(false)->useAnnotations(false)->ignorePhpDocErrors(false);

        $wiring = $this->config[WIRING] ?? null;
        if (fn\hasValue($wiring, [WIRING\REFLECTION, WIRING\AUTO])) {
            $builder->useAutowiring(true);
        } else if ($wiring === WIRING\STRICT) {
            $builder->useAnnotations(true)->ignorePhpDocErrors(false);
        } else if ($wiring === WIRING\TOLERANT) {
            $builder->useAnnotations(true)->ignorePhpDocErrors(true);
        }

        empty($this->config[CACHE]) || $builder->enableDefinitionCache();
        empty($this->config[PROXY]) || $builder->writeProxiesToFile(true, $this->config[PROXY]);
        empty($this->config[COMPILE]) || $builder->enableCompilation($this->config[COMPILE]);
        $this->container && $builder->wrapContainer($this->container);

        foreach ($definitions as $definition) {
            $builder->addDefinitions($definition);
        }

        /** @noinspection PhpUnhandledExceptionInspection */
        /** @noinspection PhpIncompatibleReturnTypeInspection */
        $built = $builder->build();
        return $built instanceof ContainerConfiguration
            ? $built
            : new ContainerConfiguration($built);
    }
1067343
protected function syntaxError($expectedDesc, $actualToken = null)
    {
        if (null === $actualToken) {
            $actualToken = $this->lexer->next;
        }
        if (null === $actualToken) {
            $actualDesc = 'end of input';
        } else if ($actualToken[1] === 0) {
            $actualDesc = sprintf('"%s" of type %s at beginning of input', $actualToken[0], $this->lexer->getName($actualToken[2]));
        } else {
            $actualDesc = sprintf('"%s" of type %s at position %d (0-based)', $actualToken[0], $this->lexer->getName($actualToken[2]), $actualToken[1]);
        }

        $ex = new SyntaxErrorException(sprintf('Expected %s, but got %s%s.', $expectedDesc, $actualDesc, $this->context ? ' '.$this->context : ''));
        if (null !== $actualToken) {
            $ex->setActualToken($actualToken);
        }
        if (null !== $this->context) {
            $ex->setContext($this->context);
        }

        throw $ex;
    }
766854
protected function allowCreate($dir, $name, $isDir = null) {
		$path = $this->joinPathCE($dir, $name);
		$perm = null;
		
		if ($this->access) {
			$perm = call_user_func($this->access, 'write', $path, $this->options['accessControlData'], $this, $isDir);			
			if ($perm !== null) {
				return !!$perm;
			}
		}
		
		$testPath = $this->separator.$this->relpathCE($path);
		
		for ($i = 0, $c = count($this->attributes); $i < $c; $i++) {
			$attrs = $this->attributes[$i];
			
			if (isset($attrs['write']) && isset($attrs['pattern']) && preg_match($attrs['pattern'], $testPath)) {
				$perm = $attrs['write'];
			} 
		}
		
		return $perm === null ? true : $perm;
	}
1087977
public static function prototype(?bool $isConsole = false) : array
  {
    return [
      'console' => $isConsole,
      'config' => Application::getConfig(),
      'events' => new Events,
      'route' => new Route,
      'view' => Template::class,
      'variables' => GlobalVariables::class
    ];
  }
840395
protected function assembleConfig(Traversable $config, $delimiter, $aligment, $sections = false) {
		$rows = [];
		
		if ($sections) {
			foreach ($config as $section => $data) {
				if ($data instanceof Traversable) {
					$rows[] = '[' . $section . ']';
					$rows[] = $this->assembleConfig($data, $delimiter, $aligment) . PHP_EOL;
				}
			}
		} else {
			$rawConfig = $this->iteratorToArray($config, $delimiter);
			
			if ($aligment) {
				$maxLength = 0;
				
				foreach (array_keys($rawConfig) as $key) {
					$keyLength = strlen($key);
					
					if ($maxLength < $keyLength) {
						$maxLength = $keyLength;
					}
				}
				
				foreach ($rawConfig as $key => $value) {
					$keyLength = strlen($key);
					
					if ($keyLength < $maxLength) {
						$key .= str_repeat(' ', $maxLength - $keyLength);
					}
					
					$rows[] = $key . ' = ' . $value;
				}
			} else {
				foreach ($rawConfig as $key => $value) {
					$rows[] = $key . ' = ' . $value;
				}
			}
		}
		
		return implode(PHP_EOL, $rows);
	}
151578
public function nodeString($indent = '', $isChild = false)
    {
        // non printable characters regex
        $nonPrintable = '#[^\x20-\x7E]#';

        //formatters
        $lt = '<';
        $gt = '>';
        $nl = "\n";
        if (!self::isCli()) {
            $lt = '&lt;';
            $gt = '&gt;';
            $nl = '<br />';
            $indent = str_replace(' ', '&nbsp;', $indent);
        }

        $ret = $indent.$lt.$this->tag;
        if ($this->attributeHash != null) {
            foreach ($this->attributeHash as $key => $value) {
                $ret .= ' '.$key.'="'.$value.'"';
            }
        }
        $ret .= $gt;
        if (strlen($this->data) > 0) {
            if (strlen($this->data) <= 1024) {
                //message
                if (preg_match($nonPrintable, $this->data)) {
                    $ret .= bin2hex($this->data);
                } else {
                    $ret .= $this->data;
                }
            } else {
                //raw data
                $ret .= ' '.strlen($this->data).' byte data';
            }
        }
        if ($this->children) {
            $ret .= $nl;
            $foo = [];
            foreach ($this->children as $child) {
                $foo[] = $child->nodeString($indent.'  ', true);
            }
            $ret .= implode($nl, $foo);
            $ret .= $nl.$indent;
        }
        $ret .= $lt.'/'.$this->tag.$gt;

        if (!$isChild) {
            $ret .= $nl;
            if (!self::isCli()) {
                $ret .= $nl;
            }
        }

        return $ret;
    }