/** * Renders the second part of the fatal error handler. * * @param string $type * The type of the error (should always be fatal). * @param string $errstr * The string from the error. * @param string $errfile * The file where the error occurred. * @param int $errline * The line number where the error occurred. * * @return string * The template file, with all markers replaced. */ public function renderFatalMain($type, $errstr, $errfile, $errline) { $template = $this->getTemplateFileContent('fatalMain'); $from = $errline - 5; $to = $errline + 5; $source = $this->storage->readSourcecode($errfile, $errline - 1, $from - 1, $to - 1); // Insert our values. $template = str_replace('{type}', $type, $template); $template = str_replace('{errstr}', $errstr, $template); $template = str_replace('{file}', $errfile, $template); $template = str_replace('{source}', $source, $template); $template = str_replace('{KrexxCount}', $this->storage->emergencyHandler->getKrexxCount(), $template); return str_replace('{line}', $errline, $template); }
/** * Analyses a closure. * * @param Model $model * The closure we want to analyse. * * @return string * The generated markup. */ public function analyseClosure(Model $model) { $ref = new \ReflectionFunction($model->getData()); $result = array(); // Adding comments from the file. $methodclass = new ThroughMethods($this->storage); $result['comments'] = $methodclass->prettifyComment($ref->getDocComment()); // Adding the sourcecode $highlight = $ref->getStartLine() - 1; $from = $highlight - 3; $to = $ref->getEndLine() - 1; $file = $ref->getFileName(); $result['source'] = $this->storage->readSourcecode($file, $highlight, $from, $to); // Adding the place where it was declared. $result['declared in'] = $ref->getFileName() . "\n"; $result['declared in'] .= 'in line ' . $ref->getStartLine(); // Adding the namespace, but only if we have one. $namespace = $ref->getNamespaceName(); if (!empty($namespace)) { $result['namespace'] = $namespace; } // Adding the parameters. $parameters = $ref->getParameters(); $paramList = ''; foreach ($parameters as $parameter) { preg_match('/(.*)(?= \\[ )/', $parameter, $key); $parameter = str_replace($key[0], '', $parameter); $result[$key[0]] = trim($parameter, ' []'); $paramList .= trim($result[$key[0]]) . ', '; } $paramList = str_replace(array('<required> ', '<optional> '), '', $this->storage->encodeString($paramList)); // Remove the ',' after the last char. $paramList = '<small>' . trim($paramList, ', ') . '</small>'; $model->setType($model->getAdditional() . ' closure')->setAdditional('. . .')->setConnector2($model->getConnector2() . '(' . $paramList . ')')->setDomid($this->generateDomIdFromObject($model->getData()))->addParameter('data', $result)->initCallback('Iterate\\ThroughMethodAnalysis'); return $this->storage->render->renderExpandableChild($model); }