Runs the entire 'make' process.

@return int Course id
193106
public function make() {
        global $DB, $CFG;

        raise_memory_limit(MEMORY_EXTRA);

        if ($this->progress && !CLI_SCRIPT) {
            echo html_writer::start_tag('ul');
        }

        $entirestart = microtime(true);

        // Create courses.
        $prevchdir = getcwd();
        chdir($CFG->dirroot);
        $ncourse = self::get_last_testcourse_id();
        foreach (self::$sitecourses as $coursesize => $ncourses) {
            for ($i = 1; $i <= $ncourses[$this->size]; $i++) {
                // Non language-dependant shortname.
                $ncourse++;
                $this->run_create_course(self::SHORTNAMEPREFIX . $ncourse, $coursesize);
            }
        }
        chdir($prevchdir);

        // Store last course id to return it (will be the bigger one).
        $lastcourseid = $DB->get_field('course', 'id', array('shortname' => self::SHORTNAMEPREFIX . $ncourse));

        // Log total time.
        $this->log('sitecompleted', round(microtime(true) - $entirestart, 1));

        if ($this->progress && !CLI_SCRIPT) {
            echo html_writer::end_tag('ul');
        }

        return $lastcourseid;
    }
613356
public function run()
    {
        $error = $this->error;
        $output = $this->output;

        return $this->builder->getProcess()->run(
            function ($type, $buffer) use ($error, $output) {
                if ('err' === $type) {
                    if ($error) {
                        $error($buffer);
                    }
                } elseif ($output) {
                    $output($buffer);
                }
            }
        );
    }
932610
public function run(): int
	{
		$this->handleGlobalOptions();

		if(($command = $this->input->getArgument(1)) === null)
		{
			return $this->displayReactorInfoAndCommandList();
		}

		if($this->commandExists($command) === false)
		{
			return $this->unknownCommand($command);
		}

		if($this->input->getArgument('help', false) !== false)
		{
			return $this->displayCommandHelp($command);
		}

		return $this->dispatch($command);
	}
325145
public function run()
    {
        $db = eZDB::instance();
        if ( $db->isConnected() )
        {
            $this->sessionInit();
        }
        else
        {
            return $this->exitWithInternalError(
                ezpI18n::tr( 'kernel/content/treemenu', 'Database is not connected' )
            );
        }

        $moduleINI = eZINI::instance( 'module.ini' );
        $globalModuleRepositories = $moduleINI->variable( 'ModuleSettings', 'ModuleRepositories' );
        eZModule::setGlobalPathList( $globalModuleRepositories );

        $module = eZModule::exists( 'content' );
        if ( !$module )
        {
            return $this->exitWithInternalError(
                ezpI18n::tr( 'kernel/content/treemenu', '"content" module could not be found.' )
            );
        }

        $function_name = 'treemenu';
        $this->uri->increase();
        $this->uri->increase();

        $currentUser = eZUser::currentUser();
        $siteAccessResult = $currentUser->hasAccessTo( 'user', 'login' );
        $hasAccessToSite = false;
        if ( $siteAccessResult[ 'accessWord' ] == 'limited' )
        {
            $policyChecked = false;
            foreach ( $siteAccessResult['policies'] as $policy )
            {
                if ( isset( $policy['SiteAccess'] ) )
                {
                    $policyChecked = true;
                    $crc32AccessName = eZSys::ezcrc32( $this->access[ 'name' ] );
                    if ( in_array( $crc32AccessName, $policy['SiteAccess'] ) )
                    {
                        $hasAccessToSite = true;
                        break;
                    }
                }
                if ( $hasAccessToSite )
                {
                    break;
                }
            }
            if ( !$policyChecked )
            {
                $hasAccessToSite = true;
            }
        }
        else if ( $siteAccessResult[ 'accessWord' ] == 'yes' )
        {
            $hasAccessToSite = true;
        }

        if ( !$hasAccessToSite )
        {
            return $this->exitWithInternalError(
                ezpI18n::tr( 'kernel/content/treemenu', 'Insufficient permissions to display the treemenu.' ),
                403
            );
        }

        $GLOBALS['eZRequestedModule'] = $module;

        $content = $module->run(
            $function_name,
            $this->uri->elements( false ),
            false,
            array(
                'use-cache-headers' => $this->settings['use-cache-headers']
            )
        );
        $attributes = isset( $content['lastModified'] ) ? array( 'lastModified' => $content['lastModified'] ) : array();
        $this->shutdown();
        return new ezpKernelResult( $content['content'], $attributes );
    }
