@return ExpressionFunction[]

@phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint
@phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.UselessReturnAnnotation
777126
public function getFunctions()
    {
        return [
            new ExpressionFunction('link', static function ($object, $rel, $absolute = false) {
                    return sprintf('$container->get(\'hateoas.helper.link\')->getLinkHref(%s, %s, %s)', $object, $rel, $absolute);
            }, static function ($context, $object, $rel, $absolute = false) {
                return $context['container']->get('hateoas.helper.link')->getLinkHref($object, $rel, $absolute);
            }),
        ];
    }
881960
public function getListFunctions() {
		if($this->listFunctions) return $this->listFunctions;

		$list = array ();
		foreach(ClassInfo::implementorsOf('SS_List') as $class) {
			$r = new ReflectionClass($class);			
			$methods = $r->getMethods();
			if($methods) {
				foreach($methods as $m) {
					$name = $m->getName();					
					if(preg_match("/[A-Z]/",$name[0])) {
						$list[] = strtolower($name);
					}											
				}
			}
		}

		return $this->listFunctions = $list;
	}
750531
static List<String> parseExpressionParameters(String expressionPart) {
        int parenthesisOpenPos = expressionPart.indexOf('(');
        int parenthesisClosePos = expressionPart.lastIndexOf(')');
        if (parenthesisOpenPos > 0 && parenthesisClosePos > 0) {
            expressionPart = expressionPart.substring(parenthesisOpenPos + 1,
                                                      parenthesisClosePos);
        }
        if (expressionPart.isEmpty()) {
            return Collections.emptyList();
        }
        return Arrays.asList(expressionPart.split(","));
    }
357597
private function parseExpression (){
		$entities = array();

		do{
			$e = $this->MatchFuncs(array('parseAddition','parseEntity'));
			if( $e ){
				$entities[] = $e;
				// operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
				if( !$this->PeekReg('/\\G\/[\/*]/') ){
					$delim = $this->MatchChar('/');
					if( $delim ){
						$entities[] = $this->NewObj1('Less_Tree_Anonymous',$delim);
					}
				}
			}
		}while($e);

		if( $entities ){
			return $this->NewObj1('Less_Tree_Expression',$entities);
		}
	}
390374
protected function _processExpressions()
    {
        $types = [];
        $typeMap = $this->getTypeMap();

        $columns = $this->_columnNames();
        foreach ($columns as $c) {
            if (!is_scalar($c)) {
                continue;
            }
            $types[$c] = $typeMap->type($c);
        }

        $types = $this->_requiresToExpressionCasting($types);

        if (empty($types)) {
            return;
        }

        foreach ($this->_values as $row => $values) {
            foreach ($types as $col => $type) {
                /* @var \Cake\Database\Type\ExpressionTypeInterface $type */
                $this->_values[$row][$col] = $type->toExpression($values[$col]);
            }
        }
        $this->_castedExpressions = true;
    }
415921
protected function evalExpression()
    {
        $this->log("Evaluating PHP expression: " . $this->expression, $this->logLevel);
        if (!StringHelper::endsWith(';', trim($this->expression))) {
            $this->expression .= ';';
        }

        if ($this->returnProperty !== null) {
            $retval = null;
            eval('$retval = ' . $this->expression);
            $this->project->setProperty($this->returnProperty, $retval);
        } else {
            eval($this->expression);
        }
    }
817080
private function Annotations()
    {
        $annotations = [];

        while (null !== $this->lexer->lookahead) {
            if (DocLexer::T_AT !== $this->lexer->lookahead['type']) {
                $this->lexer->moveNext();
                continue;
            }

            // make sure the @ is preceded by non-catchable pattern
            if (null !== $this->lexer->token && $this->lexer->lookahead['position'] === $this->lexer->token['position'] + strlen($this->lexer->token['value'])) {
                $this->lexer->moveNext();
                continue;
            }

            // make sure the @ is followed by either a namespace separator, or
            // an identifier token
            if ((null === $peek = $this->lexer->glimpse())
                || (DocLexer::T_NAMESPACE_SEPARATOR !== $peek['type'] && !in_array($peek['type'], self::$classIdentifiers, true))
                || $peek['position'] !== $this->lexer->lookahead['position'] + 1) {
                $this->lexer->moveNext();
                continue;
            }

            $this->isNestedAnnotation = false;
            if (false !== $annot = $this->Annotation()) {
                $annotations[] = $annot;
            }
        }

        return $annotations;
    }
