Run the analysis.

@return object
334428
protected function run()
    {
        $this->version = $this->get(VersionAnalyzer::class);
        try {
            return $this->analyzeExtended();
        } catch (Exception $e) {
            return $this->analyzeSimple($e);
        }
    }
499870
public function run()
    {
        $res1 = $this->gcPersistent();
        $res2 = $this->gcUserLinks();
        $res3 = $this->gcActive();

        return $res1 && $res2 && $res3;
    }
944682
public function run() {
        $results = [
            $this->doDelete(),
            $this->doUpdate(),
            $this->doCreate()
        ];
        return array_search(false, $results, true) === false;
    }
52158
public function run()
    {
        MaterializeAsset::register($this->getView());
        $html[] = $this->renderItems();

        return implode("\n", $html);
    }
1233624
public function run()
    {
        // Run compilation based on class dependencies.
        $this->runCompilationByArrangedPriority();

        // Run remaining components (if any).
        foreach ($this->components as $name => $classes) {
            $this->compileGroupClasses($name, $classes);
        }

        // Append application file to the bottom.
        $original = $this->config->get('compile.files', []);

        foreach ($original as $class) {
            $this->collection['added'][] = $class;
        }

        $this->config->set('compile.files', $this->collection['added']);

        return new Fluent([
            'added'   => $this->collection['added'],
            'missing' => $this->collection['missing'],
        ]);
    }
1042389
public function run()
    {
        $this->container = $this->container ?: new Container;

        try {
            if ($this->isControllerAction()) {
                return $this->runController();
            }

            return $this->runCallable();
        } catch (HttpResponseException $e) {
            return $e->getResponse();
        }
    }