700535
protected function doExecute()
	{
		$input  = $this->getConsoleInput();
		$output = $this->getConsoleOutput();

		// If requesting the version, short circuit the application and send the version data
		if ($input->hasParameterOption(['--version', '-V'], true))
		{
			$output->writeln($this->getLongVersion());

			return 0;
		}

		$name = $this->getCommandName($input);

		// Redirect to the help command if requested
		if ($input->hasParameterOption(['--help', '-h'], true))
		{
			// If no command name was given, use the help command with a minimal input; otherwise flag the request for processing later
			if (!$name)
			{
				$name  = 'help';
				$input = new ArrayInput(['command_name' => $this->defaultCommand]);
			}
			else
			{
				$this->wantsHelp = true;
			}
		}

		// If we still do not have a command name, then the user has requested the application's default command
		if (!$name)
		{
			$name       = $this->defaultCommand;
			$definition = $this->getDefinition();

			// Overwrite the default value of the command argument with the default command name
			$definition->setArguments(
				array_merge(
					$definition->getArguments(),
					[
						'command' => new InputArgument(
							'command',
							InputArgument::OPTIONAL,
							$definition->getArgument('command')->getDescription(),
							$name
						),
					]
				)
			);
		}

		try
		{
			$this->runningCommand = null;

			$command = $this->getCommand($name);
		}
		catch (\Throwable $e)
		{
			if ($e instanceof CommandNotFoundException && !($e instanceof NamespaceNotFoundException))
			{
				(new SymfonyStyle($input, $output))->block(sprintf("\nCommand \"%s\" is not defined.\n", $name), null, 'error');
			}

			$event = new CommandErrorEvent($e, $this);

			$this->dispatchEvent(ConsoleEvents::COMMAND_ERROR, $event);

			if ($event->getExitCode() === 0)
			{
				return 0;
			}

			$e = $event->getError();

			throw $e;
		}

		$this->runningCommand = $command;
		$exitCode             = $this->runCommand($command, $input, $output);
		$this->runningCommand = null;

		return $exitCode;
	}
1131776
public static function run(): int {
            $startOfRun = microtime(true);
            $testDurationInMicroseconds = 0;

            $reporter = new ConsoleReporter;
            $reporter->setMaxEntries(static::$numberOfTest);
            $reporter->doNotClearProgress();
            $reporter->displaySeverityWithIcons();
            $reporter->setProgressBarSize(36);
            
            $currentDescriptionIndex = 1;
            $lastDescription = false;
            $lastTest = false;

            $completedTests = 0;
            $failedTests = 0;

            foreach( static::$tests as $description => $tests ) {
                if( static::allowedToReportDescription() === true ) {
                    $reporter->info("Running tests for \"$description\"");
                }

                $lastDescription = $currentDescriptionIndex === count(static::$tests);

                $currentTestIndex = 1;

                foreach( $tests as $expectedBehaviorString => $callableTest ) {
                    $startOfTest = microtime(true);
                    
                    try {
                        $lastTest = $currentTestIndex === count($tests);

                        $currentTestIndex++;

                        call_user_func($callableTest);

                        if( static::$reportLevel === ReportLevel::DETAILED ) {
                            $reporter->success('"it ' . $expectedBehaviorString . '" completed');
                        }

                        $completedTests++;
                    }
                    catch( TestFailedException $exception ) {
                        if( static::allowedToReportTestFailed() === true ) {
                            $reporter->error('"it ' . $expectedBehaviorString . '" failed');
                            $reporter->error($exception->getMessage());
                        }

                        $failedTests++;
                    }
                    finally {
                        $endOfTest = microtime(true);
                        $testDurationInMicroseconds += $endOfTest - $startOfTest;

                        if( $lastDescription === true && $lastTest === true ) {
                            $endOfRun = microtime(true);
                            $totalRunTimeInMicroseconds = $endOfRun - $startOfRun;
                            $extraRunTimeInMicoseconds  = round($totalRunTimeInMicroseconds - $testDurationInMicroseconds, 4);
                            $testDurationInMicroseconds = round($testDurationInMicroseconds, 4);

                            $reporter->debug("$completedTests tests completed, $failedTests tests failed");                            

                            if( static::allowedToReportElapsedTime() === true ) {
                                $reporter->debug("tests ran in $testDurationInMicroseconds sec. (+$extraRunTimeInMicoseconds sec.)");       
                            }
                        }

                        $reporter->report();
                        $reporter->advance();
                    }
                }

                $currentDescriptionIndex++;
            }

            if( $failedTests > 0 ) {
                return 1;
            }
            else {
                return 0;
            }
        }
