Parses the evaluate string for runtime evaluations and returns the corresponding conditions array

@param string $evaluateString The evaluate string defined in the pointcut expression
@return array The corresponding constraints array
178263
protected function getRuntimeEvaluationConditionsFromEvaluateString(string $evaluateString): array
    {
        $matches = [];
        $runtimeEvaluationConditions = [];

        preg_match_all(self::PATTERN_MATCHRUNTIMEEVALUATIONSDEFINITION, $evaluateString, $matches);

        $matchesCount = count($matches[0]);
        for ($i = 0; $i < $matchesCount; $i++) {
            if ($matches[2][$i] === 'in' || $matches[2][$i] === 'matches') {
                $list = [];
                $listEntries = [];

                if (preg_match('/^\s*\(.*\)\s*$/', $matches[3][$i], $list) > 0) {
                    preg_match_all(self::PATTERN_MATCHRUNTIMEEVALUATIONSVALUELIST, $list[0], $listEntries);
                    $matches[3][$i] = $listEntries[1];
                }
            }

            $runtimeEvaluationConditions[] = [
                'operator' => $matches[2][$i],
                'leftValue' => $matches[1][$i],
                'rightValue' => $matches[3][$i],
            ];
        }
        return $runtimeEvaluationConditions;
    }
59093
public static function fromString($constraintExpression)
    {
        if (!preg_match('/^(==?|\!=?|~|[<>]=?)?((?:\*|[0-9]+)(?:.(?:\*|[0-9]+))*)(?:\@(\w+))?$/', $constraintExpression, $m)) {
            throw new \InvalidArgumentException("Constraint expression '$constraintExpression' could not be parsed");
        }
        return new self(
            !empty($m[1]) ? $m[1] : '=',
            $m[2],
            !empty($m[3]) ? $m[3] : 'stable'
        );
    }
687518
private void evaluateExpressions() throws JspException {
        Object obj = null;

        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        // 'value' attribute
        if (value_ != null) {
            value = ExpressionEvaluatorManager.evaluate(
                    "value", value_, Object.class, this, pageContext);
        }

        // 'type' attribute
        if (type_ != null) {
            type = (String) ExpressionEvaluatorManager.evaluate(
                    "type", type_, String.class, this, pageContext);
        }

        // 'pattern' attribute
        if (pattern_ != null) {
            pattern = (String) ExpressionEvaluatorManager.evaluate(
                    "pattern", pattern_, String.class, this, pageContext);
        }

        // 'currencyCode' attribute
        if (currencyCode_ != null) {
            currencyCode = (String) ExpressionEvaluatorManager.evaluate(
                    "currencyCode", currencyCode_, String.class, this,
                    pageContext);
        }

        // 'currencySymbol' attribute
        if (currencySymbol_ != null) {
            currencySymbol = (String) ExpressionEvaluatorManager.evaluate(
                    "currencySymbol", currencySymbol_, String.class, this,
                    pageContext);
        }

        // 'groupingUsed' attribute
        if (groupingUsed_ != null) {
            obj = ExpressionEvaluatorManager.evaluate(
                    "groupingUsed", groupingUsed_, Boolean.class, this,
                    pageContext);
            if (obj != null) {
                isGroupingUsed = ((Boolean) obj).booleanValue();
            }
        }

        // 'maxIntegerDigits' attribute
        if (maxIntegerDigits_ != null) {
            obj = ExpressionEvaluatorManager.evaluate(
                    "maxIntegerDigits", maxIntegerDigits_, Integer.class, this,
                    pageContext);
            if (obj != null) {
                maxIntegerDigits = ((Integer) obj).intValue();
            }
        }

        // 'minIntegerDigits' attribute
        if (minIntegerDigits_ != null) {
            obj = ExpressionEvaluatorManager.evaluate(
                    "minIntegerDigits", minIntegerDigits_, Integer.class, this,
                    pageContext);
            if (obj != null) {
                minIntegerDigits = ((Integer) obj).intValue();
            }
        }

        // 'maxFractionDigits' attribute
        if (maxFractionDigits_ != null) {
            obj = ExpressionEvaluatorManager.evaluate(
                    "maxFractionDigits", maxFractionDigits_, Integer.class, this,
                    pageContext);
            if (obj != null) {
                maxFractionDigits = ((Integer) obj).intValue();
            }
        }

        // 'minFractionDigits' attribute
        if (minFractionDigits_ != null) {
            obj = ExpressionEvaluatorManager.evaluate(
                    "minFractionDigits", minFractionDigits_, Integer.class, this,
                    pageContext);
            if (obj != null) {
                minFractionDigits = ((Integer) obj).intValue();
            }
        }
    }
