public function applyConstraints($instance, stdClass $schema, Context $context)
    {
        $cacheKey = gettype($instance).spl_object_hash($schema);
        $constraints = & $this->constraintsCache[$cacheKey];

        if ($constraints === null) {
            $version = $this->getVersion($schema);
            $instanceType = Types::getPrimitiveTypeOf($instance);
            $constraints = $this->registry->getConstraintsForType($version, $instanceType);
            $constraints = $this->filterConstraintsForSchema($constraints, $schema);
        }

        foreach ($constraints as $constraint) {
            $constraint->apply($instance, $schema, $context, $this);
        }
    }
public function applyConstraints($instance, stdClass $schema, Context $context)
    {
        $cacheKey = gettype($instance).spl_object_hash($schema);
        $constraints = & $this->constraintsCache[$cacheKey];

        if ($constraints === null) {
            $version = $this->getVersion($schema);
            $instanceType = Types::getPrimitiveTypeOf($instance);
            $constraints = $this->registry->getConstraintsForType($version, $instanceType);
            $constraints = $this->filterConstraintsForSchema($constraints, $schema);
        }

        foreach ($constraints as $constraint) {
            $constraint->apply($instance, $schema, $context, $this);
        }
    }
public function applyConstraints ( $ instance , stdClass $ schema , Context $ context ) { $ cacheKey = gettype ( $ instance ) . spl_object_hash ( $ schema ) ; $ constraints = & $ this -> constraintsCache [ $ cacheKey ] ; if ( $ constraints === null ) { $ version = $ this -> getVersion ( $ schema ) ; $ instanceType = Types :: getPrimitiveTypeOf ( $ instance ) ; $ constraints = $ this -> registry -> getConstraintsForType ( $ version , $ instanceType ) ; $ constraints = $ this -> filterConstraintsForSchema ( $ constraints , $ schema ) ; } foreach ( $ constraints as $ constraint ) { $ constraint -> apply ( $ instance , $ schema , $ context , $ this ) ; } }
Validates an instance against a given schema, populating a context
with encountered violations.

@param mixed    $instance
@param stdClass $schema
@param Context  $context
Validates an instance against a given schema populating a context with encountered violations .