/** * Registers services on the given app. * * @param Application $app An Application instance. * * @throws Exception\MissingDependencyException if the application does not have a descriptor.builder service. * @throws Exception\MissingDependencyException if the application does not have a serializer service. */ public function register(Application $app) { if (!isset($app['descriptor.builder'])) { throw new Exception\MissingDependencyException('The builder object that is used to construct the ProjectDescriptor is missing'); } if (!isset($app['serializer'])) { throw new Exception\MissingDependencyException('The serializer object that is used to read the template configuration with is missing'); } // parameters $app['linker.substitutions'] = array('phpDocumentor\\Descriptor\\ProjectDescriptor' => array('files'), 'phpDocumentor\\Descriptor\\FileDescriptor' => array('tags', 'classes', 'interfaces', 'traits', 'functions', 'constants'), 'phpDocumentor\\Descriptor\\ClassDescriptor' => array('tags', 'parent', 'interfaces', 'constants', 'properties', 'methods', 'usedTraits'), 'phpDocumentor\\Descriptor\\InterfaceDescriptor' => array('tags', 'parent', 'constants', 'methods'), 'phpDocumentor\\Descriptor\\TraitDescriptor' => array('tags', 'properties', 'methods', 'usedTraits'), 'phpDocumentor\\Descriptor\\FunctionDescriptor' => array('tags', 'arguments'), 'phpDocumentor\\Descriptor\\MethodDescriptor' => array('tags', 'arguments'), 'phpDocumentor\\Descriptor\\ArgumentDescriptor' => array('types'), 'phpDocumentor\\Descriptor\\PropertyDescriptor' => array('tags', 'types'), 'phpDocumentor\\Descriptor\\ConstantDescriptor' => array('tags', 'types'), 'phpDocumentor\\Descriptor\\Tag\\ParamDescriptor' => array('types'), 'phpDocumentor\\Descriptor\\Tag\\ReturnDescriptor' => array('types'), 'phpDocumentor\\Descriptor\\Tag\\SeeDescriptor' => array('reference'), 'phpDocumentor\\Descriptor\\Type\\CollectionDescriptor' => array('baseType', 'types', 'keyTypes')); // services $app['compiler'] = $app->share(function ($container) { $compiler = new Compiler(); $compiler->insert(new ElementsIndexBuilder(), ElementsIndexBuilder::COMPILER_PRIORITY); $compiler->insert(new MarkerFromTagsExtractor(), MarkerFromTagsExtractor::COMPILER_PRIORITY); $compiler->insert(new ExampleTagsEnricher($container['parser.example.finder']), ExampleTagsEnricher::COMPILER_PRIORITY); $compiler->insert(new PackageTreeBuilder(), PackageTreeBuilder::COMPILER_PRIORITY); $compiler->insert(new NamespaceTreeBuilder(), NamespaceTreeBuilder::COMPILER_PRIORITY); $compiler->insert(new ResolveInlineLinkAndSeeTags($container['transformer.routing.queue']), ResolveInlineLinkAndSeeTags::COMPILER_PRIORITY); $compiler->insert($container['linker'], Linker::COMPILER_PRIORITY); $compiler->insert($container['transformer'], Transformer::COMPILER_PRIORITY); $compiler->insert(new Debug($container['monolog'], $container['descriptor.analyzer']), Debug::COMPILER_PRIORITY); return $compiler; }); $app['linker'] = $app->share(function ($app) { return new Linker($app['linker.substitutions']); }); $app['transformer.behaviour.collection'] = $app->share(function () { return new Behaviour\Collection(); }); $app['transformer.routing.standard'] = $app->share(function ($container) { /** @var ProjectDescriptorBuilder $projectDescriptorBuilder */ $projectDescriptorBuilder = $container['descriptor.builder']; return new Router\StandardRouter($projectDescriptorBuilder); }); $app['transformer.routing.external'] = $app->share(function ($container) { return new Router\ExternalRouter($container['config']); }); $app['transformer.routing.queue'] = $app->share(function ($container) { $queue = new Router\Queue(); // TODO: load from app configuration instead of hardcoded $queue->insert($container['transformer.routing.external'], 10500); $queue->insert($container['transformer.routing.standard'], 10000); return $queue; }); $app['transformer.writer.collection'] = $app->share(function ($container) { return new Writer\Collection($container['transformer.routing.queue']); }); $this->provideTemplatingSystem($app); $app['transformer'] = $app->share(function ($container) { $transformer = new Transformer($container['transformer.template.collection'], $container['transformer.writer.collection']); $transformer->setBehaviours($container['transformer.behaviour.collection']); return $transformer; }); $app->command(new TransformCommand($app['descriptor.builder'], $app['transformer'], $app['compiler'])); $app->command(new ListCommand($app['transformer.template.factory'])); }
/** * @covers \phpDocumentor\Transformer\Router\Queue::match */ public function testNullIsReturnedWhenNoMatchingRuleCanBeFound() { $nodeName = 'test'; $this->fixture->insert($this->givenARouterMatchingNodeWithResult($nodeName, false), 0); // Act $result = $this->fixture->match($nodeName); // Assert $this->assertNull($result); }
/** * Registers services on the given app. * * @param Application $app An Application instance */ public function register(Application $app) { if (!isset($app['descriptor.builder'])) { throw new Exception\MissingDependencyException('The builder object that is used to construct the ProjectDescriptor is missing'); } if (!isset($app['serializer'])) { throw new Exception\MissingDependencyException('The serializer object that is used to read the template configuration with is missing'); } $templateDir = __DIR__ . '/../../../data/templates'; // vendored installation if (file_exists(__DIR__ . '/../../../../templates')) { $templateDir = __DIR__ . '/../../../../templates'; } // parameters $app['transformer.template.location'] = $templateDir; $app['linker.substitutions'] = array('phpDocumentor\\Descriptor\\ProjectDescriptor' => array('files'), 'phpDocumentor\\Descriptor\\FileDescriptor' => array('tags', 'classes', 'interfaces', 'traits'), 'phpDocumentor\\Descriptor\\ClassDescriptor' => array('tags', 'parent', 'interfaces', 'constants', 'properties', 'methods'), 'phpDocumentor\\Descriptor\\InterfaceDescriptor' => array('tags', 'parent', 'constants', 'methods'), 'phpDocumentor\\Descriptor\\TraitDescriptor' => array('tags', 'properties', 'methods'), 'phpDocumentor\\Descriptor\\MethodDescriptor' => array('tags', 'arguments'), 'phpDocumentor\\Descriptor\\ArgumentDescriptor' => array('types'), 'phpDocumentor\\Descriptor\\PropertyDescriptor' => array('tags', 'types'), 'phpDocumentor\\Descriptor\\ConstantDescriptor' => array('tags', 'types'), 'phpDocumentor\\Descriptor\\Tag\\ParamDescriptor' => array('types'), 'phpDocumentor\\Descriptor\\Tag\\ReturnDescriptor' => array('types'), 'phpDocumentor\\Descriptor\\Tag\\SeeDescriptor' => array('reference')); // services $app['compiler'] = $app->share(function ($container) { $compiler = new Compiler(); $compiler->insert(new ElementsIndexBuilder(), ElementsIndexBuilder::COMPILER_PRIORITY); $compiler->insert(new PackageTreeBuilder(), PackageTreeBuilder::COMPILER_PRIORITY); $compiler->insert(new NamespaceTreeBuilder(), NamespaceTreeBuilder::COMPILER_PRIORITY); $compiler->insert($container['linker'], Linker::COMPILER_PRIORITY); $compiler->insert($container['transformer'], Transformer::COMPILER_PRIORITY); $compiler->insert(new Debug($container['monolog'], $container['descriptor.analyzer']), Debug::COMPILER_PRIORITY); return $compiler; }); $app['linker'] = $app->share(function ($app) { return new Linker($app['linker.substitutions']); }); $app['transformer.behaviour.collection'] = $app->share(function () { return new Behaviour\Collection(); }); $app['transformer.routing.queue'] = $app->share(function () { $queue = new Router\Queue(); // TODO: load from app configuration instead of hardcoded $queue->insert(new Router\StandardRouter(), 10000); return $queue; }); $app['transformer.writer.collection'] = $app->share(function ($container) { return new Writer\Collection($container['transformer.routing.queue']); }); $app['transformer.template.collection'] = $app->share(function ($container) { return new Template\Collection($container['transformer.template.location'], $container['serializer']); }); $app['transformer'] = $app->share(function ($container) { $transformer = new Transformer($container['transformer.template.collection'], $container['transformer.writer.collection']); $transformer->setBehaviours($container['transformer.behaviour.collection']); return $transformer; }); $app->command(new TransformCommand($app['descriptor.builder'], $app['transformer'], $app['compiler'])); $app->command(new ListCommand()); }