The thread implementation main method which will be called from run in abstractness

@return void
170198
public function main()
    {

        // log the configured deployment directory
        $this->getSystemLogger()->debug(
            sprintf(
                "Start watching heartbeat file %s",
                $this->getHeartbeatFile()
            )
        );

        // wait until the server has been successfully started at least once
        while ($this->getLastFileTouch($this->getHeartbeatFile()) === 0) {
            $this->getSystemLogger()->debug('Heartbeat scanner is waiting for first successful startup ...');
            sleep(1);
        }

        // watch the heartbeat file
        while (true) {
            // load the current file change time of the heartbeat file and store it
            $oldMTime = $this->getLastFileTouch($this->getHeartbeatFile());

            // Get the current time
            $currentTime = time();

            // log the found directory hash value
            $this->getSystemLogger()->debug(
                sprintf(
                    "Comparing heartbeat mTimes %s (previous) : %s (actual)",
                    $oldMTime,
                    $currentTime
                )
            );

            // compare the mTime values, if they differ more than allowed we have to take action
            if (($currentTime - $oldMTime) > self::HEARTBEAT_INTERVAL) {
                // log that changes have been found
                $this->getSystemLogger()->debug(
                    sprintf(
                        "Found heartbeat missing for %s seconds.",
                        $currentTime - $oldMTime
                    )
                );

                // as long as the heartbeat does not come back up we will try to restart the appserver
                while ($oldMTime === $this->getLastFileTouch($this->getHeartbeatFile())) {
                    // tell them we try to restart
                    $this->getSystemLogger()->debug("Will try to restart the appserver.");

                    // restart the appserver
                    $this->restart();

                    // wait until restart has been finished, but only wait for so long
                    for ($i = 0; $i <= self::RESTART_INTERVAL; $i ++) {
                        // sleep a little
                        sleep(1);
                    }
                }

                // log that the appserver has been restarted successfully
                $this->getSystemLogger()->debug("appserver has successfully been restarted.");

            } else {
                // if no changes has been found, wait a second
                sleep(1);
            }
        }
    }
1273454
public function run()
    {
        Debug::enable();

        // make whatever is necessary to disable all stuff that could buffer output
        ini_set('zlib.output_compression', 0);
        ini_set('output_buffering', 0);
        ini_set('implicit_flush', 1);
        ob_implicit_flush(1);

        $this->loop = Factory::create();
        $this->controller = new UnixServer($this->getControllerSocketPath(), $this->loop);
        $this->controller->on('connection', [$this, 'onSlaveConnection']);

        $this->web = new Server(sprintf('%s:%d', $this->host, $this->port), $this->loop);
        $this->web->on('connection', [$this, 'onRequest']);

        $this->loop->addSignal(SIGTERM, [$this, 'shutdown']);
        $this->loop->addSignal(SIGINT, [$this, 'shutdown']);
        $this->loop->addSignal(SIGCHLD, [$this, 'handleSigchld']);
        $this->loop->addSignal(SIGUSR1, [$this, 'restartSlaves']);
        $this->loop->addSignal(SIGUSR2, [$this, 'reloadSlaves']);

        if ($this->isDebug()) {
            $this->loop->addPeriodicTimer(0.5, function () {
                $this->checkChangedFiles();
            });
        }

        $loopClass = (new \ReflectionClass($this->loop))->getShortName();

        $this->output->writeln("<info>Starting PHP-PM with {$this->slaveCount} workers, using {$loopClass} ...</info>");
        $this->writePid();

        $this->createSlaves();

        $this->loop->run();
    }
1324463
public function main()
    {
        $asg = $this->getService();

        $awsResult = $asg->describeAutoScalingGroups([
            'AutoScalingGroupNames' => [$this->getName()],
        ]);

        if (empty($awsResult['AutoScalingGroups'])) {
            if ($this->asgExistsProperty) {
                $this->project->setProperty(
                    $this->asgExistsProperty,
                    false
                );
            }
            return;
        }

        $group = $awsResult['AutoScalingGroups'];

        if ($this->asgExistsProperty) {
            $this->project->setProperty(
                $this->asgExistsProperty,
                true
            );
        }

        if ($this->outputProperty) {
            $this->project->setProperty(
                "{$this->outputProperty}.AutoScalingGroupName",
                $group[0]['AutoScalingGroupName']
            );

            $this->project->setProperty(
                "{$this->outputProperty}.AutoScalingGroupARN",
                $group[0]['AutoScalingGroupARN']
            );

            $this->project->setProperty(
                "{$this->outputProperty}.LaunchConfigurationName",
                $group[0]['LaunchConfigurationName']
            );
        }
    }
