{@inheritdoc}

@see http://davidbu.ch/mann/blog/2014-05-06/open-php-stack-trace-links-phpstorm.html
@see https://github.com/bcremer/phpstorm-url-handler-PKGBUILD
@see https://github.com/aik099/PhpStormProtocol
559582
public function render(\Throwable $exception, int $index) : string
    {
        $stacks = $this->exceptionStackTrace($exception);

        foreach ($stacks as &$stack) {
            if (isset($stack['file'])) {
                $stack['file'] = self::mapPath($stack['file']);
            }
        }

        $out = '';

        $out .= "\033[1;37m" . // white foreground
            "\033[41m #$index >>>> " . // red background
            $exception->getMessage() .
            "\033[0m\n";

        $out .= "\033[41mType:\033[0;31m " . // light red foreground
            get_class($exception) .
            "\033[0m\n";

        $out .= "\033[41mCode:\033[0;33m " . // brown foreground
            $exception->getCode() .
            "\033[0m\n";

        $out .= "\033[41mFile:\033[0;32m " . // green foreground
            $stacks[0]['file'] .
            "\033[0m";

        if (isset($stacks[0]['line'])) {
            $out .= ':' .
                "\033[0;35m" . // red foreground
                $stacks[0]['line'] .
                "\033[0m";
        }
        $out .= "\n\n";

        $stackTxt = '';
        foreach ($stacks as $index => $stack) {
            $stackTxt .= '  at ';
            if ($type = $this->getType($stack)) {
                $stackTxt .= "\033[0;36m" . // light gray foreground
                    $type . ' ' .
                    "\033[0m";
            }

            if (isset($stack['args'])) {
                $stackTxt .= "\033[0;37m" . // light gray foreground
                    $stack['args'] .
                    "\033[0m";
            }

            $stackTxt .= "\033[0;32m" . // green foreground
                $stack['file'] .
                "\033[0m";

            if (isset($stack['line'])) {
                $stackTxt .= ':' .
                    "\033[0;35m" . // red foreground
                    $stack['line'] .
                    "\033[0m";
            }

            $stackTxt .= "\n";
        }

        $stackTxt .= "\n";

        $data = [
            'message' => $exception->getMessage(),
            'code' => $exception->getCode(),
            'file' => $stacks[0]['file'],
            'stack' => $stackTxt,
        ];

        if (isset($stacks[0]['line'])) {
            $data['line'] = $stacks[0]['line'];
        }

        return $out . $stackTxt;
    }
14654
private function callApiTokens()
    {
        $result = $this->callApi('action=tokens&type=edit');
        if (false == isset($result['tokens']) || false == isset($result['tokens']['edittoken'])) {
            throw new BuildException('Wiki token not found');
        }

        $this->apiEditToken = $result['tokens']['edittoken'];
    }
337162
public function main()
    {
        $buffer = '';
        $registry = GeneralUtility::makeInstance('KayStrobach\Dyncss\Configuration\BeRegistry');
        $handlers = $registry->getAllFileHandler();
        if (count($handlers)) {
            foreach ($handlers as $extension => $class) {
                /** @var AbstractParser $parser */
                $parser = new $class();
                $buffer .= '<tr><td>*.'.$extension.'</td>';
                $buffer .= '<td>'.$class.'</td>';
                $buffer .= '<td><a href="'.$parser->getParserHomepage().'" target="_blank">'.$parser->getParserName().'</a></td>';
                $buffer .= '<td>'.$parser->getVersion().'</td>';
                $buffer .= '</tr>';
            }
            /** @var FlashMessage $flashMessage */
            $flashMessage = GeneralUtility::makeInstance(
                FlashMessage::class,
                'Congrats, you have '.count($handlers).' handlers registered.',
                '',
                FlashMessage::OK,
                true
            );
            $this->addFlashMessage($flashMessage);
            $buffer = '<table class="t3-table table"><thead><tr><th>extension</th><th>class</th><th>name</th><th>version</th></tr></thead>'.$buffer.'</table>';
        } else {
            /** @var FlashMessage $flashMessage */
            $flashMessage = GeneralUtility::makeInstance(
                FlashMessage::class,
                'Please install one of the dyncss_* extensions',
                'No handler registered! - No dynamic css is handled at all ;/',
                FlashMessage::WARNING,
                true
            );
            $this->addFlashMessage($flashMessage);
            return $this->renderFlashMessage();
        }
        $renderedFlashMessages = $this->renderFlashMessage();
        return $renderedFlashMessages . $buffer;
    }