340234
public function run()
    {
        $timer = new Timer;

        $this->logSection("START");
        $this->logger->info("Starting Matomo reports archiving...");

        $numWebsitesScheduled = $this->websites->getNumSites();
        $numWebsitesArchived = 0;

        $cliMulti = $this->makeCliMulti();
        if ($this->maxConcurrentArchivers && $cliMulti->supportsAsync()) {
            $numRunning = 0;
            $processes = Process::getListOfRunningProcesses();
            $instanceId = SettingsPiwik::getPiwikInstanceId();

            foreach ($processes as $process) {
                if (strpos($process, 'console core:archive') !== false &&
                    (!$instanceId
                      || strpos($process, '--matomo-domain=' . $instanceId) !== false
                      || strpos($process, '--matomo-domain="' . $instanceId . '"') !== false
                      || strpos($process, '--matomo-domain=\'' . $instanceId . "'") !== false
                      || strpos($process, '--piwik-domain=' . $instanceId) !== false
                      || strpos($process, '--piwik-domain="' . $instanceId . '"') !== false
                      || strpos($process, '--piwik-domain=\'' . $instanceId . "'") !== false)) {
                    $numRunning++;
                }
            }
            if ($this->maxConcurrentArchivers < $numRunning) {
                $this->logger->info(sprintf("Archiving will stop now because %s archivers are already running and max %s are supposed to run at once.", $numRunning, $this->maxConcurrentArchivers));
                return;
            } else {
                $this->logger->info(sprintf("%s out of %s archivers running currently", $numRunning, $this->maxConcurrentArchivers));
            }
        }

        do {
            if ($this->isMaintenanceModeEnabled()) {
                $this->logger->info("Archiving will stop now because maintenance mode is enabled");
                return;
            }

            $idSite = $this->websites->getNextSiteId();
            $numWebsitesArchived++;

            if (null === $idSite) {
                break;
            }

            if ($numWebsitesArchived > $numWebsitesScheduled) {
                // this is needed because a cron:archive might run for example for 5 hours. Meanwhile 5 other
                // `cron:archive` have been possibly started... this means meanwhile, within the 5 hours, the
                // `list of SharedSiteIds` have been potentially emptied and filled again from the beginning.
                // This means 5 hours later, even though all websites that were originally in the list have been
                // finished by now, the `cron:archive` will stay active and continue processing because the list of
                // siteIds to archive was resetted by another `cron:archive` command. Potentially some `cron:archive`
                // will basically never end because by the time the `cron:archive` finishes, the sharedSideIds have
                // been resettet. This can eventually lead to some random concurrency issues when there are like
                // 40 `core:archive` active at the same time.
                $this->logger->info("Stopping archiving as the initial list of websites has been processed.");
                return;
            }

            flush();
            $requestsBefore = $this->requests;
            if ($idSite <= 0) {
                continue;
            }

            $skipWebsiteForced = in_array($idSite, $this->shouldSkipSpecifiedSites);
            if ($skipWebsiteForced) {
                $this->logger->info("Skipped website id $idSite, found in --skip-idsites ");
                $this->skipped++;
                continue;
            }

            $shouldCheckIfArchivingIsNeeded    = !$this->shouldArchiveSpecifiedSites && !$this->shouldArchiveAllSites && !$this->dateLastForced;
            $hasWebsiteDayFinishedSinceLastRun = in_array($idSite, $this->websiteDayHasFinishedSinceLastRun);
            $isOldReportInvalidatedForWebsite  = $this->isOldReportInvalidatedForWebsite($idSite);

            if ($shouldCheckIfArchivingIsNeeded) {
                // if not specific sites and not all websites should be archived, we check whether we actually have
                // to process the archives for this website (only if there were visits since midnight)
                if (!$hasWebsiteDayFinishedSinceLastRun && !$isOldReportInvalidatedForWebsite) {

                    try {
                        if ($this->isWebsiteUsingTheTracker($idSite)) {

                            if(!$this->hadWebsiteTrafficSinceMidnightInTimezone($idSite)) {
                                $this->logger->info("Skipped website id $idSite as archiving is not needed");

                                $this->skippedDayNoRecentData++;
                                $this->skipped++;
                                continue;
                            }
                        } else {
                           $this->logger->info("- website id $idSite is not using the tracker");
                        }
                    } catch (UnexpectedWebsiteFoundException $e) {
                        $this->logger->info("Skipped website id $idSite, got: UnexpectedWebsiteFoundException");
                        continue;
                    }

                } elseif ($hasWebsiteDayFinishedSinceLastRun) {
                    $this->logger->info("Day has finished for website id $idSite since last run");
                } elseif ($isOldReportInvalidatedForWebsite) {
                    $this->logger->info("Old report was invalidated for website id $idSite");
                }
            }

            /**
             * This event is triggered before the cron archiving process starts archiving data for a single
             * site.
             *
             * @param int $idSite The ID of the site we're archiving data for.
             */
            Piwik::postEvent('CronArchive.archiveSingleSite.start', array($idSite));

            $completed = $this->archiveSingleSite($idSite, $requestsBefore);

            /**
             * This event is triggered immediately after the cron archiving process starts archiving data for a single
             * site.
             *
             * @param int $idSite The ID of the site we're archiving data for.
             */
            Piwik::postEvent('CronArchive.archiveSingleSite.finish', array($idSite, $completed));
        } while (!empty($idSite));

        $this->logger->info("Done archiving!");

        $this->logSection("SUMMARY");
        $this->logger->info("Total visits for today across archived websites: " . $this->visitsToday);

        $totalWebsites = count($this->allWebsites);
        $this->skipped = $totalWebsites - $this->websitesWithVisitsSinceLastRun;
        $this->logger->info("Archived today's reports for {$this->websitesWithVisitsSinceLastRun} websites");
        $this->logger->info("Archived week/month/year for {$this->archivedPeriodsArchivesWebsite} websites");
        $this->logger->info("Skipped {$this->skipped} websites");
        $this->logger->info("- {$this->skippedDayNoRecentData} skipped because no new visit since the last script execution");
        $this->logger->info("- {$this->skippedDayArchivesWebsites} skipped because existing daily reports are less than {$this->todayArchiveTimeToLive} seconds old");
        $this->logger->info("- {$this->skippedPeriodsArchivesWebsite} skipped because existing week/month/year periods reports are less than {$this->processPeriodsMaximumEverySeconds} seconds old");

        if($this->skippedPeriodsNoDataInPeriod) {
            $this->logger->info("- {$this->skippedPeriodsNoDataInPeriod} skipped periods archiving because no visit in recent days");
        }

        if($this->skippedDayOnApiError) {
            $this->logger->info("- {$this->skippedDayOnApiError} skipped because got an error while querying reporting API");
        }
        $this->logger->info("Total API requests: {$this->requests}");

        //DONE: done/total, visits, wtoday, wperiods, reqs, time, errors[count]: first eg.
        $percent = $this->websites->getNumSites() == 0
            ? ""
            : " " . round($this->processed * 100 / $this->websites->getNumSites(), 0) . "%";
        $this->logger->info("done: " .
            $this->processed . "/" . $this->websites->getNumSites() . "" . $percent . ", " .
            $this->visitsToday . " vtoday, $this->websitesWithVisitsSinceLastRun wtoday, {$this->archivedPeriodsArchivesWebsite} wperiods, " .
            $this->requests . " req, " . round($timer->getTimeMs()) . " ms, " .
            (empty($this->errors)
                ? self::NO_ERROR
                : (count($this->errors) . " errors."))
        );

        $this->logger->info($timer->__toString());
    }
64193
public function run() {

        foreach ( $this->requests as $request ) {

            if ( isset($request['ERROR_CODE']) && isset($request['ERROR_MESSAGE']) ) {

                $this->logger->warning("Invalid request ".$request['ID']);

                $result = self::packJsonError($request['ERROR_CODE'], $request['ERROR_MESSAGE'], $request['ID']);

                if ( !is_null($result) ) $this->results[] = $result;

            } else {

                try {

                    $this->logger->debug("Serving request ".$request['METHOD']."(".$request['ID'].")");

                    $response = $this->runSingleRequest($request['METHOD'], $request['PARAMETERS']);

                    $result = self::packJsonSuccess($response, $request['ID']);

                } catch (RpcException $re) {

                    $this->logger->warning("Error handling request ".$request['ID'].": ".$re->getMessage());

                    $result = self::packJsonError($re->getCode(), $re->getMessage(), $request['ID']);

                } catch (Exception $e) {

                    $this->logger->error($e->getMessage());

                    throw $e;

                }

                if ( !is_null($result) ) $this->results[] = $result;

            }


        }

        if ( empty($this->results) ) {

            return null;

        } else if ( $this->is_batch_request ) {

            return $this->results;

        } else {

            return $this->results[0];

        }

    }