102034
public function main()
    {
        try {
            // Log
            $this->log('Started ', $this->loglevel);
            // Initialize //
            $this->prepare();
            $haveExecuted = false;
            // Validate O.S. applicability
            if ($this->isValidOs()) {
                // Build the command //
                $this->buildCommand();
                // Process //
                $totalFiles = 0;
                $totalDirs = 0;
                $fileNames = [];
                // - FileSets
                foreach ($this->filesets as $fs) {
                    $currentType = $this->type;
                    if ($fs instanceof DirSet) {
                        if ($this->type !== self::$types['DIR']) {
                            $this->log(
                                "Found a nested dirset but type is $this->type . "
                                . "Temporarily switching to type=\"dir\" on the"
                                . " assumption that you really did mean"
                                . " <dirset> not <fileset>.",
                                Project::MSG_DEBUG
                            );
                            $currentType = 'dir';
                        }
                    }
                    $base = $fs->getDir($this->project);
                    $ds = $fs->getDirectoryScanner($this->project);
                    if ($currentType !== self::$types['DIR']) {
                        $s = $this->getFiles($base, $ds);
                        foreach ($s as $fileName) {
                            $totalFiles++;
                            $fileNames[] = $fileName;
                            $baseDirs[] = $base;
                        }
                    }
                    if ($currentType !== self::$types['FILE']) {
                        $s = $this->getDirs($base, $ds);
                        foreach ($s as $fileName) {
                            $totalDirs++;
                            $fileNames[] = $fileName;
                            $baseDirs[] = $base;
                        }
                    }
                    if (count($fileNames) === 0 && $this->skipEmpty) {
                        $this->logSkippingFileset($currentType, $ds, $base);
                        continue;
                    }
                    $this->process(
                        $fs->getDirectoryScanner($this->project)->getIncludedFiles(),
                        $fs->getDir($this->project)
                    );
                    $haveExecuted = true;
                }
                unset($this->filesets);
                // - FileLists
                /**
                 * @var FileList $fl
                 */
                foreach ($this->filelists as $fl) {
                    $totalFiles++;
                    $this->process($fl->getFiles($this->project), $fl->getDir($this->project));
                    $haveExecuted = true;
                }
                unset($this->filelists);
            }
            if ($haveExecuted) {
                $this->log(
                    "Applied " . $this->commandline->getExecutable() . " to "
                    . $totalFiles . " file"
                    . ($totalFiles !== 1 ? "s" : "") . " and "
                    . $totalDirs . " director"
                    . ($totalDirs !== 1 ? "ies" : "y") . ".",
                    $this->loglevel
                );
            }
            /// Cleanup //
            $this->cleanup();
            // Log
            $this->log('End ', $this->loglevel);
        } catch (IOException | NullPointerException | UnexpectedValueException $e) {
            throw new BuildException('Execute failed: ' . $e, $e, $this->getLocation());
        }
    }
191210
public function run()
    {
        $MenuTypes = ['header', 'sidebar', 'footer'];

        foreach ($MenuTypes as $MenuType) {
            $Type = ['type' => $MenuType];

            factory(Menu::class, 5)->create($Type)->each(function ($u) use ($Type) {
                $u->children()->saveMany(factory(Menu::class, 2)->create($Type)
                    ->each(function ($p) use ($Type) {
                        $p->children()->saveMany(factory(Menu::class, 2)->make($Type));
                    }));
            });
        }
    }
