Method processConstraint.
A constraint is a list of conditions and an explanation.
@return Rule
@throws ParserException
772494
private AbstractRule processConstraint(RulesTextProvider textProvider)
    	throws ParserException
    {
    	log.debug("processConstraint");
        Constraint rule = new Constraint();
        int start = textProvider.getPos();
        LoadCommonRuleData(rule,textProvider);
        textProvider.addTOCElement(null, rule.getDescription(), start, textProvider.getPos(), TYPE_CONSTRAINT);
        exactOrError("{",textProvider);
        Expression condition = processAction(textProvider);
        if (condition.isAssign())
        {
            throw new ParserException("Found an assignment in a condition ",textProvider);
        }
        exactOrError("}",textProvider);
        rule.addCondition(condition);

        return rule;
    }
380184
public function addConstraints()
    {
        if (static::$constraints) {
            $table = $this->related->getTable();

            $this->query->where($table.'.'.$this->otherKey, '=', $this->parent->{$this->foreignKey});
        }
    }
288324
public function parse($rule)
    {
        if ($this->parser === null) {
            $this->parser = Compiler\Llk::load(
                new File\Read(__DIR__.'/../Grammar.pp')
            );
        }

        $this->nextParameterIndex = 0;

        return $this->visit($this->parser->parse($rule));
    }
1253886
public final void setConstraint(Constraint constraint) {
        Assert.notNull(constraint);
        if (!constraint.equals(this.constraint)) {
            if (this.constraint instanceof Observable) {
                ((Observable) constraint).deleteObserver(this);
            }
            this.constraint = constraint;
            if (constraint instanceof Observable) {
                ((Observable) constraint).addObserver(this);
            }
            fireContentsChanged(this, -1, -1);
        }
    }
83858
public static function createFromConstraintViolationList(ConstraintViolationListInterface $errors)
    {
        $exception = static::createUnprocessable('Input validation errors.');

        /** @var ConstraintViolationInterface $error */
        foreach ($errors as $error) {
            $exception->errorValidation($error->getPropertyPath(), $error->getMessage());
        }

        return $exception;
    }
