{@inheritDoc}

@SuppressWarnings(PHPMD.CyclomaticComplexity)
@SuppressWarnings(PHPMD.NPathComplexity)
772518
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $error = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;

        if (!($input->getOption('php-files')
            || $input->getOption('composer')
            || $input->getOption('bower')
            || $input->getOption('packages'))
        ) {
            $error->writeln('<error>You must select at least one validation to run!</error>');
            $error->writeln('check-author.php [--php-files] [--composer] [--bower] [--packages]');

            return 1;
        }

        $this->enableDeprecatedNoProgressBar($input);

        $config = new Config();

        if (!$input->getOption('do-not-ignore-well-known-bots')) {
            $configFile = \dirname(\dirname(__DIR__))
                . DIRECTORY_SEPARATOR . 'defaults'
                . DIRECTORY_SEPARATOR . 'ignore-well-known-bots.yml';
            $config->addFromYml($configFile);
        }

        $configFile = $input->getOption('config');
        if (\is_file($configFile)) {
            $config->addFromYml($configFile);
        }

        $config
            ->ignoreAuthors($input->getOption('ignore'))
            ->excludePaths($input->getOption('exclude'))
            ->includePaths(
                \array_filter(\array_map('realpath', $input->getArgument('include')))
            );

        $paths = \array_values($config->getIncludedPaths());
        $git   = new GitRepository($this->determineGitRoot($paths[0]));
        if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) {
            $git->getConfig()->setLogger(
                new ConsoleLogger($output)
            );
        }

        $cacheDir = \rtrim((($tmpDir = ('\\' === PATH_SEPARATOR
            ? \getenv('HOMEDRIVE') . \getenv('HOMEPATH')
            : \getenv('HOME'))) ? $tmpDir : \sys_get_temp_dir()), '\\/');
        if ($input->getOption('cache-dir')) {
            $cacheDir = \rtrim($input->getOption('cache-dir'), '/');
        }
        $cacheDir .= '/.cache/phpcq-author-validation';

        if ($output->isVerbose()) {
            $error->writeln(\sprintf('<info>The folder "%s" is used as cache directory.</info>', $cacheDir));
        }

        $cachePool = new DoctrineCachePool(
            $input->getOption('no-cache')
                ? new VoidCache()
                : new FilesystemCache($cacheDir)
        );

        $diff         = $input->getOption('diff');
        $extractors   = $this->createSourceExtractors($input, $error, $config, $cachePool);
        $gitExtractor = $this->createGitAuthorExtractor($input->getOption('scope'), $config, $error, $cachePool, $git);
        $progressBar  = !$output->isQuiet() && !$input->getOption('no-progress') && \posix_isatty(STDOUT);
        $comparator   = new AuthorListComparator($config, $error, $progressBar);
        $comparator->shallGeneratePatches($diff);

        $failed = $this->handleExtractors($extractors, $gitExtractor, $comparator);

        if ($failed && $diff) {
            $output->writeln($comparator->getPatchSet());
        }

        return $failed ? 1 : 0;
    }
259315
function with(array $options, $throwException = false)
    {
        foreach ($options as $key => $val) {
            $key = strtolower($key);
            $this->$key = $val;
        }
    }
1281580
public function run(InputInterface $input = null, OutputInterface $output = null)
    {
        if ($input !== null) {
            $in = $input;
        } else {
            $in = $this->getInput();
        }

        return parent::run($in, $output);
    }