989228
protected function run()
    {
        Daemon::$process = $this;

        $this->prepareSystemEnv();
        class_exists('Timer'); // ensure loading this class
        gc_enable();

        $this->callbacks = new StackCallbacks;

        /*
         * @todo This line must be commented according to current libevent binding implementation.
         * May be uncommented in future.
         */
        //EventLoop::init()

        if (EventLoop::$instance) {
            $this->registerEventSignals();
        } else {
            $this->registerSignals();
        }

        $this->workers = new Collection();
        $this->collections['workers'] = $this->workers;
        $this->ipcthreads = new Collection;
        $this->collections['ipcthreads'] = $this->ipcthreads;

        Daemon::$appResolver->preload(true);

        $this->spawnIPCThread();
        $this->spawnWorkers(
            min(
                Daemon::$config->startworkers->value,
                Daemon::$config->maxworkers->value
            )
        );
        $this->timerCb = function ($event) use (&$cbs) {
            static $c = 0;

            ++$c;

            if ($c > 0xFFFFF) {
                $c = 1;
            }

            if (($c % 10 == 0)) {
                gc_collect_cycles();
            }

            if (!$this->lastMpmActionTs || ((microtime(true) - $this->lastMpmActionTs) > $this->minMpmActionInterval)) {
                $this->callMPM();
            }
            if ($event) {
                $event->timeout();
            }
        };

        if (EventLoop::$instance) { // we are using libevent in Master
            Timer::add($this->timerCb, 1e6 * Daemon::$config->mpmdelay->value, 'MPM');
            EventLoop::$instance->run();
        } else { // we are NOT using libevent in Master
            $lastTimerCall = microtime(true);
            $func = $this->timerCb;
            while (!$this->breakMainLoop) {
                $this->callbacks->executeAll($this);
                if (microtime(true) > $lastTimerCall + Daemon::$config->mpmdelay->value) {
                    $func(null);
                    $lastTimerCall = microtime(true);
                }
                $this->sigwait();
            }
        }
    }
584378
public function run()
    {
        $hasChanges = false;
        foreach ($this->tables as $table) {
            if (
                $table->getComparator()->hasChanges()
                || $table->getStatus() == AbstractTable::STATUS_DECLARED_DROPPED
            ) {
                $hasChanges = true;
                break;
            }
        }

        if (!$hasChanges) {
            //Nothing to do
            return;
        }

        $this->beginTransaction();

        try {
            //Drop not-needed foreign keys and alter everything else
            $this->dropForeignKeys();

            //Drop not-needed indexes
            $this->dropIndexes();

            //Other changes [NEW TABLES WILL BE CREATED HERE!]
            foreach ($this->commitChanges() as $table) {
                $table->save(HandlerInterface::CREATE_FOREIGN_KEYS, true);
            }
        } catch (\Throwable $e) {
            $this->rollbackTransaction();
            throw $e;
        }

        $this->commitTransaction();
    }