1199005
public function getParsedString($string)
    {
        $member = $this->getMember();
        $page = $this->getPage();

        /**
         * @var \SilverStripe\ORM\FieldType\DBDatetime $createdDateObj
         */
        $createdDateObj = $member->obj('Created');

        $absoluteBaseURL = $this->BaseURL();
        $variables = array(
            '$SiteName'       => SiteConfig::current_site_config()->Title,
            '$LoginLink'      => Controller::join_links(
                $absoluteBaseURL,
                singleton(Security::class)->Link('login')
            ),
            '$ConfirmLink'    => Controller::join_links(
                $this->page->AbsoluteLink('confirm'),
                $member->ID,
                "?key={$member->ValidationKey}"
            ),
            '$LostPasswordLink' => Controller::join_links(
                $absoluteBaseURL,
                singleton(Security::class)->Link('lostpassword')
            ),
            '$Member.Created' => $createdDateObj->Nice()
        );
        foreach (array('Name', 'FirstName', 'Surname', 'Email') as $field) {
            $variables["\$Member.$field"] = $member->$field;
        }
        $this->extend('updateEmailVariables', $variables);

        return str_replace(array_keys($variables), array_values($variables), $string);
    }
662976
public function getValues(string $rawString)
    {
        $regExp = $this->getStrRegExp();
        $params = $this->getParameters();
        $matches = [];

        preg_match_all($regExp, $rawString, $matches);
        array_shift($matches);

        $map = function ($match) {
            return isset($match[0]) ? $match[0] : null;
        };

        return array_combine($params, array_map($map, $matches));
    }
1182957
public function parse()
    {
        // Note: Order is very important here!
        $operators = [
            Expression::OPERATOR_GTE,
            Expression::OPERATOR_LTE,
            Expression::OPERATOR_NOT,
            Expression::OPERATOR_EQ,
            Expression::OPERATOR_GT,
            Expression::OPERATOR_LT
        ];

        foreach ($operators as $operator) {
            $pos = strpos($this->rawExpression, $operator);

            if ($pos) {

                return new Expression(
                    substr($this->rawExpression, 0, $pos),
                    $operator,
                    substr($this->rawExpression, $pos + strlen($operator))
                );
            }
        }

        // Throw an exception if an operator can't be found
        throw new InvalidExpressionException();
    }
668840
public function load($xmlString)
    {
        $data   =  $this->parserXml($xmlString);

        if (!isset($data['MsgType'])) {
            throw new \RuntimeException("can not found MsgType");
        }

        // event message
        if (WxReceive::MSG_TYPE_EVENT == $data['MsgType']) {
            $parser = new Event\Parser();
            return $parser->load($data);
        }

        // other message
        $parser = new Message\Parser();
        return $parser->load($data);
    }
1305867
public function parse( $string )
	{
		if( !is_string( $string ) )														//  no String given
			throw new InvalidArgumentException( 'Given argument is not a string' );		//  throw Exception

		$this->extendPossibleOptionsWithShortcuts();									//  realize Shortcuts

		$position	= 0;																//  initiate Sign Pointer
		$status		= self::STATUS_START;												//  initiate Status
		$buffer		= "";																//  initiate Argument Buffer
		$option		= "";																//  initiate Option Buffer

		while( isset( $string[$position] ) )											//  loop until End of String
		{
			$sign	= $string[$position];												//  get current Sign
			$position ++;																//  increase Sign Pointer

			switch( $status )															//  handle Sign depending on Status
			{
				case self::STATUS_START:												//  open for all Signs
					$this->onReady( $sign, $status, $buffer, $option );					//  handle Sign
					break;
				case self::STATUS_READ_OPTION_KEY:										//  open for Option Key Signs
					$this->onReadOptionKey( $sign, $status, $buffer, $option );			//  handle Sign
					break;
				case self::STATUS_READ_OPTION_VALUE:									//  open for Option Value Signs
					$this->onReadOptionValue( $sign, $status, $buffer, $option );		//  handle Sign
					break;
				case self::STATUS_READ_ARGUMENT:										//  open for Argument Signs
					$this->onReadArgument( $sign, $status, $buffer );					//  handle Sign
					break;
			}
		}
		$this->onEndOfLine( $status, $buffer, $option );								//  close open States
	}