1290325
function parse($args = null)
    {
        if ($args === null) {
            $args = array_slice($_SERVER['argv'], 1);
        }

        foreach ($args as $pos => $arg) {
            // reset value
            $value = null;

            if (substr($arg, 0, 1) === '-') {
                if (preg_match('/^(.+)=(.+)$/', $arg, $matches)) {
                    $arg = $matches[1];
                    $value = $matches[2];
                }

                if (!$flag = @$this->flags[$arg]) {
                    throw new ParseException(sprintf('Flag "%s" is not defined.', $arg));
                }

                unset($args[$pos]);

                if ($flag->hasValue) {
                    if (!isset($value)) {
                        $value = $args[$pos + 1];
                        unset($args[$pos + 1]);
                    }
                } else {
                    $value = true;
                }

                if (null !== $flag->callback) {
                    call_user_func_array($flag->callback, array(&$value));
                }

                # Set the reference given as the flag's 'var'.
                $flag->var = $this->parsedFlags[$flag->name] = $value;
            }
        }

        # TODO: Refactor this so this fits into the above foreach
        foreach ($this->flags as $flag) {
            if (!array_key_exists($flag->name, $this->parsedFlags)) {
                $flag->var = $this->parsedFlags[$flag->name] = $flag->defaultValue;
            }
        }

        $this->parsedArgs = $args = array_values($args);

        $pos = 0;

        foreach ($this->args as $arg) {
            if ($arg->required and !isset($args[$pos])) {
                throw new ArgumentException(sprintf(
                    'Missing required argument "%s"', $arg->name
                ));
            }

            if (isset($args[$pos])) {
                if ($arg->vararg) {
                    $value = array_slice($args, $pos);
                    $pos += count($value);
                } else {
                    $value = $args[$pos];
                    $pos++;
                }
            } else {
                $value = $arg->defaultValue;
            }

            $this->parsedNamedArgs[$arg->name] = $value;
        }
    }
25506
function serialize()
	{
		$propvals = array();
		$ro = new ReflectionObject($this);

		foreach ($ro->getProperties() as $rp )
		{
			$propname = $rp->getName();

			if (!in_array($propname,self::$NoCacheProperties))
			{
				if (method_exists($rp,"setAccessible"))
				{
					$rp->setAccessible(true);
					$propvals[$propname] = $rp->getValue($this);
				}
				elseif (!$rp->isPrivate())
				{
					// if < php 5.3 we can't serialize private vars
					$propvals[$propname] = $rp->getValue($this);
				}

			}
		}

		return serialize($propvals);
	}
43589
public function OrderBy($Value = NULL) {
      if ($Value === NULL)
         return $this->_OrderBy;

      if (is_string($Value))
         $Value = array($Value);

      if (is_array($Value)) {
         // Set the order of this object.
         $OrderBy = array();

         foreach($Value as $Part) {
            if (StringEndsWith($Part, ' desc', TRUE))
               $OrderBy[] = array(substr($Part, 0, -5), 'desc');
            elseif (StringEndsWith($Part, ' asc', TRUE))
               $OrderBy[] = array(substr($Part, 0, -4), 'asc');
            else
               $OrderBy[] = array($Part, 'asc');
         }
         $this->_OrderBy = $OrderBy;
      } elseif (is_a($Value, 'Gdn_SQLDriver')) {
         // Set the order of the given sql.
         foreach ($this->_OrderBy as $Parts) {
            $Value->OrderBy($Parts[0], $Parts[1]);
         }
      }
   }
1318578
public function find($id = NULL)
    {
        if ($id !== NULL)
        {
            $data             = $this->getData();
            $this->currentId  = $id;
            $this->currentKey = $this->getRowKey($id);
            foreach ($data[$this->currentKey] as $field => $value)
            {
                $this->setField($field, $value);
            }
        }
        else
        {
            $this->limit(1)->findAll();
            $data = $this->data;
            if (count($data))
            {
                foreach ($data[0] as $field => $value)
                {
                    $this->setField($field, $value);
                }

                $this->currentId  = $this->getField('id');
                $this->currentKey = $this->getRowKey($this->currentId);
            }
        }
        return clone $this;
    }
934636
public function indexBy($list, $property, $meta=null, $allowDupes=null, $ignoreNulls=null)
    {
        $allowDupes  = $allowDupes  !== null ? $allowDupes  : false;
        $ignoreNulls = $ignoreNulls !== null ? $ignoreNulls : true;

        if (!$list) {
            return [];
        }

        if ($meta) {
            $meta = !$meta instanceof Meta ? $this->mapper->getMeta($meta) : $meta;
        }
        else {
            if (!($first = current($list))) {
                throw new \UnexpectedValueException();
            }
            $meta = $this->mapper->getMeta(get_class($first));
        }

        $index = array();

        $props = $meta ? $meta->getProperties() : [];
        foreach ($list as $object) {
            $propDef = !isset($props[$property]) ? null : $props[$property];
            $value = !$propDef || !isset($propDef['getter']) 
                ? $object->{$property} 
                : call_user_func(array($object, $propDef['getter']));

            if ($value === null && $ignoreNulls) {
                continue;
            }
            if (!$allowDupes && isset($index[$value])) {
                throw new \UnexpectedValueException("Duplicate value for property $property");
            }
            $index[$value] = $object;
        }
        return $index;
    }