1165676
public function run() {
		
		// various set-up options
		$options                 = array();
		$options["patternPaths"] = $this->patternPaths;
		$patternDataStore        = PatternData::get();
		$stringLoader            = Template::getStringLoader();
		
		// load the pattern loader
		$patternEngineBasePath   = PatternEngine::getInstance()->getBasePath();
		$patternLoaderClass      = $patternEngineBasePath."\Loaders\PatternLoader";
		$patternLoader           = new $patternLoaderClass($options);
		
		// parse all of the CSS in the project
		$kss = new Parser(Config::getOption("sourceDir"));
		
		foreach ($patternDataStore as $patternStoreKey => $patternStoreData) {
			
			if ($patternStoreData["category"] == "pattern") {
				
				$kssSection = "";
				
				try {
					$kssSection = $kss->getSection($patternStoreKey);
				} catch(\Exception $e) {
					$kssSection = "";
				}
				
				// see if this pattern has a section in the loaded KSS
				if (!empty($kssSection)) {
					
					// update the name and desc based on the KSS
					PatternData::setPatternOption($patternStoreKey, "name", $kssSection->getTitle());
					PatternData::setPatternOption($patternStoreKey, "desc", $kssSection->getDescription());
					PatternData::setPatternOption($patternStoreKey, "descExists", true);
					
					// find the kss modifiers
					$modifiers = $kssSection->getModifiers();
					
					if (!empty($modifiers)) {
						
						$patternModifiers = array();
						
						// work through each modifier
						foreach ($modifiers as $modifier) {
							
							$name               = $modifier->getName();
							$class              = $modifier->getClassName();
							$desc               = $modifier->getDescription();
							$code               = "";
							$modifierCodeExists = false;
							
							// if it's not a pseudo class render it
							if (strpos($name,":") !== false) {
								
								$data    = Data::getPatternSpecificData($patternStoreKey);
								$data    = array_merge($data,array("styleModifier" => $class));
								
								$srcPath = (isset($patternStoreData["pseudo"])) ? PatternData::getPatternOption($patternStoreData["original"],"pathName") : $patternStoreData["pathName"];
								$code    = $patternLoader->render(array("pattern" => $srcPath, "data" => $data));
								
								$modifierCodeExists    = true;
								
							}
							
							// add pattern modifier info
							$patternModifiers[] = array("modifierName"       => $name,
														"modifierDesc"       => $desc,
														"modifierCode"       => $code,
														"modifierCodeExists" => $modifierCodeExists);
							
							$patternModifiersOutput[] = array("modifierName" => $name,
														      "modifierDesc" => $desc);
							
						}
						
						// this is silly but keeps it looking cleaner to me
						$patternModifierData = array("patternModifiers" => $patternModifiers);
						$patternModifierOutputData = array("patternModifiersExist" => true, "patternModifiers" => $patternModifiersOutput);
						
						// grab extra sections based on KSS syntax
						if (!empty($kssSection->getCompatibility())) {
							$patternModifierData["compatibility"]             = $kssSection->getCompatibility();
							$patternModifierData["compatibilityExists"]       = true;
							$patternModifierOutputData["compatibility"]       = $kssSection->getCompatibility();
							$patternModifierOutputData["compatibilityExists"] = true;
						}
						if (!empty($kssSection->getExperimental())) {
							$patternModifierData["experimental"]              = $kssSection->getExperimental();
							$patternModifierData["experimentalExists"]        = true;
							$patternModifierOutputData["experimental"]        = $kssSection->getExperimental();
							$patternModifierOutputData["experimentalExists"]  = true;
						}
						if (!empty($kssSection->getDeprecated())) {
							$patternModifierData["deprected"]                 = $kssSection->getDeprecated();
							$patternModifierData["deprecatedExists"]          = true;
							$patternModifierOutputData["deprecated"]          = $kssSection->getDeprecated();
							$patternModifierOutputData["deprecatedExists"]    = true;
						}
						if (!empty($kssSection->getParameters())) {
							$patternModifierData["parameters"]                = $kssSection->getParameters();
							$patternModifierData["parametersExist"]           = true;
							$patternModifierOutputData["parameters"]          = $kssSection->getParameters();
							$patternModifierOutputData["parametersExists"]    = true;
						}
						
						// render the views for the plug-in
						$partialViewDescAddition    = $stringLoader->render(array("string" => $this->descTemplate, "data" => $patternModifierData));
						$partialViewExampleAddition = $stringLoader->render(array("string" => $this->exampleTemplate, "data" => $patternModifierData));
						
						// add the views to the appropriate containers in the patterndata::$store
						PatternData::setPatternOptionArray($patternStoreKey, "partialViewDescAdditions", $partialViewDescAddition);
						PatternData::setPatternOptionArray($patternStoreKey, "partialViewExampleAdditions", $partialViewExampleAddition);
						PatternData::setPatternOptionArray($patternStoreKey, "extraOutput", $patternModifierOutputData, "patternLabPluginKSS");
						
					}
					
				}
				
			}
			
		}
		
		unset($kss);
		
	}