975680
protected function compileExpressions()
    {
        if (count($this->expressions) === 0) {
            throw new BadMethodCallException('Can\'t compile an empty expression');
        }
        if (count($this->expressions) === 1) {
            return reset($this->expressions);
        }

        $parts = [];

        foreach ($this->expressions as $expr) {
            $expr = '(?:' . $expr . ')';

            $parts[] = $expr;
        }

        return '(?:' . implode('|', $parts) . ')';
    }
1131886
public static function fromExpressions(array $expressions, IEvaluationContext $context = null)
    {
        $evaluator            = new self($context);
        $namespace            = $evaluator->context->getNamespace();
        $contextParameterName = self::CONTEXT_PARAMETER_NAME;
        $variableTable        = $evaluator->context->getVariableTable();

        //Replace any non value types with references in the variable table.
        $expressions = (new DynamicExpressionWalker([
                ValueExpression::getType() =>
                        function (ValueExpression $expression) use ($evaluator, $variableTable, &$name) {
                            $value = $expression->getValue();
                            if (!ValueExpression::isValueType($value)) {
                                $name = $name !== null ? $name : 0;
                                do {
                                    $name++;
                                } while (isset($variableTable['o' . $name]));

                                $name                             = 'o' . $name;
                                $evaluator->extraVariables[$name] = $value;

                                return Expression::variable(Expression::value($name));
                            }

                            return $expression;
                        }
        ]))->walkAll($expressions);

        $bodyCode = '';
        foreach ($evaluator->extraVariables + $variableTable as $variable => $value) {
            $variableName = Expression::value($variable);
            $variableCode = Expression::variable($variableName)->compile();
            $bodyCode .= "$variableCode =& $$contextParameterName" . '[' . $variableName->compile() . '];';
        }

        $bodyCode .= "unset($$contextParameterName);";
        $bodyCode .= implode(';', Expression::compileAll($expressions)) . ';';
        $evaluator->code = <<<PHP
namespace {$namespace} {
    return function ($$contextParameterName) {
        $bodyCode
    };
}
PHP;

        $evaluator->initializeEvaluator();

        return $evaluator;
    }
852120
public function flushExpression() {
        $args = func_get_args();
        $result = array();
        foreach (Mage::helper('turpentine/varnish')->getSockets() as $socket) {
            $socketName = $socket->getConnectionString();
            try {
                call_user_func_array(array($socket, 'ban'), $args);
            } catch (Mage_Core_Exception $e) {
                $result[$socketName] = $e->getMessage();
                continue;
            }
            $result[$socketName] = true;
        }
        return $result;
    }