931568
public function execute()
	{
		$this->connect();

		if (!is_object($this->connection))
		{
			$this->log(
				Log\LogLevel::ERROR,
				'Database query failed (error #{code}): {message}',
				array('code' => $this->errorNum, 'message' => $this->errorMsg)
			);
			throw new \RuntimeException($this->errorMsg, $this->errorNum);
		}

		// Take a local copy so that we don't modify the original query and cause issues later
		$sql = $this->replacePrefix((string) $this->sql);

		if ($this->limit > 0 || $this->offset > 0)
		{
			// @TODO
			$sql .= ' LIMIT ' . $this->offset . ', ' . $this->limit;
		}

		// Increment the query counter.
		$this->count++;

		// If debugging is enabled then let's log the query.
		if ($this->debug)
		{
			// Add the query to the object queue.
			$this->log(
				Log\LogLevel::DEBUG,
				'{sql}',
				array('sql' => $sql, 'category' => 'databasequery', 'trace' => debug_backtrace())
			);
		}

		// Reset the error values.
		$this->errorNum = 0;
		$this->errorMsg = '';

		// Execute the query.
		$this->executed = false;

		if ($this->prepared instanceof \PDOStatement)
		{
			// Bind the variables:
			if ($this->sql instanceof PreparableInterface)
			{
				$bounded =& $this->sql->getBounded();

				foreach ($bounded as $key => $obj)
				{
					$this->prepared->bindParam($key, $obj->value, $obj->dataType, $obj->length, $obj->driverOptions);
				}
			}

			$this->executed = $this->prepared->execute();
		}

		// If an error occurred handle it.
		if (!$this->executed)
		{
			// Get the error number and message before we execute any more queries.
			$errorNum = (int) $this->connection->errorCode();
			$errorMsg = (string) 'SQL: ' . implode(", ", $this->connection->errorInfo());

			// Check if the server was disconnected.
			if (!$this->connected())
			{
				try
				{
					// Attempt to reconnect.
					$this->connection = null;
					$this->connect();
				}
				catch (\RuntimeException $e)
				// If connect fails, ignore that exception and throw the normal exception.
				{
					// Get the error number and message.
					$this->errorNum = (int) $this->connection->errorCode();
					$this->errorMsg = (string) 'SQL: ' . implode(", ", $this->connection->errorInfo());

					// Throw the normal query exception.
					$this->log(
						Log\LogLevel::ERROR,
						'Database query failed (error #{code}): {message}',
						array('code' => $this->errorNum, 'message' => $this->errorMsg)
					);
					throw new \RuntimeException($this->errorMsg, $this->errorNum);
				}

				// Since we were able to reconnect, run the query again.
				return $this->execute();
			}
			else
			// The server was not disconnected.
			{
				// Get the error number and message from before we tried to reconnect.
				$this->errorNum = $errorNum;
				$this->errorMsg = $errorMsg;

				// Throw the normal query exception.
				$this->log(
					Log\LogLevel::ERROR,
					'Database query failed (error #{code}): {message}',
					array('code' => $this->errorNum, 'message' => $this->errorMsg)
				);
				throw new \RuntimeException($this->errorMsg, $this->errorNum);
			}
		}

		return $this->prepared;
	}
1141681
public function when(/* see docblock */)
    {
        $arguments = func_get_args();
        if ($arguments[0] instanceof Antecedent) {
            $antecedent = $arguments[0];
        } elseif ($arguments[0] instanceof PHPUnit_Framework_Constraint) {
            $antecedent = Antecedent\IndependentConstraintsAntecedent::fromAll($arguments);
        } elseif ($arguments[0] instanceof Constraint) {
            $antecedent = Antecedent\IndependentConstraintsAntecedent::fromAll($arguments);
        } elseif ($arguments && count($arguments) == 1) {
            $antecedent = Antecedent\SingleCallbackAntecedent::from($arguments[0]);
        } else {
            throw new \InvalidArgumentException("Invalid call to when(): " . var_export($arguments, true));
        }
        $this->antecedents[] = $antecedent;
        return $this;
    }