930909
public function main()
    {

        // register the default autoloader
        require SERVER_AUTOLOADER;

        // initialize the container state
        $this->containerState = ContainerStateKeys::get(ContainerStateKeys::WAITING_FOR_INITIALIZATION);

        // create a new API app service instance
        $this->service = $this->newService('AppserverIo\Appserver\Core\Api\AppService');

        // initialize the container for the configured class laoders
        $classLoaders = new GenericStackable();

        // register the configured class loaders
        $this->registerClassLoaders($classLoaders);

        // register shutdown handler
        register_shutdown_function(array(&$this, "shutdown"));

        // query whether the container's directories exists and are readable
        $this->validateDirectories();

        // initialize the naming directory with the environment data
        $this->namingDirectory->createSubdirectory(sprintf('php:env/%s', $this->getName()));
        $this->namingDirectory->createSubdirectory(sprintf('php:global/%s', $this->getName()));
        $this->namingDirectory->createSubdirectory(sprintf('php:global/log/%s', $this->getName()));
        $this->namingDirectory->bind(sprintf('php:env/%s/appBase', $this->getName()), $this->getAppBase());
        $this->namingDirectory->bind(sprintf('php:global/%s/runlevel', $this->getName()), $this->getRunlevel());

        // initialize the container state
        $this->containerState = ContainerStateKeys::get(ContainerStateKeys::INITIALIZATION_SUCCESSFUL);

        // initialize instance that contains the applications
        $this->applications = new GenericStackable();

        // initialize the profile logger and the thread context
        if ($profileLogger = $this->getInitialContext()->getLogger(LoggerUtils::PROFILE)) {
            $profileLogger->appendThreadContext($this->getContainerNode()->getName());
        }

        // initialize the array for the server configurations
        $serverConfigurations = array();

        // load the server configurations and query whether a server signatures has been set
        /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $serverNode */
        foreach ($this->getContainerNode()->getServers() as $serverNode) {
            $serverConfigurations[] = $this->getServerNodeConfiguration($serverNode);
        }

        // init upstreams
        $upstreams = array();
        if ($this->getContainerNode()->getUpstreams()) {
            $upstreams = $this->getContainerNode()->getUpstreams();
            foreach ($this->getContainerNode()->getUpstreams() as $upstreamNode) {
                // get upstream type
                $upstreamType = $upstreamNode->getType();
                // init upstream instance
                $upstream = new $upstreamType();
                // init upstream servers
                $servers = array();
                // get upstream servers from upstream
                foreach ($upstreamNode->getUpstreamServers() as $upstreamServerNode) {
                    $upstreamServerType = $upstreamServerNode->getType();
                    $upstreamServerParams = $upstreamServerNode->getParamsAsArray();
                    $servers[$upstreamServerNode->getName()] = new $upstreamServerType($upstreamServerParams);
                }
                // inject server instances to upstream
                $upstream->injectServers($servers);
                // set upstream by name
                $upstreams[$upstreamNode->getName()] = $upstream;
            }
        }

        // init server array
        $this->servers = new GenericStackable();

        // start servers by given configurations
        /** @var \AppserverIo\Server\Interfaces\ServerConfigurationInterface $serverConfig */
        foreach ($serverConfigurations as $serverConfig) {
            // get type definitions
            $serverType = $serverConfig->getType();
            $serverContextType = $serverConfig->getServerContextType();

            // create a new instance server context
            /** @var \AppserverIo\Server\Interfaces\ServerContextInterface $serverContext */
            $serverContext = new $serverContextType();

            // inject container to be available in specific mods etc. and initialize the module
            $serverContext->injectContainer($this);

            // init server context by config
            $serverContext->init($serverConfig);

            // inject upstreams
            $serverContext->injectUpstreams($upstreams);

            // inject loggers
            $serverContext->injectLoggers($this->getInitialContext()->getLoggers());

            // create the server (which should start it automatically)
            /** @var \AppserverIo\Server\Interfaces\ServerInterface $server */
            $server = new $serverType($serverContext);
            // collect the servers we started
            $this->servers[$serverConfig->getName()] = $server;
        }

        // wait for all servers to be started
        $waitForServers = true;
        while ($waitForServers === true) {
            // iterate over all servers to check the state
            foreach ($this->servers as $server) {
                if ($server->serverState === ServerStateKeys::WORKERS_INITIALIZED) {
                    $waitForServers = false;
                } else {
                    $waitForServers = true;
                }
            }
            usleep(10000);
        }

        // the container has successfully been initialized
        $this->synchronized(function ($self) {
            $self->containerState = ContainerStateKeys::get(ContainerStateKeys::SERVERS_STARTED_SUCCESSFUL);
        }, $this);

        // initialize the flag to keep the application running
        $keepRunning = true;

        // wait till container will be shutdown
        while ($keepRunning) {
            // query whether we've a profile logger, log resource usage
            if ($profileLogger) {
                $profileLogger->debug(sprintf('Container %s still waiting for shutdown', $this->getContainerNode()->getName()));
            }

            // wait a second to lower system load
            $keepRunning = $this->synchronized(function ($self) {
                $self->wait(1000000 * AbstractContainerThread::TIME_TO_LIVE);
                return $self->containerState->equals(ContainerStateKeys::get(ContainerStateKeys::SERVERS_STARTED_SUCCESSFUL));
            }, $this);
        }

        // we need to stop all servers before we can shutdown the container
        /** @var \AppserverIo\Server\Interfaces\ServerInterface $server */
        foreach ($this->servers as $server) {
            $server->stop();
        }

        // mark the container as successfully shutdown
        $this->synchronized(function ($self) {
            $self->containerState = ContainerStateKeys::get(ContainerStateKeys::SHUTDOWN);
        }, $this);

        // send log message that the container has been shutdown
        $this->getInitialContext()->getSystemLogger()->info(
            sprintf('Successfully shutdown container %s', $this->getContainerNode()->getName())
        );
    }