15217
public function run()
    {
        if ($this->driver === null || (is_array($this->driver) && !isset($this->driver['__class']))) {
            $this->driver['__class'] = GdDriver::class;
        }

        $this->driver = $this->app->ensureObject($this->driver, DriverInterface::class);

        if ($this->app->request->getQueryParam(self::REFRESH_GET_VAR) !== null) {
            // AJAX request for regenerating code
            $code = $this->getVerifyCode(true);
            $this->app->response->format = Response::FORMAT_JSON;
            return [
                'hash1' => $this->generateValidationHash($code),
                'hash2' => $this->generateValidationHash(strtolower($code)),
                // we add a random 'v' parameter so that FireFox can refresh the image
                // when src attribute of image tag is changed
                'url' => Url::to([$this->id, 'v' => uniqid()]),
            ];
        }

        $this->setHttpHeaders();
        $this->app->response->format = Response::FORMAT_RAW;

        return $this->driver->renderImage($this->getVerifyCode());
    }
108358
public function run()
    {
        $ch = curl_init();

        $query = '';
        if (!empty($this->parameters)) {
            $query = '?' . http_build_query ($this->parameters);
        }
        $this->query = $this->url . $query;
        if ($this->method == "GET") {
            curl_setopt($ch, CURLOPT_URL, $this->url . $query);
        } else {
            curl_setopt($ch, CURLOPT_URL, $this->url);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
        }

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        foreach ($this->options as $key => $value)
        {
            curl_setopt($ch, $key, $value);
        }

        $this->response = curl_exec($ch);
        $this->curlInfo = curl_getinfo($ch);
        $this->curlError = curl_error($ch);
    }
123245
public function run()
    {
        if (! $this->runPreSearch()) {
            return $this->value;
        }

        $decoded = json_decode($this->value, 1);
        $result  = (json_last_error() == JSON_ERROR_NONE) && is_array($decoded);
        if ($result) {
            /* decoded is array */
            if (is_array($decoded)) {
                $arrayValue = '';
                array_walk_recursive($decoded, function ($value, $key) use (&$arrayValue) {
                    $arrayValue .= $key.' '.$value;
                });
                $this->value = $arrayValue;
            }
        }

        return $this->value;
    }
219004
public function run() {
        $this->executor->setActual($this->actual);
        $this->executor->setPeticion($this->peticion);
        $this->executor->setCallback($this->configure->getConfig());
        $this->executor->exist();
        $this->executor->compare();
        $this->executor->execute();

	return $this;
    }
1085856
public function execute() {
        global $OUTPUT, $PAGE;

        $models = \core_analytics\manager::get_all_models(true);
        if (!$models) {
            mtrace(get_string('errornoenabledmodels', 'tool_analytics'));
            return;
        }

        foreach ($models as $model) {

            if ($model->is_static()) {
                // Skip models based on assumptions.
                continue;
            }

            if (!$model->get_time_splitting()) {
                // Can not train if there is no time splitting method selected.
                continue;
            }

            $result = $model->train();

            // Reset the page as some indicators may call external functions that overwrite the page context.
            \tool_analytics\output\helper::reset_page();

            if ($result) {
                echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_name()));

                $renderer = $PAGE->get_renderer('tool_analytics');
                echo $renderer->render_get_predictions_results($result, $model->get_analyser()->get_logs());
            }
        }
    }
196321
public function run()
    {
        $request = $this->container->get(self::REQUEST);

        $response = $this->handle($request);

        return $this->emit($response)->stream();
    }
1168143
public function run()
    {
        if ($this->useSessionFlash)  {
            return $this->getView()->registerJs($this->sessionFlashJs);
        }

        $this->getView()->registerJs($this->getJs(
            $this->type,
            $this->content,
            $this->title
        ));

    }
451970
public function run()
    {
        $model = new Measure;
        return $this->controller->render(
            'index',
            [
                'dataProvider' => $model->search(\Yii::$app->request->get()),
                'model' => $model,
            ]
        );
    }
856110
public function run() {

		$post = yii::$app->request->post();

		if( isset( $this->model ) && isset( $post[ 'itemId' ] ) ) {

			$mappingType = isset( $post[ 'ctype' ] ) ? $post[ 'ctype' ] : null;

			$modelMapper = $this->modelMapperService->activateByModelId( $this->model->id, $this->parentType, $post[ 'itemId' ], $mappingType );

			$data = [ 'cid' => $modelMapper->id, 'name' => $modelMapper->model->name ];

			// Trigger Ajax Success
			return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}