990947
protected function build()
    {
        $closure = $this['closure'];
        /** @var $closure \Closure */
        $this->request = $closure($this, $this->operation);

        if (!$this->request || !$this->request instanceof RequestInterface) {
            throw new UnexpectedValueException('Closure command did not return a RequestInterface object');
        }
    }
282749
public function build()
    {
        $this->debug->groupCollapsed(__METHOD__);
        $this->debug->groupUncollapse();
        $str = '';
        $cfg = $this->form->cfg;
        $status = $this->form->status;
        // $printOpts   = $cfg['output'];
        // $this->debug->log('cfg', $cfg);
        $this->debug->log('status', $status);
        $strAlerts = \is_callable($cfg['buildAlerts'])
            ? \call_user_func_array($cfg['buildAlerts'], array($this->form))
            : '';
        if ($status['error']) {
            $str = $strAlerts
                .$cfg['messages']['error'];
        } elseif ($status['completed']) {
            $str = $strAlerts
                .$cfg['messages']['completed'];
        } elseif ($cfg['buildOutput']) {
            // $this->debug->warn('have buildOutput');
            $this->outputSetup();
            if (\is_callable($cfg['buildOutput'])) {
                $str = \call_user_func_array($cfg['buildOutput'], array($this->form));
            }
            if (empty($str)) {
                $this->debug->info('buildOutput callback didn\'t generate anything');
                $str = $this->buildOutput($this->form);
            }
            $str = $strAlerts
                .$this->buildHiddenFields()
                .$str;
            $str = $this->form->eventManager->publish(
                'form.buildOutput',
                $this->form,
                array('output'=>$str)
            )->getValue('output');
            if ($cfg['output']['formWrap']) {
                $attribs = $cfg['attribs'];
                if (empty($attribs['action'])) {
                    $attribs['action'] = Html::getSelfUrl();
                }
                if ($status['multipart']) {
                    $attribs['enctype'] = 'multipart/form-data';
                }
                if (\strtolower($attribs['method']) == 'get') {
                    $urlParts = \parse_url(\html_entity_decode($attribs['action']));
                    $attribs['action'] = $urlParts['path'];
                }
                #$this->debug->log('form attribs', $attribs);
                $str = '<form'.Html::buildAttribString($attribs).'>'."\n"
                    .$str
                    .'</form>'."\n";
            }
            if ($cfg['output']['filepathScript'] && \file_exists($cfg['output']['filepathScript'])) {
                $str .= '<script type="text/javascript">'
                    .\file_get_contents($cfg['output']['filepathScript'])
                    .'</script>';
            }
            if ($cfg['output']['reqDepJs']) {
                $outputScript = new OutputScript($this->form);
                $str .= $outputScript->build()."\n";
            }
        }
        $this->debug->groupEnd();
        return $str;
    }
636437
public function phpLint()
    {
        $paths = $this->getPaths();
        $this->stopOnFail(true);
        $this->info('Starting syntax check of PHP source files');
        $iterator = Finder::create()
            ->files()
            ->name('*.php')
            ->in($paths['src'])
            ->sortByName();
        /** @var SplFileInfo $file */
        foreach ($iterator as $file) {
            $command = $this->taskExec('php');
            $command
                ->arg('-l')
                ->arg($file->getRealPath())
                ->printOutput(false)
                ->run();
        }
        $this->info('PHP source files passed syntax check');
    }
