/**
  * {@inheritdoc}
  */
 public function validate(ServiceReference $service, array $arguments)
 {
     $validationResult = array();
     $parameterCount = 0;
     $validatedCount = 0;
     $hasStrictFailure = false;
     foreach ($arguments as $name => $value) {
         if (strpos($name, '__internal__') !== false) {
             continue;
         }
         $constraints = $service->getParameterConstraints($name);
         $validationGroups = $service->getParameterValidationGroups($name);
         $isStrictValidation = $service->isStrictParameterValidation($name);
         if (!empty($constraints)) {
             $violations = $this->validator->validate($value, $constraints, $validationGroups);
             if (count($violations)) {
                 $validationResult[$name] = $violations;
                 if ($isStrictValidation) {
                     $hasStrictFailure = true;
                 }
             }
             $validatedCount++;
         }
         $parameterCount++;
     }
     if ($this->strict && $parameterCount !== $validatedCount) {
         throw new StrictArgumentValidationException();
     }
     if (!empty($validationResult)) {
         throw new ArgumentValidationException(new ArgumentValidationResult($validationResult), $hasStrictFailure);
     }
 }
 /**
  * @param ServiceReference $service
  * @param array            $arguments
  * @return bool
  */
 public function isGranted(ServiceReference $service, array $arguments)
 {
     if ($this->tokenStorage->getToken() === null) {
         return true;
     }
     $authorizationExpression = $service->getAuthorizationExpression();
     if (empty($authorizationExpression)) {
         return true;
     }
     return $this->language->evaluate($authorizationExpression, $this->getVariables($arguments));
 }
 /**
  * @param ServiceReference $service
  * @param string           $name
  * @return DeserializationContext
  */
 protected function createDeserializationContext(ServiceReference $service, $name)
 {
     $context = DeserializationContext::create();
     $groups = $service->getParameterSerializationGroups($name);
     $attributes = $service->getParameterSerializationAttributes($name);
     $version = $service->getParameterSerializationVersion($name);
     if (!empty($groups)) {
         $context->setGroups($groups);
     }
     if (!empty($attributes)) {
         foreach ($attributes as $k => $v) {
             $context->setAttribute($k, $v);
         }
     }
     if ($version !== null) {
         $context->setVersion($version);
         return $context;
     }
     return $context;
 }