protected function runChecks() { $baseConfig = $this->configReader->loadFromFile($this->_getStandardPath($this->context->getConfigName())); $success = true; $checkRunner = new CheckRunner($this->fileSystem, $this->checkRepository, $baseConfig); array_map([$this, '_startReporter'], $this->context->getReporters()); $checkRunner->setObserver(function (File $file, array $checkResults) use(&$success) { $minimumSeverityToFail = $this->context->hasStrictModeEnabled() ? Violation::SEVERITY_IGNORE : Violation::SEVERITY_ERROR; $this->reportCheckResults($this->context->getReporters(), $file, $checkResults); foreach ($checkResults as $checkResult) { if ($checkResult->count() > 0) { $success &= $checkResult->getMaximumViolationSeverity() < $minimumSeverityToFail; } } }); foreach ($this->context->getPathsToCheck() as $path) { $checkRunner->checkPath($path); } array_map([$this, '_finishReporter'], $this->context->getReporters()); $this->environment->setExitCode($success ? 0 : 1); $this->environment->shutdown(); }