927545
public function guessTypeForConstraint(Constraint $constraint)
    {
        $empty = null;

        switch (\get_class($constraint)) {
            case 'Symfony\Component\Validator\Constraints\Type':
                /* @var \Symfony\Component\Validator\Constraints\Type $constraint */
                switch ($constraint->type) {
                    case 'array':
                        return new TypeGuess(CollectionType::class, [], Guess::MEDIUM_CONFIDENCE);
                    case 'boolean':
                    case 'bool':
                        return new TypeGuess(CheckboxType::class, [], Guess::MEDIUM_CONFIDENCE);

                    case 'double':
                    case 'float':
                    case 'numeric':
                    case 'real':
                        return new TypeGuess(NumberType::class, [], Guess::MEDIUM_CONFIDENCE);

                    case 'integer':
                    case 'int':
                    case 'long':
                        return new TypeGuess(IntegerType::class, [], Guess::MEDIUM_CONFIDENCE);

                    case '\DateTime':
                        return new TypeGuess(DateType::class, [], Guess::MEDIUM_CONFIDENCE);

                    case 'string':
                        return new TypeGuess(TextType::class, [], Guess::LOW_CONFIDENCE);
                }
                break;

            case 'Symfony\Component\Validator\Constraints\Country':
                return new TypeGuess(CountryType::class, [], Guess::HIGH_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\Date':
                return new TypeGuess(DateType::class, ['input' => 'string'], Guess::HIGH_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\DateTime':
                return new TypeGuess(DateTimeType::class, ['input' => 'string'], Guess::HIGH_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\Email':
                return new TypeGuess(EmailType::class, [], Guess::HIGH_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\File':
            case 'Symfony\Component\Validator\Constraints\Image':
                return new TypeGuess(TextType::class, [], Guess::HIGH_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\Language':
                return new TypeGuess(LanguageType::class, [], Guess::HIGH_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\Locale':
                return new TypeGuess(LocaleType::class, [], Guess::HIGH_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\Time':
                return new TypeGuess(TimeType::class, ['input' => 'string'], Guess::HIGH_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\Url':
                return new TypeGuess(UrlType::class, [], Guess::HIGH_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\Ip':
                return new TypeGuess(TextType::class, [], Guess::MEDIUM_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\Length':
            case 'Symfony\Component\Validator\Constraints\Regex':
                return new TypeGuess(TextType::class, [], Guess::LOW_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\Range':
                return new TypeGuess(NumberType::class, [], Guess::LOW_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\Count':
                return new TypeGuess(CollectionType::class, [], Guess::LOW_CONFIDENCE);

            case 'Symfony\Component\Validator\Constraints\IsTrue':
            case 'Symfony\Component\Validator\Constraints\IsFalse':
                return new TypeGuess(CheckboxType::class, [], Guess::MEDIUM_CONFIDENCE);
        }

        return $empty;
    }
820560
private AbstractRule processRule(RulesTextProvider textProvider)
    {
    	log.debug("processRule");
    	int start = textProvider.getPos();
        Rule rule = new Rule();
        LoadCommonRuleData(rule,textProvider);
        textProvider.addTOCElement(null, rule.getDescription(), start, textProvider.getPos(), TYPE_RULE);
        exactOrError("{",textProvider);
        
        if (!exact("if",textProvider))
            throw new ParserException("expected 'if' in a rule: ",textProvider);
        // Condition
        Expression condition = processCondition(textProvider);
        rule.addCondition(condition);
        exactOrError("{",textProvider);
        while (!exact("}",textProvider))
        {
            Expression action = processAction(textProvider);
            exact(";",textProvider);
            rule.addAction(action);
        }
        exact("}",textProvider);

        return rule;
    }
1145833
public function process()
    {
        $state = $this->getState();
        $this->pushTrail($this->getRule());

        $className = ucfirst($this->getQtiNature());
        $nsClass = 'qtism\\data\\rules\\' . $className . 'Condition';
        $ruleGetter = "get${className}Rules";
        $statementGetter = "get${className}"; // + 'If'|'ElseIf'|'Else'

        while (count($this->getTrail()) > 0) {

            $rule = $this->popTrail();

            if (get_class($rule) === $nsClass) {

                // Let's try for if.
                $ifStatement = call_user_func(array($rule, $statementGetter . 'If'));
                $ifExpression = $ifStatement->getExpression();
                $exprEngine = new ExpressionEngine($ifExpression, $state);
                $value = $exprEngine->process();

                if ($value !== null && $value->getValue() === true) {
                    // Follow the if.
                    $this->pushTrail(call_user_func(array($ifStatement, $ruleGetter)));
                } else {
                    // Let's try for else ifs.
                    $followElseIf = false;
                    $elseIfStatements = call_user_func(array($rule, $statementGetter . 'ElseIfs'));

                    foreach ($elseIfStatements as $elseIfStatement) {
                        $elseIfExpression = $elseIfStatement->getExpression();
                        $exprEngine->setComponent($elseIfExpression);
                        $value = $exprEngine->process();

                        if ($value !== null && $value->getValue() === true) {
                            // Follow the current else if.
                            $this->pushTrail(call_user_func(array($elseIfStatement, $ruleGetter)));
                            $followElseIf = true;
                            break;
                        }
                    }

                    $elseStatement = call_user_func(array($rule, $statementGetter . 'Else'));

                    if ($followElseIf === false && is_null($elseStatement) === false) {
                        // No else if followed, the last resort is the else.
                        $this->pushTrail(call_user_func(array($elseStatement, $ruleGetter)));
                    }
                }
            } else {
                // $rule is another Rule than OutcomeCondition/ResponseCondition.
                $processor = $this->getRuleProcessorFactory()->createProcessor($rule);
                $processor->setState($state);
                $processor->process();
            }
        }
    }
925179
protected function enumConstraint()
    {
        if (empty($this->enumConstraint)) {
            $this->enumConstraint = $this->table . '_' . $this->getName() . '_enum_' . uniqid();
        }

        return $this->enumConstraint;
    }
306886
void readCheckConstraintCondition(Constraint c) {

        readThis(Tokens.OPENBRACKET);
        startRecording();

        isCheckOrTriggerCondition = true;

        Expression condition = XreadBooleanValueExpression();

        isCheckOrTriggerCondition = false;

        Token[] tokens = getRecordedStatement();

        readThis(Tokens.CLOSEBRACKET);

        c.check          = condition;
        c.checkStatement = Token.getSQL(tokens);
    }
754899
public function guessPatternForConstraint(Constraint $constraint)
    {
        switch (\get_class($constraint)) {
            case 'Symfony\Component\Validator\Constraints\Length':
                if (is_numeric($constraint->min)) {
                    return new ValueGuess(sprintf('.{%s,}', (string) $constraint->min), Guess::LOW_CONFIDENCE);
                }
                break;

            case 'Symfony\Component\Validator\Constraints\Regex':
                $htmlPattern = $constraint->getHtmlPattern();

                if (null !== $htmlPattern) {
                    return new ValueGuess($htmlPattern, Guess::HIGH_CONFIDENCE);
                }
                break;

            case 'Symfony\Component\Validator\Constraints\Range':
                if (is_numeric($constraint->min)) {
                    return new ValueGuess(sprintf('.{%s,}', \strlen((string) $constraint->min)), Guess::LOW_CONFIDENCE);
                }
                break;

            case 'Symfony\Component\Validator\Constraints\Type':
                if (\in_array($constraint->type, ['double', 'float', 'numeric', 'real'])) {
                    return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
                }
                break;
        }
    }
770075
public function validate($data, Constraint $constraint)
    {
        if (!$data instanceof $this->dataClass) {
            $class = \get_class($data);
            throw new \UnexpectedValueException("Can't validate data of class {$class}");
        }
        $context = $this->context; // VERY IMPORTANT ! context will be lost otherwise
        foreach ($data->getFamily()->getAttributes() as $attribute) {
            if ($attribute->isRequired() && $data->isEmpty($attribute)) {
                $this->buildAttributeViolation(
                    $data,
                    $context,
                    $attribute,
                    'required',
                    $data->get($attribute->getCode())
                );
            }
            if ($attribute->isUnique()) {
                $this->checkUnique($context, $attribute, $data);
            }

            if ($attribute->getOption('allowed_families')) {
                $this->validateFamilies($context, $attribute, $data);
            }

            if (\count($attribute->getValidationRules())) {
                $this->validateRules($context, $attribute, $data);
            }
        }
    }
1182152
private void processConstraintData() throws IOException
   {
      ConstraintFactory factory = new ConstraintFactory();
      factory.process(m_projectDir, m_file, m_inputStreamFactory);
   }
637065
public function addConstraint(Constraint $constraint) : void
    {
        $constraint->setValidator($this);
        array_push($this->constraints, $constraint);
    }
888077
public function addConstraints()
    {
        if (static::$constraints) {
            $foreignKey = $this->getForeignKeyName();
            $parentKeyValue = $this->getParentKey();

            //If the foreign key is an array (multi-column relationship), we adjust the query.
            if (is_array($this->foreignKey)) {
                foreach ($this->foreignKey as $index => $key) {
                    list(, $key) = explode('.', $key);
                    $fullKey = $this->getRelated()
                            ->getTable().'.'.$key;
                    $this->query->where($fullKey, '=', $parentKeyValue[$index]);
                    $this->query->whereNotNull($fullKey);
                }
            } else {
                $fullKey = $this->getRelated()
                        ->getTable().'.'.$foreignKey;
                $this->query->where($fullKey, '=', $parentKeyValue);
                $this->query->whereNotNull($fullKey);
            }
        }
    }
1136245
private void positionalConstraints(PatternDescrBuilder<?> pattern) throws RecognitionException {
        constraint(pattern,
                true,
                "");
        if (state.failed)
            return;

        while (input.LA(1) == DRL6Lexer.COMMA) {
            match(input,
                    DRL6Lexer.COMMA,
                    null,
                    null,
                    DroolsEditorType.SYMBOL);
            if (state.failed)
                return;

            constraint(pattern,
                    true,
                    "");
            if (state.failed)
                return;
        }

        match(input,
                DRL6Lexer.SEMICOLON,
                null,
                null,
                DroolsEditorType.SYMBOL);
        if (state.failed)
            return;
    }
1022925
public function validate($value, Constraint $constraint)
    {
        $object = $this->context->getObject();
        $name = null;
        if (is_object($object)) {
            if (method_exists($object, 'getConfig'))
                $name = $object->getConfig()->getName();
            if (! $name && method_exists($object, '__toString'))
                $name = $object->__toString();
            if (! $name && method_exists($object, 'getName'))
                $name = $object->getName();
            if (! $name)
                $name = get_class($object);
        } else
            $name = strval($object);
        $this->context->buildViolation($constraint->message)
            ->setParameter('%{name}', $name)
            ->addViolation();
    }