474792
public function call() {
    /**
     * Finds overridable Application Model (default -> Named Application -> annotated 'option ApplicationModel')
     * There can only be one.
     *
     * @var $applicationModelClass \MABI\Model
     */
    $applicationModelClass = '\MABI\DefaultApplicationModel';

    $mabi = $this->getApp();

    $modelClasses = $mabi->getModelClasses();
    foreach ($modelClasses as $modelClass) {
      if (ReflectionHelper::stripClassName($modelClass) == 'Application') {
        $applicationModelClass = $modelClass;
      }

      $rClass = new \ReflectionClass($modelClass);
      $modelOptions = ReflectionHelper::getDocDirective($rClass->getDocComment(), 'model');
      if (in_array('ApplicationModel', $modelOptions)) {
        $applicationModelClass = $modelClass;
        break;
      }
    }

    // Find the shared secret property (named sharedSecret or annotated 'field SharedSecret')
    $rClass = new \ReflectionClass($applicationModelClass);
    $modelProps = $rClass->getProperties(\ReflectionProperty::IS_PUBLIC);
    $sharedSecretProp = 'sharedSecret';
    foreach ($modelProps as $modelProp) {
      $rProp = new \ReflectionProperty($applicationModelClass, $modelProp->name);
      $propOptions = ReflectionHelper::getDocDirective($rProp->getDocComment(), 'field');
      if (in_array('SharedSecret', $propOptions)) {
        $sharedSecretProp = $modelProp->name;
        break;
      }
    }

    $this->apiApplication = $applicationModelClass::init($mabi);
    if (!$this->apiApplication->findByField($sharedSecretProp, $mabi->getRequest()->headers('SHARED-SECRET'))) {
      $this->apiApplication = FALSE;
    }
    $mabi->getRequest()->apiApplication = $this->apiApplication;

    if (!empty($this->next)) {
      $this->next->call();
    }
  }
102785
protected function generatePhpStormIdeHelperOutput()
    {
        $smarty = $this->getSmarty();
        $smarty->assign('moduleParentClasses', $this->moduleExtendClassMapProvider->getModuleParentClassMap());
        $output = $smarty->fetch('phpstorm.meta.php.tpl');

        return $output;
    }
512763
function callHook() {
		global $default; // Should take care of this later.
		$queryString = array();

		if (!isset($this->url)) {

			$controller = $this->routes['default']['controller'];
			$action = $this->routes['default']['action'];
		} else {
			//print "URL: " . $this->url . "<br>";
			$this->routeURL(); // Replace the URL with something else based on preg_matches defined in the routing
			//print "URL: " . $this->url . "<br>";
			$urlArray = array();
			$urlArray = explode("/",$this->url);
			$controller = $urlArray[0];
			array_shift($urlArray); // Pop the first element
			if (!$controller){
				$controller="index";  // Default Controller
			}

			if (isset($urlArray[0])) {
				$action = $urlArray[0];
				array_shift($urlArray); // pop the second element
			} else {
				$action = 'index'; // Default Action
			}
			$queryString = $urlArray;
		}

		$controllerName = ucfirst($controller).'Controller';
		//print "Calling $controllerName with $controller and $action at ";
		$this->runControllerAction($controller, $action, $queryString, $controllerName, $action);

	}
