public function generateDump(Route $route, AdapterInterface $console) { $configFile = $route->getMatchedParam('config'); $outputFile = $route->getMatchedParam('output_file'); $strip = (bool) $route->getMatchedParam('strip'); $console->writeLine("Generating class cache from {$configFile} into {$outputFile}"); if (!file_exists($configFile)) { throw new RuntimeException("Configuration file does not exist: {$configFile}"); } $classes = (include $configFile); if (!is_array($classes)) { throw new RuntimeException("Configuration file does not contain array of class names"); } if (!file_exists(dirname($outputFile))) { mkdir(dirname($outputFile), 0777, true); } $dumper = new ClassDumper(); $cache = $dumper->dump($classes, $strip); file_put_contents($outputFile, "<?php\n" . $cache); }
public function testDumpSkipsInternalClasses() { $dumper = new ClassDumper(); $classes = [RuntimeException::class]; $cache = $dumper->dump($classes); $this->assertEquals('namespace UserLib\\Exception { class RuntimeException extends \\RuntimeException { } } ', $cache); }