These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | /** |
||
5 | * This file is part of phpDocumentor. |
||
6 | * |
||
7 | * For the full copyright and license information, please view the LICENSE |
||
8 | * file that was distributed with this source code. |
||
9 | * |
||
10 | * @author Mike van Riel <[email protected]> |
||
11 | * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
||
12 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
13 | * @link http://phpdoc.org |
||
14 | */ |
||
15 | |||
16 | namespace phpDocumentor\Plugin\Scrybe; |
||
17 | |||
18 | use phpDocumentor\Plugin\Scrybe\Converter\Definition\Factory; |
||
19 | use phpDocumentor\Plugin\Scrybe\Converter\Format\Format; |
||
20 | |||
21 | /** |
||
22 | * Creates and binds the components for the generation of manuals. |
||
23 | * |
||
24 | * Scrybe is a plugin that allows authors to write documentation in a markup format of their choosing and generate |
||
25 | * human-readable documentation from it. |
||
26 | */ |
||
27 | class ServiceProvider |
||
28 | { |
||
29 | const CONVERTER_FACTORY = 'converter-factory'; |
||
30 | |||
31 | const TEMPLATE_FACTORY = 'template-factory'; |
||
32 | |||
33 | const CONVERTER_DEFINITION_FACTORY = 'converter_definition_factory'; |
||
34 | |||
35 | const FORMATS = 'converter_formats'; |
||
36 | |||
37 | const CONVERTERS = 'converters'; |
||
38 | |||
39 | const TEMPLATE_FOLDER = 'template_folder'; |
||
40 | |||
41 | /** |
||
42 | * Registers services on the given app. |
||
43 | * |
||
44 | * @param Container $app An Application instance. |
||
45 | */ |
||
46 | public function register(Container $app): void |
||
47 | { |
||
48 | $app[self::TEMPLATE_FOLDER] = __DIR__ . '/data/templates/'; |
||
49 | $app[self::CONVERTERS] = [ |
||
50 | '\phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\ToHtml' => [Format::RST, Format::HTML], |
||
51 | ]; |
||
52 | |||
53 | $app[self::FORMATS] = function () { |
||
54 | return new Converter\Format\Collection(); |
||
55 | }; |
||
56 | |||
57 | $app[self::CONVERTER_DEFINITION_FACTORY] = function ($container) { |
||
58 | return new Factory($container[self::FORMATS]); |
||
59 | }; |
||
60 | |||
61 | $app[self::CONVERTER_FACTORY] = function ($container) { |
||
62 | return new Converter\Factory( |
||
63 | $container['converters'], |
||
64 | $container['converter_definition_factory'], |
||
65 | $container['monolog'] |
||
66 | ); |
||
67 | }; |
||
68 | |||
69 | $app[self::TEMPLATE_FACTORY] = function ($app) { |
||
70 | return new Template\Factory( |
||
71 | ['twig' => new Template\Twig($app[self::TEMPLATE_FOLDER])] |
||
72 | ); |
||
73 | }; |
||
74 | |||
75 | $this->addCommands($app); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Method responsible for adding the commands for this application. |
||
80 | */ |
||
81 | protected function addCommands(Container $app): void |
||
82 | { |
||
83 | if ($app instanceof Application) { |
||
84 | $app->command( |
||
85 | new Command\Manual\ToHtmlCommand(null, $app[self::TEMPLATE_FACTORY], $app[self::CONVERTER_FACTORY]) |
||
86 | ); |
||
87 | } |
||
88 | |||
89 | // FIXME: Disabled the ToLatex and ToPdf commands for now to prevent confusion of users. |
||
90 | // $this->command(new \phpDocumentor\Plugin\Scrybe\Command\Manual\ToLatexCommand()); |
||
0 ignored issues
–
show
|
|||
91 | // $this->command(new \phpDocumentor\Plugin\Scrybe\Command\Manual\ToPdfCommand()); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
92 | } |
||
93 | } |
||
94 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.