133033
public function getFunctions()
    {
        $stmts = [];
        $stmts['drop/function/slugify'] = 'DROP FUNCTION IF EXISTS `slugify`';
        $stmts['create/function/slugify'] = <<< ENDQ
        CREATE FUNCTION `slugify` (dirty_string VARCHAR(255))
        RETURNS VARCHAR(255) CHARSET latin1
        DETERMINISTIC
        BEGIN
            DECLARE x, y , z INT;
            DECLARE temp_string, new_string VARCHAR(255);
            DECLARE is_allowed BOOL;
            DECLARE c, check_char VARCHAR(1);

            SET temp_string = LOWER(dirty_string);

            SET temp_string = REPLACE(temp_string, '&', ' and ');

            SELECT temp_string REGEXP('[^a-z0-9\-]+') INTO x;
            IF x = 1 THEN
                SET z = 1;
                WHILE z <= CHAR_LENGTH(temp_string) DO
                    SET c = SUBSTRING(temp_string, z, 1);
                    SET is_allowed = FALSE;
                    IF !((ascii(c) = 45) or (ascii(c) >= 48 and ascii(c) <= 57) or (ascii(c) >= 97 and ascii(c) <= 122)) THEN
                        SET temp_string = REPLACE(temp_string, c, '-');
                    END IF;
                    SET z = z + 1;
                END WHILE;
            END IF;

            SELECT temp_string REGEXP("^-|-$|'") INTO x;
            IF x = 1 THEN
                SET temp_string = REPLACE(temp_string, "'", '');
                SET z = CHAR_LENGTH(temp_string);
                SET y = CHAR_LENGTH(temp_string);
                Dash_check: WHILE z > 1 DO
                    IF STRCMP(SUBSTRING(temp_string, -1, 1), '-') = 0 THEN
                        SET temp_string = SUBSTRING(temp_string,1, y-1);
                        SET y = y - 1;
                    ELSE
                        LEAVE Dash_check;
                    END IF;
                    SET z = z - 1;
                END WHILE;
            END IF;

            REPEAT
                SELECT temp_string REGEXP("--") INTO x;
                IF x = 1 THEN
                    SET temp_string = REPLACE(temp_string, "--", "-");
                END IF;
            UNTIL x <> 1 END REPEAT;

            IF LOCATE('-', temp_string) = 1 THEN
                SET temp_string = SUBSTRING(temp_string, 2);
            END IF;

            RETURN temp_string;
        END        
ENDQ;

        $stmts['drop/function/strip_tags'] = 'DROP FUNCTION IF EXISTS `strip_tags`';
        $stmts['create/function/strip_tags'] = <<< 'ENDQ'
        CREATE FUNCTION strip_tags( DIRTY VARCHAR(3000) )
        RETURNS VARCHAR(3000) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci
        DETERMINISTIC 
        BEGIN
          DECLARE iStart, iEnd, iLength int;
            WHILE LOCATE( '<', DIRTY ) > 0 And LOCATE( '>', DIRTY, LOCATE( '<', DIRTY )) > 0 DO
              BEGIN
                SET iStart = LOCATE( '<', DIRTY ), iEnd = LOCATE( '>', DIRTY, LOCATE('<', DIRTY ));
                SET iLength = ( iEnd - iStart) + 1;
                IF iLength > 0 THEN
                  BEGIN
                    SET DIRTY = INSERT( DIRTY, iStart, iLength, '');
                  END;
                END IF;
              END;
            END WHILE;
            RETURN DIRTY;
        END;
ENDQ;

        $stmts['drop/function/delete_double_spaces'] = 'DROP FUNCTION IF EXISTS `delete_double_spaces`';
        $stmts['create/function/delete_double_spaces'] = <<< 'ENDQ'
        CREATE FUNCTION delete_double_spaces ( title VARCHAR(3000) )
        RETURNS VARCHAR(3000) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci 
        DETERMINISTIC
        BEGIN
            DECLARE result VARCHAR(3000);
            SET result = REPLACE( title, '  ', ' ' );
            WHILE (result <> title) DO 
                SET title = result;
                SET result = REPLACE( title, '  ', ' ' );
            END WHILE;
            RETURN result;
        END;
ENDQ;

        $stmts['drop/function/get_searchable_reference'] = 'DROP FUNCTION IF EXISTS `get_searchable_reference`';
        $stmts['create/function/get_searchable_reference'] = <<< 'ENDQ'
        CREATE FUNCTION `get_searchable_reference` (`in_str` VARCHAR(2048)) 
        RETURNS VARCHAR(2048) CHARSET utf8mb4
        DETERMINISTIC        
        BEGIN
            /*
              This function escape a string from any non alphanumeric chars (A_Z0_9)
              to get a searchable reference. Also try to remove any first 
              non-significative zero.

              FOR example 'BA-0114-22' -> 'BA11422'  

            */    
            DECLARE out_str VARCHAR(2048) DEFAULT '';
            DECLARE c VARCHAR(1) DEFAULT '';
            DECLARE prev_c VARCHAR(1) DEFAULT '';
            DECLARE pointer INT DEFAULT 1;

            IF ISNULL(in_str) THEN
                RETURN NULL;
            ELSE
                WHILE pointer <= LENGTH(in_str) DO
                    SET c = UPPER(MID(in_str, pointer, 1));

                    -- TAKE ONLY [A-Z0-9] characters
                    IF  ((ASCII(c) > 64 AND ASCII(c) < 92) or (ASCII(c) > 47 AND ASCII(c) < 58))
                    THEN
                        -- IF A NUMBER, try to get rid of non-significave numbers
                        IF (ASCII(c) > 47 AND ASCII(c) < 58)
                        THEN 
                            -- IF C is a zero and PREVIOUS CHARACTER IS NUMERIC
                            IF (c = 0 and NOT (ASCII(prev_c) > 47 AND ASCII(prev_c) < 58))
                            THEN
                                -- NOTHING
                                SET c = c;
                            ELSE
                                SET out_str = CONCAT(out_str, c);
                            END IF;
                        ELSE 
                            SET out_str = CONCAT(out_str, c);
                        END IF;
                    END IF;
                    SET prev_c = c;
                    SET pointer = pointer + 1;
                END WHILE;
            END IF;

            RETURN UPPER(out_str);
        END;
ENDQ;

        return $stmts;
    }
