@param string $classMethod
@param array  $arguments
@param array  $errorMessageValues
@param bool   $fetchValidatorErrors

@return $this
193466
protected function addCondition(
        $classMethod,
        array $arguments = [],
        array $errorMessageValues = [],
        $fetchValidatorErrors = false
    ) {
        $classMethod = \explode("\\", $classMethod);
        $classMethod = \array_pop($classMethod);

        $this->conditions[$classMethod] = [
            'key'          => $classMethod,
            'arguments'    => $arguments,
            'values'       => $errorMessageValues,
            'is_validator' => $fetchValidatorErrors,
        ];

        return $this;
    }
44337
@FFDCIgnore(value = { SecurityException.class, IllegalAccessException.class, IllegalArgumentException.class, InvocationTargetException.class })
    private void callValidationMethod(String methodName, Object[] paramValues, Object theProvider) {
        if (theProvider == null) {
            return;
        }

        Method m = cxfBeanValidationProviderMethodsMap.get(methodName);

        if (m == null) {
            return;
        }

        try {
            m.invoke(theProvider, paramValues);
        } catch (SecurityException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Can't access the method \"" + m.getName() + "\" due to security issue." + e.getMessage());
            }
        } catch (IllegalAccessException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Can't access the method \"" + m.getName() + "\"." + e.getMessage());
            }
        } catch (IllegalArgumentException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Illegal argument to the method \"" + m.getName() + "\"." + e.getMessage());
            }
        } catch (InvocationTargetException e) {

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Invocation of the method \"" + m.getName() + "\" fails" + e.getMessage());
            }

            /**
             * throw the javax.validation.ValidationException to keep the same behavior as CXF expected
             */
            Throwable validationException = e.getTargetException();
            if (null != validationException && validationException instanceof RuntimeException) {
                throw (RuntimeException) validationException;
            }

        }
    }