1182209
public function main()
    {
        if ($this->name !== null) {
            if ($this->value === null && $this->reference === null) {
                throw new BuildException(
                    "You must specify value or refid with the name attribute",
                    $this->getLocation()
                );
            }
        } else {
            if ($this->file === null && $this->env === null) {
                throw new BuildException(
                    "You must specify file or environment when not using the name attribute",
                    $this->getLocation()
                );
            }
        }

        if ($this->file === null && $this->prefix !== null) {
            throw new BuildException("Prefix is only valid when loading from a file.", $this->getLocation());
        }

        if (($this->name !== null) && ($this->value !== null)) {
            $this->addProperty($this->name, $this->value);
        }

        if ($this->file !== null) {
            $this->loadFile($this->file);
        }

        if ($this->env !== null) {
            $this->loadEnvironment($this->env);
        }

        if (($this->name !== null) && ($this->reference !== null)) {
            // get the refereced property
            try {
                $referencedObject = $this->reference->getReferencedObject($this->project);

                if ($referencedObject instanceof Exception) {
                    $reference = $referencedObject->getMessage();
                } else {
                    $reference = (string) $referencedObject;
                }

                $this->addProperty($this->name, $reference);
            } catch (BuildException $be) {
                if ($this->fallback !== null) {
                    $referencedObject = $this->reference->getReferencedObject($this->fallback);

                    if ($referencedObject instanceof Exception) {
                        $reference = $referencedObject->getMessage();
                    } else {
                        $reference = (string) $referencedObject;
                    }
                    $this->addProperty($this->name, $reference);
                } else {
                    throw $be;
                }
            }
        }
    }
56639
public function beforeCompile(): void
	{
		$builder = $this->getContainerBuilder();

		// Idea by @enumag
		// https://github.com/Arachne/EventManager/blob/master/src/DI/EventManagerExtension.php

		$eventManager = $builder->getDefinition($this->prefix('eventManager'));
		foreach ($builder->findByTag(self::TAG_NETTRINE_SUBSCRIBER) as $serviceName => $tag) {
			$serviceName = (string) $serviceName; // nette/di 2.4 allows numeric names, which are converted to integers
			$class = $builder->getDefinition($serviceName)->getType();

			if ($class === null || !is_subclass_of($class, EventSubscriber::class)) {
				throw new AssertionException(
					sprintf(
						'Subscriber "%s" doesn\'t implement "%s".',
						$serviceName,
						EventSubscriber::class
					)
				);
			}
			$eventManager->addSetup(
				'?->addEventListener(?, ?)',
				[
					'@self',
					call_user_func([(new ReflectionClass($class))->newInstanceWithoutConstructor(), 'getSubscribedEvents']),
					$serviceName, // Intentionally without @ for laziness.
				]
			);
		}
	}
991117
function xmlDefaultHandler($parser,$data)
		{
			//strip '<!--' and '-->' off comments
			$data = repl(array("&lt;!--", "--&gt;"), "", htmlspecialchars($data));
			$count = $this->xmlCount - 1;
			if(!empty($this->xmlDData[$count])) $this->xmlDData[$count] .= $data;
			else $this->xmlDData[$count] = $data;
		}
683135
protected function parse()
    {
        try {
            // get parse context
            $ctx = $this->project->getReference(self::PARSING_CONTEXT_REFERENCE);
            if (null == $ctx) {
                // make a new context and register it with project
                $ctx = new PhingXMLContext($this->project);
                $this->project->addReference(self::PARSING_CONTEXT_REFERENCE, $ctx);
            }

            //record this parse with context
            $ctx->addImport($this->buildFile);

            if (count($ctx->getImportStack()) > 1) {
                $currentImplicit = $ctx->getImplicitTarget();
                $currentTargets = $ctx->getCurrentTargets();

                $newCurrent = new Target();
                $newCurrent->setProject($this->project);
                $newCurrent->setName('');
                $ctx->setCurrentTargets([]);
                $ctx->setImplicitTarget($newCurrent);

                // this is an imported file
                // modify project tag parse behavior
                $this->setIgnoreProjectTag(true);
                $this->_parse($ctx);
                $newCurrent->main();

                $ctx->setImplicitTarget($currentImplicit);
                $ctx->setCurrentTargets($currentTargets);
            } else {
                $ctx->setCurrentTargets([]);
                $this->_parse($ctx);
                $ctx->getImplicitTarget()->main();
            }
        } catch (Exception $exc) {
            //throw new BuildException("Error reading project file", $exc);
            throw $exc;
        }
    }