371855
public static Object evaluate(String attributeName,
                                  String expression,
                                  Class expectedType,
                                  PageContext pageContext)
            throws JspException {

        return evaluate(attributeName, expression, expectedType, null, pageContext);
    }
1285907
public function getValue( $variableSet, $evaluationResult, $log )
	{
		$aspect = $variableSet->aspectModel == 'dimensional'
			? ( $this->occ == 'segment' ? ASPECT_NON_XDT_SEGMENT : ASPECT_NON_XDT_SCENARIO )
			: ( $this->occ == 'segment' ? ASPECT_COMPLETE_SEGMENT : ASPECT_COMPLETE_SCENARIO );

		$sourceFact = $variableSet->getSourceFact( $this->source, $evaluationResult, $aspect, $log );
		if ( ! $sourceFact ) return null;
		$contextRef = FactValues::getContextRef( $sourceFact );
		if ( ! $contextRef ) return null;
		$context = $variableSet->xbrlInstance->getContext( $contextRef );
		// $component = isset( $context['entity'][ $this->occ ]['member'] )
		// 	? $context['entity'][ $this->occ ]['member']
		// 	: array();
		$components = array();
		if ( ! $this->select ) return $components;

		$componentNodes = $this->evaluateXPath( $variableSet, "{$this->select}", array( $this->getSourceName() => $sourceFact ) );

		foreach ( $componentNodes as $node )
		{
			if ( ( $this->occ == 'scenario' || $this->occ == 'segment' ) &&
				 $node->getNamespaceURI() == \XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLDI] )
			{
				$log->formula_validation( "OCC XPath", "The result of the XPath query is not consistent with ",
					array(
						'occ' => $this->occ,
						'xpath' => $this->select,
						'error' => 'xbrlfe:badSubsequentOCCValue'
					)
				);
			}
			$components[] = array( 'name' => $node->getName(), 'member' => '' );
		}

		return $components;
	}
1032206
static function evalConstant ($exp, &$valid = null)
  {
    $exp = trim ($exp);
    if ($exp !== '') {
      $valid = true;
      if ($exp[0] == '"' || $exp[0] == "'") return substr ($exp, 1, -1);
      if (is_numeric ($exp)) {
        return ctype_digit ($exp) ? intval ($exp) : floatVal ($exp);
      }
      if (defined ($exp))
        return constant ($exp);
    }
    $valid = false;
    return null;
  }
885122
public function evaluateExpression(string $expression)
    {
        $expressionLanguage = new ExpressionLanguage();

        return $expressionLanguage->evaluate($expression, $this->services);
    }
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);
        }
    }
1119411
protected function evaluate($exp)
    {
        list(, $op, $left, $right, $whiteBefore, $whiteAfter) = $exp;

        $left = $this->reduce($left);
        $right = $this->reduce($right);

        if ($leftColor = $this->coerceColor($left)) {
            $left = $leftColor;
        }

        if ($rightColor = $this->coerceColor($right)) {
            $right = $rightColor;
        }

        $ltype = $left[0];
        $rtype = $right[0];

        // operators that work on all types
        if ($op == 'and') {
            return $this->toBool($left == self::$TRUE && $right == self::$TRUE);
        }

        if ($op == '=') {
            return $this->toBool($this->eq($left, $right));
        }

        if ($op == '+' && !is_null($str = $this->stringConcatenate($left, $right))) {
            return $str;
        }

        // type based operators
        $fname = "op_${ltype}_${rtype}";
        if (is_callable(array($this, $fname))) {
            $out = $this->$fname($op, $left, $right);
            if (!is_null($out)) {
                return $out;
            }
        }

        // make the expression look it did before being parsed
        $paddedOp = $op;
        if ($whiteBefore) {
            $paddedOp = ' '.$paddedOp;
        }
        if ($whiteAfter) {
            $paddedOp .= ' ';
        }

        return array('string', '', array($left, $paddedOp, $right));
    }