386304
public function validateClassMethod(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
    {
        $methodReflectionResult = $this->validateReflectionMethod($coverMapping->getClassFQN(), $coverMapping->getMethod());
        if ($methodReflectionResult instanceof CoverFishMessageError) {
            $coverFishResult = $this->setValidationError(
                $coverFishResult,
                $methodReflectionResult->getMessageCode()
            );
        }

        return $coverFishResult;
    }
543733
final protected function throwIfInvalidAnnotation(string $classWithAnnotation, string $annotation, string $expectedClassName, string $actualClassName): void
    {
        if (!is_a($actualClassName, $expectedClassName, true)) {
            throw new Exception('On class `' . $classWithAnnotation . '` the annotation `@API\\' . $annotation . '` expects a FQCN implementing `' . $expectedClassName . '`, but instead got: ' . $actualClassName);
        }
    }
1005094
private function validate(MethodInvocation $invocation, \ReflectionMethod $onValidate, \ReflectionMethod $onFailure = null)
    {
        $validation = $onValidate->invokeArgs($invocation->getThis(), (array) $invocation->getArguments());
        if ($validation instanceof Validation && $validation->getMessages()) {
            /* @var $validation Validation */
            $validation->setInvocation($invocation);
            $failure = $this->getFailure($invocation, $validation, $onFailure);
            if ($failure instanceof \Exception) {
                throw $failure;
            }

            return [false, $failure];
        }

        return [true, null];
    }
34202
protected function _validateArguments($methodName, $args) {
        if (!array_key_exists($methodName, $this->_allowedArguments)
            || $this->_allowedArguments[$methodName] === '*'
        ) {
            return true;
        }

        $unknownArgs = array_diff(array_keys($args), $this->_allowedArguments[$methodName]);
        if (!count($unknownArgs)) {
            return true;
        }
        // Report the first erroneous argument
        $errorStr = current($unknownArgs);
        // Show the value of the argument if the index is numeric
        if (is_numeric($errorStr)) {
            $errorStr = $args[$unknownArgs[0]];
        }
        Garp_Cli::errorOut('Unexpected argument ' . $errorStr);
        return false;
    }
496112
private function throwExceptionIfErrors(ConstraintViolationListInterface $errors): void
    {
        if (0 === $errors->count()) {
            return;
        }
        throw ValidationException::create($errors, $this->dataObject);
    }
165247
protected function callOnceBeforeMethodHooks($classInstance, $method, array $args = [])
    {
        $method = self::getCalledMethod($method);

        $onceBeforeMethodName = 'onceBefore'.ucfirst($method);
        if ( ! isset($this->instanceOnceCalledMethods['before'][$onceBeforeMethodName])) {
            if (isset($this->hooks[$onceBeforeMethodName])) {
                foreach ($this->hooks[$onceBeforeMethodName] as $callable) {
                    try {
                        $return = $this->callCallable($classInstance, $callable, $args, $method, false);
                    } catch (CancelPropagationException $e) {
                        break;
                    }

                    if ($return !== null) {
                        return $return;
                    }
                }

                $this->instanceOnceCalledMethods['before'][$onceBeforeMethodName] = true;
            }
        }

        $return = $this->callGlobalOnceBeforeMethodHooks($classInstance, $method, $onceBeforeMethodName);

        if ($return !== null) {
            return $return;
        }
    }
662630
protected function throwNewInvalidArgumentException ($errorMsg) {
		$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
		$str = '['.$selfClass.'] ' . $errorMsg . ' ('
			. 'form id: `'.$this->id . '`, '
			. 'form type: `'.get_class($this->form).'`'
		.')';
		throw new \InvalidArgumentException($str);
	}
689655
private function validateHttpMethods(array $methods): array
    {
        if (empty($methods)) {
            throw new InvalidArgumentException(
                'HTTP methods argument was empty; must contain at least one method'
            );
        }
        if (false === array_reduce($methods, function ($valid, $method) {
            if (false === $valid) {
                return false;
            }
            if (! is_string($method)) {
                return false;
            }
            //if (! preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) {
            if (! preg_match("/^[!#$%&'*+.^_`|~0-9a-z-]+$/i", $method)) {
                return false;
            }

            return $valid;
        }, true)) {
            throw new InvalidArgumentException('One or more HTTP methods were invalid');
        }

        return array_map('strtoupper', $methods);
    }
1288899
@SuppressWarnings({"ThrowableInstanceNeverThrown"})
    public static void validateIsStatic(Method method, List<Throwable> errors)
    {
        if (!Modifier.isStatic(method.getModifiers()))
        {
            errors.add(new Exception("Method " + method.getName() + "() should be static"));
        }
        if (!Modifier.isPublic(method.getDeclaringClass().getModifiers()))
        {
            errors.add(new Exception("Class " + method.getDeclaringClass().getName() + " should be public"));
        }
    }
1085138
public static function fetchArguments($_class = null, $_method = null, $args = null)
    {
        if (empty($_class) || empty($_method)) {
            return null;
        }
        $args_def = array();
        if (!empty($args)) {
            $analyze = new ReflectionMethod($_class, $_method);
            foreach($analyze->getParameters() as $_param) {
                $arg_index = $_param->getName();
                $args_def[$_param->getPosition()] = isset($args[$arg_index]) ?
                    $args[$arg_index] : ( $_param->isOptional() ? $_param->getDefaultValue() : null );
            }
        }
        return call_user_func_array( array($_class, $_method), $args_def );
    }
674540
public function setError($errorCode = null, $message = null):ErrorResponseBuilder
    {
        $this->errorCode = $errorCode;

        if (is_array($message)) {
            $this->parameters = $message;
        } else {
            $this->message = $message;
        }

        return $this;
    }
308738
protected function resolveArgs($className, $methodName, $errorMessageSuffix = '', $extraMappings = []) {
		$reflectionMethod = $this->getReflectionMethod($className, $methodName);

		if (is_null($reflectionMethod) && $methodName === '__construct') {
			return [];
		}

		$extraMappings = (array)$extraMappings;

		if (isset($this->rules[$className][$methodName])) {
			$extraMappings += $this->rules[$className][$methodName];
		}

		$args = [];

		try {
			foreach ($reflectionMethod->getParameters() as $param) {
				if ($extraMappings) {
					$paramName = $param->getName();

					// Add argument according to parameter name.
					if (array_key_exists($paramName, $extraMappings)) {
						$args[] = $extraMappings[$paramName];
						continue;
					}
				}

				$paramType = $param->getType();

				// Disallow primitive types.
				if ($paramType->isBuiltin()) {
					throw new NotAllowedException("Parameter type \"$paramType\" is not allowed" . $errorMessageSuffix);
				}

				$paramClassName = $param->getClass()->getName();

				// Resolve by class.
				if (array_key_exists($paramClassName, $extraMappings)) {
					if (is_string($extraMappings[$paramClassName])) {
						$args[] = $this->get($extraMappings[$paramClassName]);
					} else {
						$args[] = $extraMappings[$paramClassName];
					}
				} else {
					$args[] = $this->get($paramClassName);
				}
			}
		} catch (ReflectionException $e) {
			throw new NotFoundException("Parameter class $paramType is not found" . $errorMessageSuffix);
		}

		return $args;
	}
1131915
protected <V extends ATSecDBValidator> Set<ATError> createError(V validator, String key, String suffix, String defaultMessagePrefix, Object... arguments ) {
		Set<ATError> errors = new HashSet<>(1);
		if (null != validator) {
			errors.add(new ATError(key, 
					validator.getMessageWithSuffix(suffix, arguments, defaultMessagePrefix + StringUtils.join(arguments, ','))));
		} else if (null != messageSource) {
			errors.add(new ATError(key, 
					messageSource.getMessage(key, null, defaultMessagePrefix, LocaleContextHolder.getLocale())));
		} else {
			errors.add(new ATError(key, defaultMessagePrefix));
		}
		return errors;
	}
604640
public function getValidator($type, array $args = [])
    {
        try {
            $wrapper = $this->wrapperFactory($type, $args, ServiceTypeResolver\ValidatorWrapper::class);
        } catch (\Exception $e) {
            throw new Exception\ErrorCreatingValidatorException($e->getMessage(), $e->getCode(), $e);
        }
        return $wrapper;
    }
820530
protected function callOnceAfterHooks($classInstance, $method, array $args = [])
    {
        $return = $this->callOnceAfterAllHooks($classInstance, $method, $args);

        if ($return !== null) {
            return $return;
        }

        $return = $this->callOnceAfterMethodHooks($classInstance, $method, $args);

        if ($return !== null) {
            return $return;
        }
    }