protected function buildRuntimeEvaluationsConditionCode($operator, array $conditions, &$useGlobalObjects = false)
    {
        $conditionsCode = [];

        if (count($conditions) === 0) {
            return '';
        }

        if (isset($conditions['evaluateConditions']) && is_array($conditions['evaluateConditions'])) {
            $conditionsCode[] = $this->buildGlobalRuntimeEvaluationsConditionCode($conditions['evaluateConditions'], $useGlobalObjects);
            unset($conditions['evaluateConditions']);
        }

        if (isset($conditions['methodArgumentConstraints']) && is_array($conditions['methodArgumentConstraints'])) {
            $conditionsCode[] = $this->buildMethodArgumentsEvaluationConditionCode($conditions['methodArgumentConstraints'], $useGlobalObjects);
            unset($conditions['methodArgumentConstraints']);
        }

        $subConditionsCode = '';
        if (count($conditions) > 1) {
            $isFirst = true;
            foreach ($conditions as $subOperator => $subCondition) {
                $negateCurrentSubCondition = false;
                if ($subOperator === '&&!') {
                    $subOperator = '&&';
                    $negateCurrentSubCondition = true;
                } elseif ($subOperator === '||!') {
                    $subOperator = '||';
                    $negateCurrentSubCondition = true;
                }

                $currentSubConditionsCode = $this->buildRuntimeEvaluationsConditionCode($subOperator, $subCondition, $useGlobalObjects);
                if ($negateCurrentSubCondition === true) {
                    $currentSubConditionsCode = '(!' . $currentSubConditionsCode . ')';
                }

                $subConditionsCode .= ($isFirst === true ? '(' : ' ' . $subOperator . ' ') . $currentSubConditionsCode;
                $isFirst = false;
            }
            $subConditionsCode .= ')';

            $conditionsCode[] = $subConditionsCode;
        } elseif (count($conditions) === 1) {
            $subOperator = key($conditions);
            $conditionsCode[] = $this->buildRuntimeEvaluationsConditionCode($subOperator, current($conditions), $useGlobalObjects);
        }

        $negateCondition = false;
        if ($operator === '&&!') {
            $operator = '&&';
            $negateCondition = true;
        } elseif ($operator === '||!') {
            $operator = '||';
            $negateCondition = true;
        }

        $resultCode = implode(' ' . $operator . ' ', $conditionsCode);

        if (count($conditionsCode) > 1) {
            $resultCode = '(' . $resultCode . ')';
        }
        if ($negateCondition === true) {
            $resultCode = '(!' . $resultCode . ')';
        }

        return $resultCode;
    }
protected function buildRuntimeEvaluationsConditionCode($operator, array $conditions, &$useGlobalObjects = false)
    {
        $conditionsCode = [];

        if (count($conditions) === 0) {
            return '';
        }

        if (isset($conditions['evaluateConditions']) && is_array($conditions['evaluateConditions'])) {
            $conditionsCode[] = $this->buildGlobalRuntimeEvaluationsConditionCode($conditions['evaluateConditions'], $useGlobalObjects);
            unset($conditions['evaluateConditions']);
        }

        if (isset($conditions['methodArgumentConstraints']) && is_array($conditions['methodArgumentConstraints'])) {
            $conditionsCode[] = $this->buildMethodArgumentsEvaluationConditionCode($conditions['methodArgumentConstraints'], $useGlobalObjects);
            unset($conditions['methodArgumentConstraints']);
        }

        $subConditionsCode = '';
        if (count($conditions) > 1) {
            $isFirst = true;
            foreach ($conditions as $subOperator => $subCondition) {
                $negateCurrentSubCondition = false;
                if ($subOperator === '&&!') {
                    $subOperator = '&&';
                    $negateCurrentSubCondition = true;
                } elseif ($subOperator === '||!') {
                    $subOperator = '||';
                    $negateCurrentSubCondition = true;
                }

                $currentSubConditionsCode = $this->buildRuntimeEvaluationsConditionCode($subOperator, $subCondition, $useGlobalObjects);
                if ($negateCurrentSubCondition === true) {
                    $currentSubConditionsCode = '(!' . $currentSubConditionsCode . ')';
                }

                $subConditionsCode .= ($isFirst === true ? '(' : ' ' . $subOperator . ' ') . $currentSubConditionsCode;
                $isFirst = false;
            }
            $subConditionsCode .= ')';

            $conditionsCode[] = $subConditionsCode;
        } elseif (count($conditions) === 1) {
            $subOperator = key($conditions);
            $conditionsCode[] = $this->buildRuntimeEvaluationsConditionCode($subOperator, current($conditions), $useGlobalObjects);
        }

        $negateCondition = false;
        if ($operator === '&&!') {
            $operator = '&&';
            $negateCondition = true;
        } elseif ($operator === '||!') {
            $operator = '||';
            $negateCondition = true;
        }

        $resultCode = implode(' ' . $operator . ' ', $conditionsCode);

        if (count($conditionsCode) > 1) {
            $resultCode = '(' . $resultCode . ')';
        }
        if ($negateCondition === true) {
            $resultCode = '(!' . $resultCode . ')';
        }

        return $resultCode;
    }
