{@inheritdoc}
@throws InvalidArgumentException
437413
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $middleware = array_shift($this->middleware);

        // Use default callable if there is no middleware.
        if ($middleware === null) {
            return \call_user_func($this->handler, $request);
        }

        if ($middleware instanceof MiddlewareInterface) {
            return $middleware->process($request, clone $this);
        }

        if (null === $this->container || !$this->container->has($middleware)) {
            throw new InvalidArgumentException(
                sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class),
                $middleware
            );
        }

        array_unshift($this->middleware, $this->container->get($middleware));

        return $this->handle($request);
    }
1251428
public function alias(string $alias, string $abstract): void
    {
        if (\array_key_exists($alias, $this->values) || isset($this->factory[$alias])) {
            throw new InvalidArgumentException("Already defined in container: $alias");
        }

        if ($alias === $abstract) {
            throw new InvalidArgumentException('Alias cannot be the same as the original name');
        }

        $this->alias[$alias] = $abstract;

        if (!isset($this->abstractAlias[$abstract])) {
            $this->abstractAlias[$abstract] = [];
        }

        $this->abstractAlias[$abstract][] = $alias;
    }
1230607
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $sourceArg = realpath($input->getArgument('source'));
        $ruleSetArg = realpath($input->getArgument('ruleset'));

        if (false === $sourceArg || false === $ruleSetArg) {
            throw new \InvalidArgumentException(
                sprintf(
                    '%s argument is invalid: "%s" is not a path.',
                    $sourceArg ? 'Rule set' : 'Source directory',
                    $sourceArg ? $input->getArgument('ruleset') : $input->getArgument('source')
                )
            );
        }

        $config = new Configuration(
            $input->getArgument('ruleset'),
            $input->getOption('container-cache'),
            $input->getOption('no-cache'),
            $input->getOption('cache-dir'),
            $input->getOption('filter-methods'),
            $input->getOption('fail'),
            $input->getOption('verbose'),
            $input->getOption('log-html'),
            $input->getOption('output')
        );

        $factory = new DetectorFactory();
        $detector = $factory->create($config, $output);
        $violations = $detector->checkForDeprecations($sourceArg, $ruleSetArg);

        if ($config->failOnDeprecation() && !empty($violations)) {
            return 1;
        }

        return 0;
    }
1139552
public function validate($value): void
    {
        if (!$this->type->accepts($value)) {
            throw new InvalidArgument((string) $this->name);
        }
    }
1321986
public function parameter($key, $value = NULL)
	{
		if (func_num_args() === 1)
		{
			if ( ! array_key_exists($key, $this->_parameters))
			{
				throw new \InvalidArgumentException('Parameter not set: '.$key);
			}
			return $this->_parameters[$key];
		}
		$this->_parameters[$key] = $value;
		return $this;
	}
248946
public function isValid($value)
    {
        if ( ! array_key_exists('fields', $this->getOptions())) {

            throw new \InvalidArgumentException(
                'Required option "property" not set for NoOtherObjectExists Validator.'
            );
        }

        if ( ! array_key_exists('class', $this->getOptions())) {

            throw new \InvalidArgumentException(
                'Required option "class" not set for NoOtherObjectExists Validator.'
            );
        }

        if ( ! array_key_exists('comparison_object', $this->getOptions())) {

            throw new \InvalidArgumentException(
                'Required option "comparison_object" not set for NoOtherObjectExists Validator.'
            );
        }

        if ( ! array_key_exists('identifier', $this->getOption('comparison_object'))) {

            throw new \InvalidArgumentException(
                'Required option "identifier" not set for NoOtherObjectExists Validator "comparison_object".'
            );
        }

        if ( ! array_key_exists('id', $this->getOption('comparison_object'))) {

            throw new \InvalidArgumentException(
                'Required option "id" not set for NoOtherObjectExists Validator "comparison_object".'
            );
        }

        $propertyName = $this->getOption('fields');
        $propertyClass = $this->getOption('class');

        $getterMethod = 'get' . ucfirst($propertyName);
        $cleanedValue = $this->cleanSearchValue($value);

        $comparisonObjectProperties = $this->getOption('comparison_object');
        $getIdentifier = 'get' . ucfirst($comparisonObjectProperties['identifier']);

        /** @var \object $comparisonObject */
        $comparisonObject = $this->objectRepository->findOneBy(
            [
                $comparisonObjectProperties['identifier'] => $comparisonObjectProperties['id'],
            ]
        );

        if ( ! method_exists($comparisonObject, $getterMethod)) {

            throw new \Exception(sprintf('Method %s() doesn\'t exist in class %s!', $getterMethod, $propertyClass));
        }

        $matches = $this->objectRepository->findBy($cleanedValue);
        if ($matches) {
            foreach ($matches as $index => $match) {
                // Check if the match has the same identifier as the object being edited. If it does continue, this is allowed.
                if (is_object($match)
                    && $match instanceof $propertyClass
                    && $match->$getIdentifier() === $comparisonObject->$getIdentifier()
                ) {

                    continue;
                }

                $this->error(self::ERROR_OBJECT_FOUND, $value);

                return false;
            }
        }

        return true;
    }