973456
public function run()
    {
        //Bogus variable set. The original value is never used, but IDEs complain
        $result = new Result();
        $resultArray = array();
        $max = count($this->commands);

        for ($i = 0; $i < $max; ++$i) {
            $cmd = $this->commands[$i];

            if ($i === 0) {
                $resultArray[] = $result = $cmd->run();
                continue;
            }

            if (($cmd->_runMode === RUN_IF_PREVIOUS_SUCCEEDS && $result->getExitCode() !== 0) ||
                ($cmd->_runMode === RUN_IF_PREVIOUS_FAILS && $result->getExitCode() === 0)
            ) {
                continue;
            }

            if ($cmd->_pipe) {
                $stdOut = trim($result->getStdOut());

                $isXArg = false;
                foreach ($cmd as $argIdx => $arg) {
                    if ($arg instanceof Argument) {
                        if (stripos($arg->getKey(true), PIPE_PH) !== false) {
                            $key = str_replace(PIPE_PH, $stdOut, $arg->getKey(true));
                            $arg->setKey($key);
                        }

                        $values = $arg->getValues();
                        foreach ($values as $index => $val) {
                            if (stripos($val, PIPE_PH) !== false) {
                                $val = str_replace(PIPE_PH, $stdOut, $val);
                                $arg->replaceValue($index, $val);
                                $isXArg = true;
                            }
                        }
                    }
                }
                if (!$isXArg) {
                    $cmd->setStdIn($stdOut);
                }
            }

            $resultArray[] = $result = $cmd->run();
        }

        return $resultArray;
    }
875785
public function process()
    {
        list($action, $ids) = $this->Process->getRequestVars($this->name);
        return $this->Process->make($this->Groups, $action, $ids);
    }
428570
public function run()
    {
        $command = new \ReflectionClass($this);
        $options = input()->get();

        if (empty($options)) {
            if ($this->welcomeNote instanceof Format or $this->welcomeNote instanceof Text) {
                output()->write($this->welcomeNote);
            } elseif (is_string($this->welcomeNote) and $this->welcomeNote !== '') {
                output()->write(
                    (new Format())
                        ->setString(language()->getLine($this->welcomeNote))
                        ->setNewLinesAfter(1)
                );
            }

            output()->write(
                (new Format())
                    ->setString($this->name . ' v' . $this->version)
                    ->setNewLinesBefore(2)
                    ->setNewLinesAfter(1)
            );

            // Run help option
            $this->optionHelp();
        } else {

            foreach ($options as $method => $arguments) {

                if ($method === 'h') {
                    $method = 'help';
                } elseif ($method === 'v') {
                    $method = 'version';
                } elseif ($method === 'vv') {
                    $method = 'verbose';
                }

                $optionMethod = camelcase('option-' . $method);

                if ($command->hasMethod($optionMethod)) {

                    $commandMethod = $command->getMethod($optionMethod);

                    if ($commandMethod->getNumberOfRequiredParameters() == 0) {
                        call_user_func([&$this, $optionMethod]);
                    } else {
                        $optionArguments = is_array($arguments)
                            ? $arguments
                            : [$arguments];

                        call_user_func_array([&$this, $optionMethod], $optionArguments);
                    }
                }
            }
        }
    }
321914
public function run()
    {
        if ($this->opts->error !== null) {
            if ($this->opts->error !== '') {
                $top = '{cmd}: ' . $this->opts->error;
            } else {
                $top = '';
            }
            $this->usage($top);
            return $this->io;
        }
        if (!$this->loadOpts()) {
            return $this->io;
        }
        $this->process();
        return $this->io;
    }