200962
public function run()
	{
		// streams
		$read = [$this->_input];

		$write  = null;
		$except = null;

		// stream ends?
		$end_of_stream = false;

		$waitForMinComputationTime = defined('PROKKIBOT_MIN_COMPUTATION_TIME') && !empty(PROKKIBOT_MIN_COMPUTATION_TIME);

		do
		{

			$changed_streams = stream_select($read, $write, $except, PROKKIBOT_MAX_SERVER_TIMEOUT);

			if( $waitForMinComputationTime )
			{
				$time_start = get_microtime_float();
			}
			
			if( false === $changed_streams )
			{
				die();
			}

			foreach( $read as $_handle )
			{

				$string = trim(fgets($_handle));

				if( empty($string) )
				{
					$end_of_stream = true;
					continue;
				}

				Debugger::Log(sprintf("received: %s\n", $string));

				$end_of_stream = feof($_handle);

				try
				{

					$command = $this->_bot->getParser()->run($string);

//					Debugger::Log(get_class($command) . "\n");

					$command->apply($this->_bot);

//					Debugger::Log("applied\n");

//					Debugger::Log(sprintf("Round: %d, Remaining: %d, Last: %d\n",
//						$this->_environment->getCurrentRoundNo(),
//						$this->_environment->getRemainingRounds(),
//						$this->_environment->isLastRound()
//					));

					if( $command->isComputable() )
					{

						/** @var Computable $command */
						$send = $command->compute($this->_bot);

						if( $waitForMinComputationTime )
						{
							self::_WaitForMinCompuitationTime($time_start);
						}

						fwrite($this->_output, $send . "\n");

						Debugger::Log(sprintf("send: %s\n", $send));
					}

				}
				catch( \Exception $exception )
				{
					Debugger::Log(sprintf("Exception:%s\n\n%s", $exception->getMessage(), $exception->getTraceAsString()));

					$send = "Aborting due an error :-(";

					fwrite($this->_output, $send . "\n");

					Debugger::Log(sprintf("send: %s\n", $send));

					$end_of_stream = true;
				}

			}
		}
		while( !$end_of_stream && !empty($changed_streams) );

		Debugger::Log("MEM: " . size_to_readable_string(memory_get_usage(true)) . "\n");

		Debugger::Log("END!\n");

		fclose($this->_input);
	}
