@throws \Exception

@return void
962525
private function parse(){

		$docList = $this->docBlock->parse();

		$filename = array_shift($this->argv);
		$command = array_shift($this->argv);

		/**
		* Aquire parameters
		*/
		while($arg = array_shift($this->argv)){

			$quotes = array("'",'"');

			$optionsExists = preg_match("/^-[-\w]+/", $arg);

			// print_r(array(

			// 	"optionExists"=>$optionsExists,
			// 	"arg"=>$arg
			// ));

			$argsExists = !empty(key($docList["arguments"]));

			if($optionsExists){

				$optionExists = in_array($arg, array_keys($docList["options"]));
				$optionAliasExists = @in_array($arg, array_keys($docList["aliases"]));

				if($optionExists){

					$args[$arg] = 1;

					if($docList["usage"][$arg]["input"])
						$args[$arg] = str_replace($quotes, "", array_shift($this->argv));	
				}
				
				if(!$optionExists && $optionAliasExists){

					$arg = $docList["aliases"][$arg];
					$args[$arg] = 1;

					if($docList["usage"][$arg]["input"])
						$args[$arg] = str_replace($quotes, "", array_shift($this->argv));	
				}
			}
			
			if(!$optionsExists && $argsExists){

				$args[key($docList["arguments"])] = $arg;
				next($docList["arguments"]);	
			}
			
			if(!$optionsExists && !$argsExists)
				$unknowns[] = $arg;
		}

		/**
		* Validate parameters
		*/
		if(!empty($docList["usage"])){

			foreach($docList["usage"] as $param=>$usage){

				$name = trim(trim($param, "-"),"--");

				$isParamInArgs = @in_array($param, array_keys($args));

				if($isParamInArgs){

					if(empty($args[$param]))
						if($usage["input"])
							throw new \Exception(sprintf("Input required for [%s]!", $param));

					$this->args[$name] = $args[$param];
				}

				$isArgsInDocList = in_array("arguments", array_keys($docList));

				if(!$isParamInArgs && $isArgsInDocList){

					// print_r($ this->args);

					$isParamInDocList = in_array($param, array_keys($docList["arguments"]));

					if($isParamInDocList)
						if($usage["required"])
							throw new \Exception(sprintf("Argument [%s] is required!", $param));

					if($usage["required"])
						throw new \Exception(sprintf("Option [%s] is required!", $param));
				}
			}
		}

		if(!empty($unknowns))
			throw new \Exception(sprintf("Unknown parameter/input [%s]!", current($unknowns)));
	}
815284
public function run(): void
    {
        $response = $this->routes->getResponse($this->request);
        if (!($response instanceof App\Response)) {
            $response = new App\Response\NotFound();
        }
        $this->send($response);
    }
743990
public function onConstruct()
    {
        $this->userLinkedSourcesModel = new UserLinkedSources();
        $this->userModel = new Users();

        if (!isset($this->config->jwt)) {
            throw new Exception('You need to configure your app JWT');
        }
    }
882315
public function initChunks()
    {
        if (!$this->template) {
            throw new Exception(['Lister does not have default template. Either supply your own HTML or use "defaultTemplate"=>"lister.html"']);
        }

        // empty row template
        if ($this->template->hasTag('empty')) {
            $this->t_empty = $this->template->cloneRegion('empty');
            $this->template->del('empty');
        }

        // data row template
        if ($this->template->hasTag('row')) {
            $this->t_row = $this->template->cloneRegion('row');
            $this->template->del('rows');
        } else {
            $this->t_row = clone $this->template;
            $this->template->del('_top');
        }
    }
586495
public function execute()
	{
		$query  = $this->factory->builder($this->insert)->process();
		$result = $this->pdo->query($query);
		if(!$result)
		{
			throw new \Exception('An error is while the insertion occurred! (query: "' . $query . '")');
		}

		return $this->pdo->lastInsertId();
	}
489537
public function run()
    {
        $block = ob_get_clean();
        if ($this->renderInPlace) {
            throw new Exception("not implemented yet ! ");
        }
        $block = trim($block);
        $cssBlockPattern = '|^<style[^>]*>(?P<blockContent>.+?)</style>$|is';
        if (preg_match($cssBlockPattern, $block, $matches)) {
            $block = $matches['blockContent'];
        }
        $this->view->registerCss($block, $this->options, $this->key);
    }
