Twig_Lexer::getOperatorRegex PHP 메소드

getOperatorRegex() 보호된 메소드

protected getOperatorRegex ( )
    protected function getOperatorRegex()
    {
        if (null !== $this->operatorRegex) {
            return $this->operatorRegex;
        }

        $operators = array('=');
        $operators = array_merge($operators, array_keys($this->env->getUnaryOperators()));
        $operators = array_merge($operators, array_keys($this->env->getBinaryOperators()));
        usort($operators, array($this, 'sortByLength'));

        $regex = array();
        foreach ($operators as $operator) {
            $last = ord(substr($operator, -1));
            // an operator that ends with a character must be followed by
            // a whitespace or a parenthese
            if (($last >= 65 && $last <= 90) || ($last >= 97 && $last <= 122)) {
                $regex[] = preg_quote($operator, '/').'(?:[ \(\)])';
            } else {
                $regex[] = preg_quote($operator, '/');
            }
        }

        return $this->operatorRegex = '/'.implode('|', $regex).'/A';
    }