624810
public function offsetSet($offset, $value)
    {
        if(is_array($this->obj)){
            $this->obj[$offset] = $value;
        }elseif(self::hasProperty($this->obj, $offset)){
            $this->obj->{$offset} = $value;
        }elseif(method_exists($this->obj, 'set')){
            $this->obj->set($offset, $value);
        }elseif(method_exists($this->obj, $method = 'set'.ucfirst($offset))){
            $this->obj->{$method}($value);
        }else{
            throw new \BadMethodCallException("can not set $offset");
        }
    }
332161
function bindAndExecute() {
		$conn = $this->connection;

		if ($conn === null) {
			throw new RuntimeException('bindAndExecute cannot be called on a QueryStatement without a connection.');
		}
		if ($conn instanceof DBMSSQL && $conn->getDriver() === 'dblib' && function_exists('mb_detect_encoding')) {
			return $conn->query($this->__toString());
		}
		if ($conn instanceof DBSQLite) {
			return $conn->query($this->__toString());
		}

		$string = self::embedIdentifiers($this->getString(), array_values($this->identifiers), $conn);

		$result = $conn->prepare($string);
		foreach ($this->getParams() as $key => $value) {
			$pdo_type = PDO::PARAM_STR;
			if (is_int($value)) {
				$pdo_type = PDO::PARAM_INT;
			} elseif (is_null($value)) {
				$pdo_type = PDO::PARAM_NULL;
			} elseif (is_bool($value)) {
				$value = $value ? 1 : 0;
				$pdo_type = PDO::PARAM_INT;
			}
			$result->bindValue($key + 1, $value, $pdo_type);
		}
		$result->execute();
		return $result;
	}
1226649
public function set($name, $value=null, $locale=null, $hook=true, $change=true, $silentException=false) {
		if(is_string($name))
			$name = strtolower($name);

		#setting multiple properties at once
		if(is_array($name)) {
			$vars = $name;
			$locale = $value;
			foreach($vars as $name=>$value)
				$this->set($name, $value, $locale, $hook);
			return $this;
		}

		#setting a property multiple translations at once
		if(is_array($locale)) {
			foreach($locale as $one)
				$this->set($name, $value[$one], $one, $hook);
			return $this;
		}

		$this->getDefinition()->processPreSet($this, $name, $value, $locale, $hook, $silentException);

		if($this->getDefinition()->hasProperty($name)) {
			if(!$locale)
				$locale = $this->getLocale();

			if($this->getDefinition()->property($name)->get('i18n') && $locale !== $this->getLocale()) {
				if($locale == 'all') {
					foreach($value as $locale => $v) {
						if(isset($this->data['translations'][$locale][$name]) && $v === $this->data['translations'][$locale][$name])
							continue;
						$this->data['translations'][$locale][$name] = $v;
						if($change) {
							if(!isset($this->translationschanged[$locale]))
								$this->translationschanged[$locale] = [];
							$this->translationschanged[$locale][$name] = true;
						}
					}
				}
				else {
					if(isset($this->data['translations'][$locale][$name]) && $value === $this->data['translations'][$locale][$name])
						return $this;
					$this->data['translations'][$locale][$name] = $value;
					if($change) {
						if(!isset($this->translationschanged[$locale]))
							$this->translationschanged[$locale] = [];
						$this->translationschanged[$locale][$name] = true;
					}
				}
			}
			else {
				if(isset($this->data['properties'][$name]) && $value === $this->data['properties'][$name])
					return $this;
				$this->data['properties'][$name] = $value;
				if($change) {
					if($this->getDefinition()->property($name)->get('i18n'))
						$this->translationschanged[$this->getLocale()][$name] = true;
					else
						$this->changed[$name] = true;
				}
			}
		}
		elseif($name !== 'translations' && $name !== 'properties') {
			if(is_array($value)) {
				$coll = new ManyCollection($this, $name);
				$value = $coll->setAll($value);
			}
			$this->data[$name] = $value;
		}

		return $this;
	}