239917
public function initComponentsByString( $string, array $arguments )
    {

        // find operations
        if( preg_match_all( $this->getRegex(), $string, $matches ) ) {

            $operations = array( null );
            foreach( $matches[0] as $match ) {
                $operations[] = self::$operations[$match];
            }

            /*
            if( count( array_unique( $operations ) ) > 1 ) {
                throw new \Exception("don't support ambigous expressions");
            }
             */

            $elements = array_combine(
                array_map( 'lcfirst', preg_split( $this->getRegex(), $string ) ),
                $operations
            );

        } else {
            $elements[lcfirst($string)] = null;
        }

        // check we've been passed the right number of arguments
        if( count( $elements) !== count( $arguments ) ) {
            throw new \LogicException(
                sprintf(
                    "FindFilterComponent method `%s` has been split into %d components. Number of arguments passed %d. These should be the same.",
                    $string,
                    count( $elements ),
                    count( $arguments )
                )
            );
        }

        $output = array();
        foreach( $elements as $name => $operation ) {
            $output[$name] = $this->get(
                $name,
                $operation,
                array_shift( $arguments )
            );
        }

        return $output;

    }
1127462
protected function evaluate($condition)
    {
        if (null === $condition || false === $condition) {
            return false;
        }

        if (!is_string($condition)) {
            return false;
        }

        $condition = trim($condition);

        if (!strlen($condition)) {
            return false;
        }

        $config = $this->getConfig();

        if (0 < preg_match_all('/\$\\{\\s*([a-z0-9_\.]+)\\s*\\}/', $condition, $matches)) {
            foreach ($matches[0] as $i => $match) {
                $v = $config->get($matches[1][$i], null);
                $condition = str_replace($match, null === $v ? '""' : (is_numeric($v) ? $v : ('"'.str_replace('"', '\\"', (string) $v).'"')), $condition);
            }
        }

        $condition = trim($condition);

        if (0 < preg_match_all('/\%\\{\\s*([a-z0-9_]+)\\s*\\}/i', $condition, $matches)) {
            foreach ($matches[0] as $i => $match) {
                $v = getenv($matches[1][$i]);
                switch (true) {
                    case 'false' === ((string) $v):
                        $v = false;
                        break;
                    case 'true' === ((string) $v):
                        $v = true;
                        break;
                    case '1' === ((string) $v):
                        $v = 1;
                        break;
                    case false === $v:
                        $v = null;
                        break;
                    case null === $v:
                        $v = null;
                        break;
                    default:
                        if (!is_numeric($v)) {
                            $v = trim((string) $v);
                        }
                        break;
                }
                $condition = str_replace($match, null === $v ? '""' : (is_numeric($v) ? $v : ('"'.str_replace('"', '\\"', (string) $v).'"')), $condition);
            }
        }

        return $this->getExpressionService()->evaluate($condition, ['cfg' => $config]);
    }
1164982
protected function evaluateDateString($string)
    {
        $seconds = 1;
        $matches = [];
        preg_match('/^([0-9]*)([s|M|h|d|m|y])$/', $string, $matches);

        switch ($matches[2]) {
            case 's':
                $seconds = $matches[1];
                break;
            case 'M':
                $seconds = $this->evaluateDateString(60 * $matches[1] . 's');
                break;
            case 'h':
                $seconds = $this->evaluateDateString(60 * $matches[1] . 'M');
                break;
            case 'd':
                $seconds = $this->evaluateDateString(24 * $matches[1] . 'h');
                break;
            case 'm':
                $seconds = $this->evaluateDateString(30 * $matches[1] . 'd');
                break;
            case 'y':
                $seconds = $this->evaluateDateString(12 * $matches[1] . 'm');
                break;
        }

        return $seconds;
    }