805304
public function output() {
        $parts = explode('/', $this->output_path);
        // get rid of the filename
        array_pop($parts);

        $path = implode('/', $parts);
        if ($path && !file_exists($path)) {
            if (!mkdir($path, 0777, true)) {
                throw new \Exception("could not make directory $path");
            }
        }

        if (!file_put_contents($this->output_path, $this->render())) {
            throw new \Exception("could not write $filename");
        }
    }
1211173
public function run() {
		if ($this->url === null) {
			throw new \Exception("No URL configured for redirection.");
		}
		if (strpos($this->url, '/') === 0 || strpos($this->url, 'http://') === 0 || strpos($this->url, 'https://') === 0) {
			$url = ValueUtils::val($this->url);
		} else {
			$url = ROOT_URL.ValueUtils::val($this->url);
		}
		header("Location: ".$url);
	}
627938
public function bootstrap(): void
    {
        foreach ($this->bootstrap as $mixed) {
            $component = null;
            if ($mixed instanceof \Closure) {
                $this->debug('Bootstrap with Closure', __METHOD__);
                if (empty($component = call_user_func($mixed, $this))) {
                    continue;
                }
            } elseif (is_string($mixed)) {
                if ($this->has($mixed)) {
                    $component = $this->get($mixed);
                } elseif ($this->hasModule($mixed)) {
                    $component = $this->getModule($mixed);
                } elseif (strpos($mixed, '\\') === false) {
                    throw new InvalidConfigException("Unknown bootstrapping component ID: $mixed");
                }
            }

            if (!isset($component)) {
                $component = $this->createObject($mixed);
            }

            if ($component instanceof BootstrapInterface) {
                $this->debug('Bootstrap with ' . get_class($component) . '::bootstrap()', __METHOD__);
                $component->bootstrap($this);
            } else {
                $this->debug('Bootstrap with ' . get_class($component), __METHOD__);
            }
        }
    }
223574
public function execAction()
    {
        //no action defined
        if(!$this->action) {
            throw new \Exception(sprintf('no action defined for subject %s', $this->name));
        }
        //exec method
        try {
            $this->checkTraitsInjections();
            $this->traitsInit();
            $this->{'exec'.$this->sanitizeAction($this->action)}();
        } catch(Exception $exception) {
        //no method defined
            throw new Exception(sprintf('no method for handling %s %s %s', AREA, $this->name, $this->action));
        }
    }
624469
public function run()
    {
        /** @var Model $model */
        $model = $this->model;
        $options = $this->options;
        unset($options['id']);

        // Add model meta
        $modelClassName = $model::className();
        $modelMeta = $model::meta();
        if (\Yii::$app->has('frontendState')) {
            \Yii::$app->frontendState->set('config.types.metas.' . $modelClassName, $modelMeta);
        } else {
            $jsArgs = [Json::encode($modelClassName), Json::encode($modelMeta)];
            \Yii::$app->view->registerJs('__appTypes.addModelMeta(' . implode(', ', $jsArgs) . ')', View::POS_END, 'app-form-' . $model::className());
        }

        // Add enums
        foreach ($model::meta() as $item) {
            if (!empty($item['enumClassName'])) {
                /** @var Enum $enumClass */
                $enumClass = $item['enumClassName'];
                $enumClassName = $enumClass::className();
                $props = [
                    'labels' => $enumClass::getLabels(),
                ];

                if (\Yii::$app->has('frontendState')) {
                    \Yii::$app->frontendState->set('config.types.enums.' . $enumClassName, $props);
                } else {
                    $jsArgs = [Json::encode($enumClassName), Json::encode($props)];
                    \Yii::$app->view->registerJs('__appTypes.addEnum(' . implode(', ', $jsArgs) . ')', View::POS_END, 'app-enum-' . $enumClass::className());
                }
            }
        }

        // Render field
        $props = array_merge([
            'formId' => $this->field ? $this->field->form->id : 'f' . ++self::$idCounter,
            'model' => $model::className(),
            'prefix' => $model->formName(),
            'attribute' => Html::getAttributeName($this->attribute),
        ], $options);
        if (\Yii::$app->has('frontendState')) {
            \Yii::$app->frontendState->add('config.types.toRenderField', [$this->id, $props]);
        } else {
            $jsArgs = [Json::encode($this->id), Json::encode($props)];
            \Yii::$app->view->registerJs('__appTypes.renderField(' . implode(', ', $jsArgs) . ')', View::POS_END, $this->id);
        }
        return Html::tag('span', '', ['id' => $this->id]);
    }
