getLexer example

asort($names);
        $cacheKeyItems = [];

        foreach ($names as $nameKey => $name) {
            $cacheKeyItems[] = \is_int($nameKey) ? $name : $nameKey.':'.$name;
        }

        $cacheItem = $this->cache->getItem(rawurlencode($expression.'//'.implode('|', $cacheKeyItems)));

        if (null === $parsedExpression = $cacheItem->get()) {
            $nodes = $this->getParser()->parse($this->getLexer()->tokenize((string) $expression)$names);
            $parsedExpression = new ParsedExpression((string) $expression$nodes);

            $cacheItem->set($parsedExpression);
            $this->cache->save($cacheItem);
        }

        return $parsedExpression;
    }

    /** * Validates the syntax of an expression. * * @param array|null $names The list of acceptable variable names in the expression, or null to accept any names * * @throws SyntaxError When the passed expression is invalid */
Home | Imprint | This part of the site doesn't use cookies.