933425
public function main()
    {
        $exc = null;

        if (empty($this->tryContainer)) {
            throw new BuildException('A nested <try> element is required');
        }

        try {
            $this->tryContainer->perform();
        } catch (BuildException $e) {
            if (!empty($this->propertyName)) {
                $this->project->setProperty($this->propertyName, $e->getMessage());
            }

            if (!empty($this->referenceName)) {
                $this->project->addReference($this->referenceName, $e);
            }

            if (!empty($this->catchContainer)) {
                $this->catchContainer->perform();
            } else {
                $exc = $e;
            }
        }

        if (!empty($this->finallyContainer)) {
            $this->finallyContainer->perform();
        }

        if (!empty($exc)) {
            throw $exc;
        }
    }
953871
public function attach($hook, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null)
    {
        $module_id = null;

        if (strpos($hook, '|') !== false) {
            list($hook, $module_id) = explode('|', $hook, 2);
        }

        $method = $this->getMethod($hook);

        if (isset($module_id)) {
            $class = $this->module->getClass($module_id);
            return $this->call($class, $method, $a, $b, $c, $d, $e);
        }

        if (empty($this->hooks[$method])) {
            return false;
        }

        foreach (array_keys($this->hooks[$method]) as $class) {
            $this->call($class, $method, $a, $b, $c, $d, $e);
        }

        return true;
    }
246732
function compile( $path = null  ){	
		
		// process as root script if path not passed
		$isroot = is_null($path);
		if( $isroot ){
			$path = $this->path;
			$this->incs = array();
			$this->dependencies = array();
		}
		
		// compile initial source for top-level file
		// 
		$this->inphp = false;
		$this->lasttoken = null;
		$src = $this->compile_php( $path, null, $isroot );

		// second pass to replace constants with literals if option set
		//
		if( $this->opt(COMPILER_OPTION_LITERALS)  ){
			$tokens = token_get_all( $src );
			$src = '';
			do {
				$tok = current( $tokens );
				$s = is_array($tok) ? $tok[1] : $tok;
				if( is_array($tok) && T_STRING === $tok[0] ){
					$c = $tok[1];
					if( isset($this->conf_consts[$c]) ){
						// replace current definition with target config value
						$s = var_export( $this->conf_consts[$c], 1 );
					}
					else if( defined($c) && $this->opt(COMPILER_OPTION_LITERALS_SYS) ){
						// WARNING: extension constants could differ on target environment
						$s = var_export( constant($c), 1 );
					}
				}
				$src .= $s;
			}
			while( next($tokens) !== false );
		}

		
		// bytecode compilation with bcompiler extension
		//
		if( $this->opt(COMPILER_OPTION_BYTECODE) ){
			// extension can only operate on files
			$srcpath = tempfile( $stdin, null );
			file_put_contents( $srcpath, $src );
			unset( $src );
			// run via shell due to conflict bugs in bcompiler
			PLUG::exec_bin( 'bcompile', array($srcpath), $src );
		}
		
		return $src;
	}
6621
public function renderTreeSitesModalFormHandlerAction()
    {
        $data = array();
    
        $sourcePageId = (int) $this->params()->fromQuery('sourcePageId', '');
        
        $melisKey = $this->params()->fromRoute('melisKey', '');
        // declare the Tool service that we will be using to completely create our tool.
        $melisTool = $this->getServiceLocator()->get('MelisCoreTool');
        $melisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
        $appConfigForm = $melisCoreConfig->getFormMergedAndOrdered('meliscms/tools/meliscms_tree_sites_tool/forms/meliscms_tree_sites_duplicate_tree_form','meliscms_tree_sites_duplicate_tree_form');
        $factory = new \Zend\Form\Factory();
        $formElements = $this->serviceLocator->get('FormElementManager');
        $factory->setFormElementManager($formElements);
        $form = $factory->createForm($appConfigForm);
        
        $data = array(
            'sourcePageId' => $sourcePageId  
        );
        
        $form->setData($data);
        
        $view = new ViewModel();
        $view->melisKey = $melisKey;
        $view->form = $form;
        $view->sourcePageId = $sourcePageId;
        return $view;
    }