917635
function main()
    {
        $lem = new PHP_ParserGenerator_Data;

        $this->OptInit($_SERVER['argv']);
        if ($this->_version) {
            echo "Lemon version 1.0/PHP_ParserGenerator port version @package_version@\n";
            //exit(0); 
            return;
        }
        if ($this->OptNArgs($_SERVER['argv']) != 1) {
            echo "Exactly one filename argument is required.\n";
            //exit(1);
            return;
        }
        $lem->errorcnt = 0;
        $lem->parser_template = $this->_parser_template;

        /* Initialize the machine */
        $lem->argv0 = $_SERVER['argv'][0];
        $lem->filename = $this->_optArg(0, $_SERVER['argv']);
        $a = pathinfo($lem->filename);
        if (isset($a['extension'])) {
            $ext = '.' . $a['extension'];
            $lem->filenosuffix = substr($lem->filename, 0, strlen($lem->filename) - strlen($ext));
        } else {
            $lem->filenosuffix = $lem->filename;
        }
        $lem->basisflag = $this->_basisflag;
        $lem->has_fallback = 0;
        $lem->nconflict = 0;
        $lem->name = $lem->include_code = $lem->include_classcode = $lem->arg = $lem->tokentype = $lem->start = 0;
        $lem->vartype = 0;
        $lem->stacksize = 0;
        $lem->error = $lem->overflow = $lem->failure = $lem->accept = $lem->tokendest = $lem->tokenprefix = $lem->outname = $lem->extracode = 0;
        $lem->vardest = 0;
        $lem->tablesize = 0;
        PHP_ParserGenerator_Symbol::Symbol_new("$");
        $lem->errsym = PHP_ParserGenerator_Symbol::Symbol_new("error");

        /* Parse the input file */
        $parser = new PHP_ParserGenerator_Parser($this);
        $parser->Parse($lem);
        if ($lem->errorcnt) {
            return;
            // exit($lem->errorcnt);
        }
        if ($lem->rule === 0) {
            printf("Empty grammar.\n");
            return;
            //exit(1);
        }

        /* Count and index the symbols of the grammar */
        $lem->nsymbol = PHP_ParserGenerator_Symbol::Symbol_count();
        PHP_ParserGenerator_Symbol::Symbol_new("{default}");
        $lem->symbols = PHP_ParserGenerator_Symbol::Symbol_arrayof();
        for ($i = 0; $i <= $lem->nsymbol; $i++) {
            $lem->symbols[$i]->index = $i;
        }
        usort($lem->symbols, array('PHP_ParserGenerator_Symbol', 'sortSymbols'));
        for ($i = 0; $i <= $lem->nsymbol; $i++) {
            $lem->symbols[$i]->index = $i;
        }
        // find the first lower-case symbol
        for ($i = 1; ord($lem->symbols[$i]->name[0]) <= ord('Z'); $i++);
        $lem->nterminal = $i;

        /* Generate a reprint of the grammar, if requested on the command line */
        if ($this->_rpflag) {
            $this->Reprint();
        } else {
            /* Initialize the size for all follow and first sets */
            $this->SetSize($lem->nterminal);

            /* Find the precedence for every production rule (that has one) */
            $lem->FindRulePrecedences();

            /* Compute the lambda-nonterminals and the first-sets for every
            ** nonterminal */
            $lem->FindFirstSets();

            /* Compute all LR(0) states.  Also record follow-set propagation
            ** links so that the follow-set can be computed later */
            $lem->nstate = 0;
            $lem->FindStates();
            $lem->sorted = PHP_ParserGenerator_State::State_arrayof();

            /* Tie up loose ends on the propagation links */
            $lem->FindLinks();

            /* Compute the follow set of every reducible configuration */
            $lem->FindFollowSets();

            /* Compute the action tables */
            $lem->FindActions();

            /* Compress the action tables */
            if ($this->_compress===0) {
                $lem->CompressTables();
            }

            /* Reorder and renumber the states so that states with fewer choices
            ** occur at the end. */
            $lem->ResortStates();

            /* Generate a report of the parser generated.  (the "y.output" file) */
            if (!$this->_quiet) {
                $lem->ReportOutput();
            }

            /* Generate the source code for the parser */
            $lem->ReportTable($this->_mhflag);

            /* Produce a header file for use by the scanner.  (This step is
            ** omitted if the "-m" option is used because makeheaders will
            ** generate the file for us.) */
            //if (!$this->_mhflag) {
            //    $this->ReportHeader();
            //}
        }
        if ($this->_statistics) {
            printf(
                "Parser statistics: %d terminals, %d nonterminals, %d rules\n",
                $lem->nterminal,
                $lem->nsymbol - $lem->nterminal,
                $lem->nrule
            );
            printf(
                "                   %d states, %d parser table entries, %d conflicts\n",
                $lem->nstate,
                $lem->tablesize,
                $lem->nconflict
            );
        }
        if ($lem->nconflict) {
            printf("%d parsing conflicts.\n", $lem->nconflict);
        }
        //exit($lem->errorcnt + $lem->nconflict);
        echo $lem->errorcnt + $lem->nconflict;
        return ($lem->errorcnt + $lem->nconflict);
    }
186119
public function run(): void
    {
        pcntl_async_signals(true);

        $this->makeSocket();

        [$pid, $master, $workers] = $this->spawn();

        if ($pid) {
            fclose($this->socket);
            $this->workerPids = $workers;
            $this->handleSignals();

            (new Master($workers, $this->unixConnector, $this->exchangeWorkersData))->dispatch();
        } else {
            if ($this->useConnector) {
                fclose($this->unixConnector);
            }

            (new $this->handler($this->socket, $master))->handle();
        }
    }