75122
private static function treeStruct(string $expression): array
    {
        if (\strpos($expression, '<?') === 0 || $expression[-1] === ';') {
            throw new \InvalidArgumentException('Expression syntax error');
        }

        $expression = '<?php ' . $expression . ';';

        $tokens = \token_get_all($expression);

        $temp = [];
        $level = 0;

        $n = \count($tokens);
        $i = 1; // skip T_OPEN_TAG
        for (; $i < $n; ++$i) {
            $token = $tokens[$i];

            $type = null;
            if (\is_array($token)) {
                $type = $token[0];

                if ($type === T_WHITESPACE) {
                    continue;
                }

                if (!\in_array($type, self::SUPPORT_TOKEN, true)) {
                    throw new \InvalidArgumentException('Expression contains not support token "' . \token_name($type) . '""');
                }

                if ($type === T_INC && ($tokens[$i - 1] === '+' || $tokens[$i + 1] === '+')) {
                    throw new \InvalidArgumentException('Expression contains error code: "+++');
                }

                if ($type === T_DEC && ($tokens[$i - 1] === '-' || $tokens[$i + 1] === '-')) {
                    throw new \InvalidArgumentException('Expression contains error code: "---');
                }
            }

            switch ($token) {
                case '?':
                    $part = $temp[$level];

                    if ($level === 0) {
                        $temp[$level++] = [$part, new Token($token)];
                    } else {
                        $parentLevel = $level - 1;
                        $temp[$parentLevel][] = $part;
                        $temp[$parentLevel][] = new Token($token);
                    }

                    $temp[$level] = [];
                    break;

                case ':':
                    if ($level === 0) {
                        throw new \InvalidArgumentException('Expression ternary syntax error');
                    }

                    $part = $temp[$level];

                    $parentLevel = $level - 1;
                    $temp[$parentLevel][] = $part;
                    $temp[$parentLevel][] = new Token($token);

                    $temp[$level] = [];
                    break;

                case ';':
                    if ($level > 0) {
                        $part = $temp[$level];
                        unset($temp[$level]);

                        $temp[--$level][] = $part;
                    }
                    ++$i;
                    break 2;
                case ')':
                case ']':
                    $temp[$level][] = new Token($token);
                    $part = $temp[$level];
                    unset($temp[$level]);

                    $temp[--$level][] = $part;
                    break;

                case '(':
                case '[':
                    $temp[++$level] = [new Token($token)];
                    break;

                default:
                    $temp[$level][] = new Token($token);
            }
        }

        if ($i !== $n) {
            throw new \InvalidArgumentException('The code has multi-line expression');
        }

        if (\count($temp) > 1) {
            throw new \InvalidArgumentException('Expression syntax error');
        }

        return $temp[0];
    }
41084
public function getFunctions()
    {
        return [
            /**
             * Evaluate a rule by name.
             */
            new ExpressionFunction(
                'money',
                function () {
                    throw new RuntimeException(
                        'Function "money" can\'t be compiled.'
                    );
                },
                function (array $context, $amount, $currencyIso = null) {

                    if ($currencyIso === null) {
                        $currency = $this
                            ->defaultCurrencyWrapper
                            ->get();
                    } else {
                        /**
                         * @var CurrencyInterface $currency
                         */
                        $currency = $this
                            ->currencyRepository
                            ->findOneBy([
                                'iso' => $currencyIso,
                            ]);
                    }

                    return Money::create(
                        $amount * 100,
                        $currency
                    );
                }
            ),
        ];
    }
468517
public function getRule()
    {
        $returnValue = (string) '';

        
    // Get subExpressions
        $subExpressionsRules = array();
        foreach ($this->subExpressions as $subExpression){
            $subExpressionsRules[] = $subExpression->getRule();
        }
        $subExpressionsJSON = implode(',', $subExpressionsRules);

        // Format options
        $optionsJSON = count($this->attributes) ? '"'.addslashes(json_encode($this->attributes)).'"' : 'null';
        
        // Format rule function of the expression operator
        switch ($this->name) {
            case 'correct':
                $returnValue = 'getCorrect("'.$this->attributes['identifier'].'")';
                break;
            case 'mapResponse':
                $identifier = $this->attributes['identifier'];
                $returnValue = 'mapResponse('
                    . $optionsJSON
                    .', getMap("'.$identifier.'"), getResponse("'.$identifier.'"))';
                break;
            // Multiple is a Creation of List from parameters
            case 'multiple':
                $returnValue = 'createVariable("{\"type\":\"list\"}", '.$subExpressionsJSON.')';
                break;
            // Null is a Creation of empty BaseTypeVariable
            case 'null':
                $returnValue = 'createVariable(null, null)';
                break;
            // Ordered is a Creation of Tuple from parameters
            case 'ordered':
                $returnValue = 'createVariable("{\"type\":\"tuple\"}", '.$subExpressionsJSON.')';
                break;
            case 'outcome':
                $returnValue = 'getOutcome("'.$this->attributes['identifier'].'")';
                break;
            case 'setOutcomeValue':
                //@todo remove this
                throw new common_Exception('setOutcomeValue is not a valid expression');
                break;
            case 'variable':
                $returnValue = 'getVariable("'.$this->attributes['identifier'].'")';
                break;
            
            default:                 
                $returnValue = 
                    $this->name.'('
                        . $optionsJSON
                        . ($subExpressionsJSON!="" ? ', '.$subExpressionsJSON : '')
                    .')';
        }
        

        return (string) $returnValue;
    }