protected function buildRuntimeEvaluationsConditionCode ( $ operator , array $ conditions , & $ useGlobalObjects = false ) { $ conditionsCode = [ ] ; if ( count ( $ conditions ) === 0 ) { return '' ; } if ( isset ( $ conditions [ 'evaluateConditions' ] ) && is_array ( $ conditions [ 'evaluateConditions' ] ) ) { $ conditionsCode [ ] = $ this -> buildGlobalRuntimeEvaluationsConditionCode ( $ conditions [ 'evaluateConditions' ] , $ useGlobalObjects ) ; unset ( $ conditions [ 'evaluateConditions' ] ) ; } if ( isset ( $ conditions [ 'methodArgumentConstraints' ] ) && is_array ( $ conditions [ 'methodArgumentConstraints' ] ) ) { $ conditionsCode [ ] = $ this -> buildMethodArgumentsEvaluationConditionCode ( $ conditions [ 'methodArgumentConstraints' ] , $ useGlobalObjects ) ; unset ( $ conditions [ 'methodArgumentConstraints' ] ) ; } $ subConditionsCode = '' ; if ( count ( $ conditions ) > 1 ) { $ isFirst = true ; foreach ( $ conditions as $ subOperator => $ subCondition ) { $ negateCurrentSubCondition = false ; if ( $ subOperator === '&&!' ) { $ subOperator = '&&' ; $ negateCurrentSubCondition = true ; } elseif ( $ subOperator === '||!' ) { $ subOperator = '||' ; $ negateCurrentSubCondition = true ; } $ currentSubConditionsCode = $ this -> buildRuntimeEvaluationsConditionCode ( $ subOperator , $ subCondition , $ useGlobalObjects ) ; if ( $ negateCurrentSubCondition === true ) { $ currentSubConditionsCode = '(!' . $ currentSubConditionsCode . ')' ; } $ subConditionsCode .= ( $ isFirst === true ? '(' : ' ' . $ subOperator . ' ' ) . $ currentSubConditionsCode ; $ isFirst = false ; } $ subConditionsCode .= ')' ; $ conditionsCode [ ] = $ subConditionsCode ; } elseif ( count ( $ conditions ) === 1 ) { $ subOperator = key ( $ conditions ) ; $ conditionsCode [ ] = $ this -> buildRuntimeEvaluationsConditionCode ( $ subOperator , current ( $ conditions ) , $ useGlobalObjects ) ; } $ negateCondition = false ; if ( $ operator === '&&!' ) { $ operator = '&&' ; $ negateCondition = true ; } elseif ( $ operator === '||!' ) { $ operator = '||' ; $ negateCondition = true ; } $ resultCode = implode ( ' ' . $ operator . ' ' , $ conditionsCode ) ; if ( count ( $ conditionsCode ) > 1 ) { $ resultCode = '(' . $ resultCode . ')' ; } if ( $ negateCondition === true ) { $ resultCode = '(!' . $ resultCode . ')' ; } return $ resultCode ; }
Returns the PHP code of the conditions used for runtime evaluations

@param string $operator The operator for the given condition
@param array $conditions Condition array
@param boolean &$useGlobalObjects Set to true if global objects are used by the condition
@return string The condition code
Returns the PHP code of the conditions used for runtime evaluations