50668
public function main()
    {
        if ($this->params['stagger']) {
            sleep(rand(0, $this->params['stagger']));
        }

        Configure::write('App.baseUrl', '/');
        $emailQueue = TableRegistry::getTableLocator()->get('EmailQueue', ['className' => EmailQueueTable::class]);
        $emails = $emailQueue->getBatch($this->params['limit']);

        $count = count($emails);
        foreach ($emails as $e) {
            $configName = $e->config === 'default' ? $this->params['config'] : $e->config;
            $template = $e->template === 'default' ? $this->params['template'] : $e->template;
            $layout = $e->layout === 'default' ? $this->params['layout'] : $e->layout;
            $headers = empty($e->headers) ? [] : (array)$e->headers;
            $theme = empty($e->theme) ? '' : (string)$e->theme;
            $viewVars = empty($e->template_vars) ? [] : $e->template_vars;
            $errorMessage = null;

            try {
                $email = $this->_newEmail($configName);

                if (!empty($e->from_email) && !empty($e->from_name)) {
                    $email->setFrom($e->from_email, $e->from_name);
                }

                $transport = $email->getTransport();

                if ($transport && $transport->getConfig('additionalParameters')) {
                    $from = key($email->getFrom());
                    $transport->setConfig(['additionalParameters' => "-f $from"]);
                }

                if (!empty($e->attachments)) {
                    $email->setAttachments($e->attachments);
                }

                $sent = $email
                    ->setTo($e->email)
                    ->setSubject($e->subject)
                    ->setEmailFormat($e->format)
                    ->addHeaders($headers)
                    ->setViewVars($viewVars)
                    ->setMessageId(false)
                    ->setReturnPath($email->getFrom());

                $email->viewBuilder()
                    ->setLayout($layout)
                    ->setTheme($theme)
                    ->setTemplate($template);

                $email->send();
            } catch (SocketException $exception) {
                $this->err($exception->getMessage());
                $errorMessage = $exception->getMessage();
                $sent = false;
            }

            if ($sent) {
                $emailQueue->success($e->id);
                $this->out('<success>Email ' . $e->id . ' was sent</success>');
            } else {
                $emailQueue->fail($e->id, $errorMessage);
                $this->out('<error>Email ' . $e->id . ' was not sent</error>');
            }
        }
        if ($count > 0) {
            $locks = collection($emails)->extract('id')->toList();
            $emailQueue->releaseLocks($locks);
        }
    }
799529
public function run()
    {

        // register the default autoloader
        require SERVER_AUTOLOADER;

        // create a local copy of the manager instance
        $manager = $this->manager;

        // query whether the manager has an application with class loaders/annotation registries to be registered
        if (method_exists($manager, 'getApplication') && $application = $manager->getApplication()) {
            $application->registerClassLoaders();
            $application->registerAnnotationRegistries();
        }

        // stop the manager if an apropriate method exists
        if (method_exists($manager, 'stop')) {
            $manager->stop();
        }
    }
562289
public function main() {
		if (!class_exists('Robo\Runner')) {
			$this->err('<error>Unable to load Robo\Runner.</error>');
			$this->err('');
			$this->err('Make sure you have installed robo as a dependency,');
			$this->err('and that Robo\Runner is registered in your autoloader.');
			$this->err('');
			$this->err('If you are using composer run');
			$this->err('');
			$this->err('<info>$ php composer.phar require codegyre/robo</info>');
			$this->err('');
			return 1;
		}

		array_shift($_SERVER['argv']);

		$runner = new Runner();
		$runner->file = $this->params['config'];
		$runner->execute();
	}
465288
public function run()
    {
        // Get and instantiate the reporter class, load files
        $reporterClass = self::$console->getReporterClass();
        $this->reporter = new $reporterClass(self::$console);

        $this->reporter->beforeRun();
        foreach ($this->suites as $suite) {
            $this->runSuite($suite);
        }
        $this->reporter->afterRun();

        if (self::$console->options['watch']) {
            $this->watch();
        }
    }
1244052
protected function run()
    {
        $this->silentRunActionTrigger(Action::EVENT_START);
        try {
            $event = $this->action->execute($this->control, $this->context) ?: Action::EVENT_SUCCESS;
            $this->context->exitCode = 0;
        } catch (ErrorException $errorException) {
            $event = Action::EVENT_ERROR;
            $this->context->exception = $errorException;
            $this->context->exitCode = 2;
        } catch (Exception $exception) {
            $event = Action::EVENT_FAILURE;
            $this->context->exception = $exception;
            $this->context->exitCode = 1;
        }
        $this->context->finishTime = time();
        $this->silentRunActionTrigger($event);
        $this->silentRunActionTrigger(Action::EVENT_FINISH);
    }