495627
public function SimpleSelectExpression()
    {
        $peek = $this->lexer->glimpse();

        switch ($this->lexer->lookahead['type']) {
            case Lexer::T_IDENTIFIER:
                switch (true) {
                    case $peek['type'] === Lexer::T_DOT:
                        $expression = $this->StateFieldPathExpression();

                        return new AST\SimpleSelectExpression($expression);
                    case $peek['type'] !== Lexer::T_OPEN_PARENTHESIS:
                        $expression = $this->IdentificationVariable();

                        return new AST\SimpleSelectExpression($expression);
                    case $this->isFunction():
                        // SUM(u.id) + COUNT(u.id)
                        if ($this->isMathOperator($this->peekBeyondClosingParenthesis())) {
                            return new AST\SimpleSelectExpression($this->ScalarExpression());
                        }
                        // COUNT(u.id)
                        if ($this->isAggregateFunction($this->lexer->lookahead['type'])) {
                            return new AST\SimpleSelectExpression($this->AggregateExpression());
                        }

                        // IDENTITY(u)
                        return new AST\SimpleSelectExpression($this->FunctionDeclaration());
                    default:
                        // Do nothing
                }
                break;

            case Lexer::T_OPEN_PARENTHESIS:
                if ($peek['type'] !== Lexer::T_SELECT) {
                    // Shortcut: ScalarExpression => SimpleArithmeticExpression
                    $expression = $this->SimpleArithmeticExpression();

                    return new AST\SimpleSelectExpression($expression);
                }

                // Subselect
                $this->match(Lexer::T_OPEN_PARENTHESIS);
                $expression = $this->Subselect();
                $this->match(Lexer::T_CLOSE_PARENTHESIS);

                return new AST\SimpleSelectExpression($expression);
            default:
                // Do nothing
        }

        $this->lexer->peek();

        $expression = $this->ScalarExpression();
        $expr       = new AST\SimpleSelectExpression($expression);

        if ($this->lexer->isNextToken(Lexer::T_AS)) {
            $this->match(Lexer::T_AS);
        }

        if ($this->lexer->isNextToken(Lexer::T_IDENTIFIER)) {
            $token                             = $this->lexer->lookahead;
            $resultVariable                    = $this->AliasResultVariable();
            $expr->fieldIdentificationVariable = $resultVariable;

            // Include AliasResultVariable in query components.
            $this->queryComponents[$resultVariable] = [
                'resultvariable' => $expr,
                'nestingLevel'   => $this->nestingLevel,
                'token'          => $token,
            ];
        }

        return $expr;
    }
338188
public String getExpressionString() {
        StringBuffer b = new StringBuffer();
        b.append(functionName);
        b.append("(");
        Iterator i = argumentList.iterator();
        while (i.hasNext()) {
            b.append(((Expression) i.next()).getExpressionString());
            if (i.hasNext()) {
                b.append(", ");
            }
        }
        b.append(")");
        return b.toString();
    }
492400
public function buildExpressions()
	{
		$this->expressions	= array();
		$values	= array_keys( $this->data );
		for( $i=0; $i<count( $values ); $i++ )
		{
			$this->expressions[$i]	= "";
			for( $k=0; $k<count( $values ) ;$k++ )
			{
				if( $k == $i )
					continue;
				$expression	= "(x-".$values[$k].")/(".$values[$i]."-".$values[$k].")";
				if( strlen( $this->expressions[$i] ) )
					$this->expressions[$i]	.= "*".$expression;
				else
					$this->expressions[$i]	= $expression;
			}
		}
	}