public function scanRoutes($path) { $routes = []; $latte = new Latte\Engine(); $macroSet = new Latte\Macros\MacroSet($latte->getCompiler()); $macroSet->addMacro('url', function ($node) use(&$routes, &$file) { $routes[$node->args] = (string) $file; }, NULL, NULL, $macroSet::ALLOWED_IN_HEAD); foreach (Nette\Utils\Finder::findFiles('*.latte')->from($path) as $file) { $latte->compile($file); } return $routes; }
$checker->tasks[] = function (CodeChecker $checker, $s) { if ($checker->is('php,phpt')) { $tmp = rtrim($s); if (substr($tmp, -2) === '?>') { $checker->fix('contains closing PHP tag ?>'); return substr($tmp, 0, -2); } } }; // lint Latte templates $checker->tasks[] = function (CodeChecker $checker, $s) { if ($checker->is('latte')) { try { $latte = new Latte\Engine(); $latte->setLoader(new Latte\Loaders\StringLoader()); $latte->compile($s); } catch (Latte\CompileException $e) { if (!preg_match('#Unknown (macro|attribute)#A', $e->getMessage())) { $checker->error($e->getMessage(), $e->sourceLine); } } } }; // lint Neon $checker->tasks[] = function (CodeChecker $checker, $s) { if ($checker->is('neon')) { try { Nette\Neon\Neon::decode($s); } catch (Nette\Neon\Exception $e) { $checker->error($e->getMessage()); }