1295270
public function resolve($key) {
        if (!array_key_exists($key, $this->bindings)) {
            throw new InvalidArgumentException("{$key} is not bound.");
        }

        $binding = $this->bindings[$key];
        $value = $binding['value'];

        // singleton
        if ($value instanceof Closure) {
            return $value($this);
        }

        // anonymous object
        if (is_null($value) && class_exists('\\' . $key)) {
            return $this->make($key);
        }

        // labeled object
        if (is_string($value) && class_exists('\\' . $value)) {
            return $this->make($value);
        }

        return $value;
    }
131123
public function setField(string $field) : void
    {
        $field = trim($field);
        if (empty($field)) {
            throw new InvalidArgumentException("Field is empty");
        }

        $this->field = $field;
    }
1020265
public function get($propertyName, $funcName, array $arguments = [], array &$errorValues = [], array &$errors)
    {
        if (false === \array_key_exists($funcName, $this->functionMap)) {
            throw new \InvalidArgumentException(
                \sprintf('Validator key \'%s\' not found', $funcName)
            );
        }

        $function = $this->functionMap[$funcName];
        $class    = \explode("::", $function);

        try {
            $result = \call_user_func_array([$class[0], $class[1]], $arguments);

            if (false === $result) {
                $funcName = $this->funcNameToUnderscore($funcName);
                if (false === \array_key_exists($funcName, $errors)) {
                    throw new \InvalidArgumentException(
                        \sprintf('Validator key \'%s\' not found in error file', $funcName)
                    );
                }

                if (\strlen($errors[$funcName]) > 0) {
                    $this->validator->setError(
                        $this->buildErrorMessage($errorValues, $errors, $funcName, $propertyName),
                        $funcName
                    );
                }
            }
        } catch (FileUploadException $e) {
            $lowerCaseFuncName = $this->funcNameToUnderscore($e->getMessage());
            $this->validator->setError(
                $this->buildErrorMessage($errorValues, $errors, $e->getMessage(), $propertyName),
                $lowerCaseFuncName
            );

            $result = false;
        }

        return $result;
    }
275265
public function validate(...$args)
    {
        foreach ($args as $key) {
            $value = $this->getParameter($key);
            if (!isset($value)) {
                throw new InvalidRequestException("The $key parameter is required");
            }
        }
    }
536131
public function offsetSet($offset, $value): void
    {
        if ($this->isValidEntity($value)) {
            if (is_null($offset) || mb_strlen($offset) == 0) {
                $this->list[] = $value;
            } else {
                $this->list[$offset] = $value;
            }
        } else {
            throw new \InvalidArgumentException(sprintf('This collection does\'t accept this entity "%s"', gettype($value)));
        }
    }
1019510
public function setConst(string $const): void
	{
		if (!$this->locale) {
			throw new InvalidArgumentException('Locale must be set before calling setConst');
		}
		if (Strings::match($const, '/[^A-Za-z0-9_]/')) {
			throw new InvalidArgumentException('Constant contains invalid characters');
		}

		/* @var $repository ContentRepository */
		$repository = $this->getRepository();
		$content = $repository->getByConst($const, $this->locale->name);
		if ($content !== null && $content !== $this) {
			throw new UniqueConstraintViolationException("Content with '$const' exists");
		}
		$this->const = $const;
	}
318967
public function getOptionForValue($value) : IFieldOption
    {
        if ($this->specificFieldOptionLoader) {
            $fieldOption = call_user_func($this->specificFieldOptionLoader, $value);

            if (!$fieldOption) {
                throw InvalidArgumentException::format('Invalid option supplied to %s: %s', __METHOD__, $value);
            }

            return $fieldOption;
        }

        return (new ArrayFieldOptions(call_user_func($this->fieldOptionsLoader)))->getOptionForValue($value);
    }
