public function __construct($iterator = null, array $config = array()) { parent::__construct(); $sc = $this; if (null !== $iterator) { $this['files'] = $iterator; } $this['_versions'] = function ($sc) { $versions = isset($sc['versions']) ? $sc['versions'] : $sc['version']; if (is_string($versions)) { $versions = new Version($versions); } if ($versions instanceof Version) { $versions = new SingleVersionCollection($versions); } return $versions; }; $this['project'] = function ($sc) { $project = new Project($sc['store'], $sc['_versions'], array('build_dir' => $sc['build_dir'], 'cache_dir' => $sc['cache_dir'], 'remote_repository' => $sc['remote_repository'], 'simulate_namespaces' => $sc['simulate_namespaces'], 'include_parent_data' => $sc['include_parent_data'], 'default_opened_level' => $sc['default_opened_level'], 'theme' => $sc['theme'], 'title' => $sc['title'], 'source_url' => $sc['source_url'], 'source_dir' => $sc['source_dir'])); $project->setRenderer($sc['renderer']); $project->setParser($sc['parser']); return $project; }; $this['parser'] = function ($sc) { return new Parser($sc['files'], $sc['store'], $sc['code_parser'], $sc['traverser']); }; $this['indexer'] = function () { return new Indexer(); }; $this['tree'] = function () { return new Tree(); }; $this['parser_context'] = function ($sc) { return new ParserContext($sc['filter'], $sc['docblock_parser'], $sc['pretty_printer']); }; $this['docblock_parser'] = function () { return new DocBlockParser(); }; $this['php_parser'] = function () { return new PhpParser(new Lexer()); }; $this['php_traverser'] = function ($sc) { $traverser = new NodeTraverser(); $traverser->addVisitor(new NameResolver()); $traverser->addVisitor(new NodeVisitor($sc['parser_context'])); return $traverser; }; $this['code_parser'] = function ($sc) { return new CodeParser($sc['parser_context'], $sc['php_parser'], $sc['php_traverser']); }; $this['pretty_printer'] = function () { return new PrettyPrinter(); }; $this['filter'] = function () { return new DefaultFilter(); }; $this['store'] = function () { return new JsonStore(); }; $this['renderer'] = function ($sc) { return new Renderer($sc['twig'], $sc['themes'], $sc['tree'], $sc['indexer']); }; $this['traverser'] = function ($sc) { $visitors = array(new ClassVisitor\InheritdocClassVisitor(), new ClassVisitor\MethodClassVisitor(), new ClassVisitor\PropertyClassVisitor()); if ($sc['remote_repository'] instanceof AbstractRemoteRepository) { $visitors[] = new ClassVisitor\ViewSourceClassVisitor($sc['remote_repository']); } return new ClassTraverser($visitors); }; $this['themes'] = function ($sc) { $templates = $sc['template_dirs']; $templates[] = __DIR__ . '/Resources/themes'; return new ThemeSet($templates); }; $this['twig'] = function () { $twig = new \Twig_Environment(new \Twig_Loader_Filesystem(array('/')), array('strict_variables' => true, 'debug' => true, 'auto_reload' => true, 'cache' => false)); $twig->addExtension(new TwigExtension()); return $twig; }; $this['theme'] = 'default'; $this['title'] = 'API'; $this['version'] = 'master'; $this['template_dirs'] = array(); $this['build_dir'] = getcwd() . '/build'; $this['cache_dir'] = getcwd() . '/cache'; $this['remote_repository'] = null; $this['source_dir'] = ''; $this['source_url'] = ''; $this['default_opened_level'] = 2; // simulate namespaces for projects based on the PEAR naming conventions $this['simulate_namespaces'] = false; // include parent properties and methods on class pages $this['include_parent_data'] = true; foreach ($config as $key => $value) { $this[$key] = $value; } }