968652
public static function updateOrNull($data = null)
    {
        static $request;
        if (!$request) {
            $request = Di::getDefault()->getShared('request');
        }

        if (!$request->isPost() && !$request->isPut() && !$request->isPatch()) {
            return null;
        }

        $model = new static;

        $pkName = $model->getPrimaryKey();

        $_request = $request->get();

        $instance = static::get(isset($data[$pkName]) ? $data[$pkName] : $request->getId($pkName));

        if ($data === null || !isset($data[0])) {
            foreach ($model->getSafeFields() as $field) {
                if (isset($_request[$field])) {
                    $instance->$field = $_request[$field];
                }
            }
        }

        if ($data) {
            foreach ($data as $k => $v) {
                if (is_int($k)) {
                    $field = $v;
                    if (!isset($_request[$field])) {
                        throw new MissingFieldException($field);
                    }
                    $instance->$field = $_request[$field];
                } else {
                    $instance->$k = $v;
                }
            }
        }

        return $instance->update();
    }
721461
public function fill(array $attributes = [])
    {
        $filtered = [];

        foreach ($attributes as $name => $value) {

            // This is done by the parent
            if (in_array($name, ['name', 'constraints'])) {
                continue;
            }

            if (isset(static::$propertyMap[static::class][$name]) ||
                isset(static::$aliases[static::class][$name])) {
                $filtered[$name] = $value;
                continue;
            }

            if (!$value instanceof XType) {
                throw new UnsupportedParameterException("The value of $name has to be instanceof XType");
            }

            $this->set($name, $value);
        }

        return parent::fill($filtered);
    }
497732
public function resolve(
        ValueInterface $value,
        FixtureInterface $fixture,
        ResolvedFixtureSet $fixtureSet,
        array $scope,
        GenerationContext $context
    ): ResolvedValueWithFixtureSet {
        if (null === $this->argumentResolver) {
            throw ResolverNotFoundExceptionFactory::createUnexpectedCall(__METHOD__);
        }

        $functionCall = $value->getFunctionCall();
        $arguments = $functionCall->getArguments();
        foreach ($arguments as $index => $argument) {
            if ($argument instanceof ValueInterface) {
                $resolvedSet = $this->argumentResolver->resolve($argument, $fixture, $fixtureSet, $scope, $context);

                $arguments[$index] = $resolvedSet->getValue();
                $fixtureSet = $resolvedSet->getSet();
            }
        }

        $context->markAsNeedsCompleteGeneration();
        $fixtureReferenceResult = $this->argumentResolver->resolve($value->getReference(), $fixture, $fixtureSet, $scope, $context);
        $context->unmarkAsNeedsCompleteGeneration();

        /** @var ResolvedFixtureSet $fixtureSet */
        list($instance, $fixtureSet) = [$fixtureReferenceResult->getValue(), $fixtureReferenceResult->getSet()];

        try {
            $resolvedValue = $instance->{$functionCall->getName()}(...$arguments);
        } catch (\Throwable $exception) {
            if (false === method_exists($instance, $functionCall->getName())) {
                throw NoSuchMethodExceptionFactory::createForFixture($fixture, $value);
            }

            throw UnresolvableValueExceptionFactory::create($value, 0, $exception);
        }

        return new ResolvedValueWithFixtureSet(
            $resolvedValue,
            $fixtureSet
        );
    }
2420
public function hydrate($value)
    {
        if ($this->nullable && $value === null) {
            return null;
        }

        $this->hasOneStrategy->setPrototypeStrategy($this->getPrototypeStrategy());
        $return = clone $this->arrayObjectPrototype;
        if (is_array($value) || $value instanceof \Traversable) {
            foreach ($value as $key => $data) {
                $return[$key] = $this->hasOneStrategy->hydrate($data);
            }
        } else {
            throw new Exception\InvalidArgumentException(sprintf(
                'Value must be null (only if nullable option is enabled), or an array, or a Traversable: "%s" given',
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        return $return;
    }