650442
public function init()
    {
        $this->header('Content-Type: text/html'); // default header.

        $this->proc = new \PHPDaemon\Core\ShellCommand();
        $this->proc->readPacketSize = $this->appInstance->readPacketSize;
        $this->proc->onReadData([$this, 'onReadData']);
        $this->proc->onWrite([$this, 'onWrite']);
        $this->proc->binPath = $this->appInstance->binPath;
        $this->proc->chroot = $this->appInstance->chroot;

        if (isset($this->attrs->server['BINPATH'])) {
            if (isset($this->appInstance->binAliases[$this->attrs->server['BINPATH']])) {
                $this->proc->binPath = $this->appInstance->binAliases[$this->attrs->server['BINPATH']];
            } elseif ($this->appInstance->config->allowoverridebinpath->value) {
                $this->proc->binPath = $this->attrs->server['BINPATH'];
            }
        }

        if (isset($this->attrs->server['CHROOT']) && $this->appInstance->config->allowoverridechroot->value) {
            $this->proc->chroot = $this->attrs->server['CHROOT'];
        }

        if (isset($this->attrs->server['SETUSER']) && $this->appInstance->config->allowoverrideuser->value) {
            $this->proc->setUser = $this->attrs->server['SETUSER'];
        }

        if (isset($this->attrs->server['SETGROUP']) && $this->appInstance->config->allowoverridegroup->value) {
            $this->proc->setGroup = $this->attrs->server['SETGROUP'];
        }

        if (isset($this->attrs->server['CWD']) && $this->appInstance->config->allowoverridecwd->value) {
            $this->proc->cwd = $this->attrs->server['CWD'];
        } elseif ($this->appInstance->config->cwd->value !== null) {
            $this->proc->cwd = $this->appInstance->config->cwd->value;
        } else {
            $this->proc->cwd = dirname($this->attrs->server['SCRIPT_FILENAME']);
        }

        $this->proc->setArgs([$this->attrs->server['SCRIPT_FILENAME']]);
        $this->proc->setEnv($this->attrs->server);
        $this->proc->execute();
    }
612412
public function logException(\Exception $exception)
    {
        $this->logError('Error: ' . get_class($exception) . ' - ' . $exception->getMessage() . ' (Code: ' . $exception->getCode() . ')');
        $this->logError('File: ' . $exception->getFile() . ' / Line: ' . $exception->getLine());
    }
922510
public function run() {
        try {
            $this->command->execute($this->console, $this->parser->getArguments());
        } catch (\Exception $e) {
            $this->writeException($e);
            if ($this->exitOnException) {
                exit($e->getCode() ? : 1);
            }
            throw $e;
        }
    }
602342
public function init() {
        if (VERBOSE) echo 'INIT:' ,PHP_EOL;
        if (VERBOSE) echo ' CONNECTING API' ,PHP_EOL;
        $this->api->auth();
        if (VERBOSE) echo ' API CONNECTED' ,PHP_EOL;
        if (VERBOSE) echo ' CONNECTING SQL' ,PHP_EOL;
        $this->db->connect();
        if (VERBOSE) echo ' SQL CONNECTED' ,PHP_EOL;
        if (VERBOSE) echo ' CHECKING PATHS' ,PHP_EOL;
        if (DEBUG) echo '  CHECKING TMP DIR AT : '.$this->tmp_dir ,PHP_EOL;
        if (!file_exists($this->tmp_dir)) {
            throw new Exception("Path for 'tmp_dir' not found at '".$this->tmp_dir."'!");
        }
        if (DEBUG) echo '  CHECKING DUMP DIR AT : '.$this->dumps_dir ,PHP_EOL;
        if (!file_exists($this->dumps_dir)) {
            throw new Exception("Path for 'dumps_dir' not found at '".$this->dumps_dir."'!");
        }
        if (VERBOSE) echo ' PATHS FOUND' ,PHP_EOL;
    }
522504
public function flush()
    {
        if (!$this->getClient()->flush()) {
            throw new \Exception($this->getClient()->getResultMessage(), $this->getClient()->getResultCode());
        }
    }
263219
public function run()
    {
        $this->convertTo->setData($this->convertFrom->getData());
        $this->convertTo->write();
    }