876646
private function resolveParameters()
    {
        // Parameters need special handling when adding
        foreach ($this->config['parameters'] as $name => $param) {
            if (!is_array($param)) {
                throw new \InvalidArgumentException(
                    "Parameters must be arrays, {$this->config['name']}.$name is ".gettype($param)
                );
            }
            $param['name'] = $name;
            $this->parameters[$name] = new Parameter(
                $param,
                ['description' => $this->description]
            );
        }

        if ($this->config['additionalParameters']) {
            if (is_array($this->config['additionalParameters'])) {
                $this->additionalParameters = new Parameter(
                    $this->config['additionalParameters'],
                    ['description' => $this->description]
                );
            } else {
                $this->additionalParameters = $this->config['additionalParameters'];
            }
        }
    }
708702
public function init( $config = NULL )
    {
        parent::init( $config );
        
        if ( !isset( $config[ 'migration_path' ] ) )
        {
            throw new \InvalidArgumentException( 'Missing migration_path parameter' );
        }
        
        foreach ( $config as $key => $value )
        {
            switch( $key )
            {
                case 'migration_path':
                    $this->migrationPath = $value;
                    break;
                
                case 'migration_namespace':
                    $this->migrationNamespace = $value;
                    break;
                
                case 'namespaces':
                    $this->namespaces = $value;
                    break;
                
                case 'class_prefix':
                    $this->classPrefix = $value;
                    break;
                
                case 'migration_table':
                    $this->migrationTable = $value;
                    break;
                
                case 'class_name_style':
                    $this->migrationClassStyle = $value;
                    break;
                
                case 'overwrite':
                    $this->overwrite = $value;
                    break;
                
                case 'levels':
                    $this->levels = $value;
                    break;
                
                case 'name':
                    $this->migrationClass = $value;
                    break;
                
                case 'verbose':
                    $this->verbose = $value === 'true' ? TRUE : FALSE;
                    break;
                
                default:
                    // Do nothing
                    break;
            }
        }
        
        $this->doAction( self::ON_INIT_ACTION );
    }
1002579
public function create( $username, $password, $email = null ) {
		if ( !is_string( $username ) ) {
			throw new InvalidArgumentException( '$username should be a string' );
		}
		if ( !is_string( $password ) ) {
			throw new InvalidArgumentException( '$password should be a string' );
		}
		if ( !is_string( $email ) && !is_null( $email ) ) {
			throw new InvalidArgumentException( '$email should be a string or null' );
		}

		$params = [
			'createreturnurl' => $this->api->getApiUrl(),
			'createtoken' => $this->api->getToken( 'createaccount' ),
			'username' => $username,
			'password' => $password,
			'retype' => $password,
		];

		if ( !is_null( $email ) ) {
			$params['email'] = $email;
		}

		try {
			$result = $this->api->postRequest( new SimpleRequest( 'createaccount', $params ) );
			return $result['createaccount']['status'] === 'PASS';
		} catch ( UsageException $exception ) {
			// If the above request failed, try again in the old way.
			if ( $exception->getApiCode() === 'noname' ) {
				return $this->createPreOneTwentySeven( $params );
			}
			throw $exception;
		}
	}
570888
public function setOptions ($options = array())
	{
		// make sure we've got an array for $this->options (could be null)
		if (!is_array($this->options))
		{
			$this->options = array();
		}
		
		// make sure we've gotten a proper argument
		if (!is_array($options))
		{
			throw new InvalidArgumentException ('setOptions requires an array');
		}
		
		// we've yet to init the default options, so create them here
		if (sizeof($this->options) == 0)
		{
			$defaultOptions = array 
			(
				'resizeUp'				=> false,
				'jpegQuality'			=> 100,
				'correctPermissions'	=> false,
				'preserveAlpha'			=> true,
				'alphaMaskColor'		=> array (255, 255, 255),
				'preserveTransparency'	=> true,
				'transparencyMaskColor'	=> array (0, 0, 0)
			);
		}
		// otherwise, let's use what we've got already
		else
		{
			$defaultOptions = $this->options;
		}
		
		$this->options = array_merge($defaultOptions, $options);
	}