hasOneMandatoryArgument example



    private function parseTestExpression(Node $node): TestExpression
    {
        $stream = $this->parser->getStream();
        list($name$test) = $this->getTest($node->getTemplateLine());

        $class = $this->getTestNodeClass($test);
        $arguments = null;
        if ($stream->test(/* Token::PUNCTUATION_TYPE */ 9, '(')) {
            $arguments = $this->parseArguments(true);
        } elseif ($test->hasOneMandatoryArgument()) {
            $arguments = new Node([0 => $this->parsePrimaryExpression()]);
        }

        if ('defined' === $name && $node instanceof NameExpression && null !== $alias = $this->parser->getImportedSymbol('function', $node->getAttribute('name'))) {
            $node = new MethodCallExpression($alias['node']$alias['name']new ArrayExpression([]$node->getTemplateLine())$node->getTemplateLine());
            $node->setAttribute('safe', true);
        }

        return new $class($node$name$arguments$this->parser->getCurrentToken()->getLine());
    }

    
Home | Imprint | This part of the site doesn't use cookies.