952552
protected function doExecute()
	{
		$args = $this->input->args;

		$command = $this->getDescribedCommand($args);

		if (!$command->getApplication())
		{
			$command->setApplication($this->application);
		}

		$descriptor = $this->getDescriptor();

		/** @var $command Command */
		$rendered = $descriptor->describe($command);

		$this->out($rendered);

		return;
	}
334428
protected function run()
    {
        $this->version = $this->get(VersionAnalyzer::class);
        try {
            return $this->analyzeExtended();
        } catch (Exception $e) {
            return $this->analyzeSimple($e);
        }
    }
1297533
public function run()
    {
        foreach ($this->getCommands() as $command)
        {
            $this->transformer->transform($command);

            $this->application->add($command);
        }

        return $this->application->run();
    }
186437
public function execute() {
        global $CFG;
        require_once($CFG->dirroot. '/course/lib.php');

        // Set the proper user.
        if ($this->get_custom_data()->userid !== $this->get_custom_data()->realuserid) {
            $realuser = \core_user::get_user($this->get_custom_data()->realuserid, '*', MUST_EXIST);
            cron_setup_user($realuser);
            \core\session\manager::loginas($this->get_custom_data()->userid, \context_system::instance(), false);
        } else {
            $user = \core_user::get_user($this->get_custom_data()->userid, '*', MUST_EXIST);
            cron_setup_user($user);
        }

        $cms = $this->get_custom_data()->cms;
        foreach ($cms as $cm) {
            try {
                course_delete_module($cm->id);
            } catch (\Exception $e) {
                throw new \coding_exception("The course module {$cm->id} could not be deleted. {$e->getTraceAsString()}");
            }
        }
    }
190348
public function run()
    {
        // If the truthTest failed, don't run
        if ($this->truthTest !== true) {
            return false;
        }

        // If overlapping, don't run
        if ($this->isOverlapping()) {
            return false;
        }

        // Write lock file if necessary
        $this->createLockFile();

        // Call before if required
        if (is_callable($this->before)) {
            call_user_func($this->before);
        }

        // If command is callable...
        if (is_callable($this->command)) {
            $this->output = $this->exec();
        } else {
            $args = \is_string($this->args) ? $this->args : implode(' ', $this->args);
            $command = $this->command . ' ' . $args;
            $process = new Process($command);

            $this->process = $process;

            if ($this->runInBackground()) {
                $process->start();
            } else {
                $process->run();
                $this->finalize();
            }
        }

        return true;
    }
175821
public function run() {
		$start_time = microtime( true );

		$proc = Utils\proc_open_compat( $this->command, self::$descriptors, $pipes, $this->cwd, $this->env );

		$stdout = stream_get_contents( $pipes[1] );
		fclose( $pipes[1] );

		$stderr = stream_get_contents( $pipes[2] );
		fclose( $pipes[2] );

		$return_code = proc_close( $proc );

		$run_time = microtime( true ) - $start_time;

		if ( self::$log_run_times ) {
			if ( ! isset( self::$run_times[ $this->command ] ) ) {
				self::$run_times[ $this->command ] = array( 0, 0 );
			}
			self::$run_times[ $this->command ][0] += $run_time;
			self::$run_times[ $this->command ][1]++;
		}

		return new ProcessRun(
			array(
				'stdout'      => $stdout,
				'stderr'      => $stderr,
				'return_code' => $return_code,
				'command'     => $this->command,
				'cwd'         => $this->cwd,
				'env'         => $this->env,
				'run_time'    => $run_time,
			)
		);
	}
626192
public function execute() {
        global $DB;

        mtrace("\n  Cleaning up old question statistics cache records...", '');

        $expiretime = time() - 5 * HOURSECS;
        $DB->delete_records_select('question_statistics', 'timemodified < ?', [$expiretime]);
        $responseanlysisids = $DB->get_records_select_menu('question_response_analysis',
            'timemodified < ?',
            [$expiretime],
            'id',
            'id, id AS id2');
        $DB->delete_records_list('question_response_analysis', 'id', $responseanlysisids);
        $DB->delete_records_list('question_response_count', 'analysisid', $responseanlysisids);

        mtrace('done.');
    }