imports:
  - { resource: 'pipelines.yaml' }
  - { resource: 'reflection.yaml' }
  - { resource: 'stages.yaml' }
  - { resource: 'guides.yaml' }

services:
    _defaults:
        autowire: true
        autoconfigure: true
        public: false
        bind:
          $defaultTemplateName: 'default'
          $globalTemplatesPath: "@=service('phpDocumentor\\\\Application').templateDirectory()"
          $servicesWithCustomSettings: !tagged_iterator app.with_custom_settings
    _instanceof:
      # Tag any service that implements WithCustomSettings so that we can auto-register them
      # with the ProjectDescriptor
      phpDocumentor\Descriptor\ProjectDescriptor\WithCustomSettings:
        tags: ['app.with_custom_settings']

      phpDocumentor\Descriptor\Filter\FilterInterface:
        tags: ['phpdoc.descriptor.filter']

      phpDocumentor\Transformer\Writer\WriterAbstract:
        tags: ['phpdoc.transformer.writer']

    ###################################################################################
    ## Autoloading definitions for whole namespaces ###################################
    ###################################################################################

    phpDocumentor\:
        resource: '../src/phpDocumentor/*'
        exclude:
          - '../src/phpDocumentor/Linker/Linker'
          - '../src/phpDocumentor/Compiler'
          - '../src/phpDocumentor/**/Messages'
          - '../src/phpDocumentor/Pipeline/Stage'
          - '../src/phpDocumentor/Transformer/**/{Event, Exception}/{**}'
          - '../src/phpDocumentor/Guides/RenderCommand.php'
          - '../src/phpDocumentor/Guides/Handlers/*Handler.php'

    phpDocumentor\Console\:
        resource: '../src/phpDocumentor/Console'

    phpDocumentor\Parser\:
        resource: '../src/phpDocumentor/Parser'
        exclude: '../src/phpDocumentor/Parser/Middleware'

    phpDocumentor\Parser\Middleware\:
        resource: '../src/phpDocumentor/Parser/Middleware'
        tags: [ { name: 'phpdoc.parser.middleware', priority: 1000 } ]

    phpDocumentor\Transformer\:
        resource: '../src/phpDocumentor/Transformer'
        exclude: '../src/phpDocumentor/Transformer/**/{Event, Exception}/{**}'

    ###################################################################################
    ## Autoloading definitions for individual classes #################################
    ###################################################################################

    Twig\Loader\FilesystemLoader: ~
    Twig\Environment:
      arguments:
        $loader: '@Twig\Loader\FilesystemLoader'

    application:
      alias: 'phpDocumentor\Application'
      public: true

    phpDocumentor\Application:
      public: true

    phpDocumentor\Console\Command\Project\RunCommand:
        arguments:
          - '@phpDocumentor\Descriptor\ProjectDescriptorBuilder'
          - '@phpdoc.pipeline.complete'
        tags: [ { name: 'console.command' } ]
        public: true

    phpDocumentor\Console\Command\Project\ListSettingsCommand:
        tags: [ { name: 'console.command' } ]

    phpDocumentor\Descriptor\Builder\AssemblerFactory:
        class: 'phpDocumentor\Descriptor\Builder\AssemblerFactory'
        factory: ['phpDocumentor\Descriptor\Builder\AssemblerFactory', 'createDefault']

    phpDocumentor\Descriptor\Filter\Filter:
        arguments:
          - !tagged_iterator 'phpdoc.descriptor.filter'

    phpDocumentor\Configuration\Configuration:
        factory: ['@phpDocumentor\Configuration\ConfigurationFactory', 'fromDefaultLocations']

    phpDocumentor\Configuration\ConfigurationFactory:
        arguments:
          $defaultFiles:
            - "@=service('application').getWorkingDir() ~ '/phpdoc.xml'"
            - "@=service('application').getWorkingDir() ~ '/phpdoc.dist.xml'"
            - "@=service('application').getWorkingDir() ~ '/phpdoc.xml.dist'"
            - "@=service('application').getWorkingDir() ~ '/.phpdoc.xml.dist'"
            - "@=service('application').getWorkingDir() ~ '/.phpdoc.xml'"
            - "@=service('application').getWorkingDir() ~ '/.phpdoc.dist.xml'"
          $symfonyConfigFactory: '@phpDocumentor\Configuration\SymfonyConfigFactory'

    phpDocumentor\Configuration\SymfonyConfigFactory:
      arguments:
          $definitions:
            '2': '@phpDocumentor\Configuration\Definition\Version2'
            '3': '@phpDocumentor\Configuration\Definition\Version3'

    phpDocumentor\Parser\Parser: ~

    phpDocumentor\Reflection\DocBlock\ExampleFinder: ~

    phpDocumentor\JsonPath\Executor: ~
    phpdoc.jsonpath.parser:
      class: phpDocumentor\JsonPath\Parser
      factory: ['phpDocumentor\JsonPath\Parser', 'createInstance']

    phpDocumentor\Descriptor\Query\Engine:
        arguments:
          $parser: '@phpdoc.jsonpath.parser'

    phpDocumentor\Parser\Middleware\StopwatchMiddleware:
        tags: [ { name: 'phpdoc.parser.middleware', priority: 5000 } ]

    # Increments the progress bar; by placing it in front of the cache you see the progress bar
    # increment, even while we only consume the cache
    phpDocumentor\Parser\Middleware\EmittingMiddleware:
        tags: [ { name: 'phpdoc.parser.middleware', priority: 4500 } ]

    phpDocumentor\Parser\Middleware\CacheMiddleware:
        arguments:
          $cache: '@files'
        tags: [ { name: 'phpdoc.parser.middleware', priority: 4000 } ]

    phpDocumentor\Parser\Middleware\ErrorHandlingMiddleware:
        tags: [ { name: 'phpdoc.parser.middleware', priority: 3000 } ]

    phpDocumentor\Parser\Middleware\ReEncodingMiddleware:
      tags: [ { name: 'phpdoc.parser.middleware', priority: 2000 } ]

    phpDocumentor\Descriptor\Cache\ProjectDescriptorMapper:
        arguments:
          $cache: '@descriptors'

    phpDocumentor\Parser\Cache\Locator:
      arguments:
        $files: '@files'
        $descriptors: '@descriptors'

    phpDocumentor\Extension\ExtensionHandler:
      factory: [ '\phpDocumentor\Extension\ExtensionHandler', 'getInstance' ]

    ###################################################################################
    ## Autoloading definitions for external services ##################################
    ###################################################################################

    files:
      class: phpDocumentor\Parser\Cache\FilesystemAdapter

    descriptors:
      class: phpDocumentor\Parser\Cache\FilesystemAdapter

    Monolog\Logger:
      public: true
      arguments:
        - 'app'

    Psr\Log\LoggerInterface:
      alias: 'Monolog\Logger'
      public: true

    Symfony\Component\EventDispatcher\EventDispatcher:
      public: true
    Symfony\Contracts\EventDispatcher\EventDispatcherInterface: '@Symfony\Component\EventDispatcher\EventDispatcher'
    Psr\EventDispatcher\EventDispatcherInterface: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'

    Symfony\Component\Stopwatch\Stopwatch: ~

    League\Flysystem\MountManager: ~

    League\CommonMark\Extension\DisallowedRawHtml\DisallowedRawHtmlExtension:
      tags: ['commonmark.extension']

    League\CommonMark\Extension\Table\TableExtension:
      tags: ['commonmark.extension']

    League\CommonMark\ConverterInterface: '@League\CommonMark\CommonMarkConverter'
    League\CommonMark\CommonMarkConverter:
      factory: ['@phpDocumentor\Transformer\Writer\Twig\CommonMarkFactory', 'createConverter']
      arguments:
        - !tagged 'commonmark.extension'


    ###################################################################################
    ## Writers ########################################################################
    ###################################################################################

    phpDocumentor\Transformer\Writer\Twig\EnvironmentFactory:
      arguments:
        $guidesTemplateBasePath: '%phpdoc.guides.base_template_paths%'

    phpDocumentor\Transformer\Writer\Collection:
        arguments: [!tagged_iterator { tag: 'phpdoc.transformer.writer' }]

    ###################################################################################
    ## Guides  ########################################################################
    ###################################################################################

    phpDocumentor\Guides\RestructuredText\TextRoles\PHPReference:
      tags:
        - { name: 'phpdoc.guides.parser.rst.text_role', 'domain': 'php'}


    phpDocumentor\Guides\Compiler\NodeTransformer\PHPReferenceNodeTransformer:
      tags:
        - { name: 'phpdoc.guides.compiler.nodeTransformers'}

    phpDocumentor\Guides\Compiler\NodeTransformer\ClassListNodeTransformer:
      tags:
        - { name: 'phpdoc.guides.compiler.nodeTransformers'}


    phpDocumentor\Guides\Compiler\NodeTransformer\ClassDiagramNodeTransformer:
      tags:
        - { name: 'phpdoc.guides.compiler.nodeTransformers'}

    phpDocumentor\Guides\RestructuredText\Directives\PHPClassList:
      arguments:
        $startingRule: '@phpDocumentor\Guides\RestructuredText\Parser\Productions\DirectiveContentRule'
      tags:
        - { name: 'phpdoc.guides.directive' }

    phpDocumentor\Guides\RestructuredText\Directives\PHPElementName:
      tags:
        - { name: 'phpdoc.guides.directive' }

    phpDocumentor\Guides\RestructuredText\Directives\PHPElementSummary:
      tags:
        - { name: 'phpdoc.guides.directive' }

    phpDocumentor\Guides\RestructuredText\Directives\PHPElementDescription:
      tags:
        - { name: 'phpdoc.guides.directive' }

    phpDocumentor\Guides\RestructuredText\Directives\ClassDiagram:
      tags:
        - { name: 'phpdoc.guides.directive' }
