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\Converter\RestructuredText; |
||
17 | |||
18 | use Monolog\Logger; |
||
19 | use phpDocumentor\Plugin\Scrybe\Converter\ConverterInterface; |
||
20 | |||
21 | /** |
||
22 | * This is a customized RestructuredText document to register Scrybe-specific directives, roles and options. |
||
23 | * |
||
24 | * The following directives are introduced using this class: |
||
25 | * |
||
26 | * - toctree, a directive used to insert table of contents into documents. |
||
27 | * - image, an overridden version of `image` that collects the assets. |
||
28 | * - figure, an overridden version of the `figure` that collects the assets. |
||
29 | * |
||
30 | * The following roles are introduced in this class: |
||
31 | * |
||
32 | * - doc, a reference to an external piece of documentation. |
||
33 | * |
||
34 | * @property \ezcDocumentRstOptions $options |
||
35 | */ |
||
36 | class Document extends \ezcDocumentRst |
||
37 | { |
||
38 | /** |
||
39 | * Fileset containing the project root and list of files in this run. |
||
40 | */ |
||
41 | protected $file; |
||
42 | |||
43 | /** |
||
44 | * Converter used to retrieve global assets from. |
||
45 | * |
||
46 | * The converter contains global assets, such as the Table of Contents, that can be used in directives and roles. |
||
47 | * |
||
48 | * @var ConverterInterface |
||
49 | */ |
||
50 | protected $converter; |
||
51 | |||
52 | /** |
||
53 | * Sets the Scrybe-specific options, registers the roles and directives and loads the file. |
||
54 | */ |
||
55 | public function __construct(ConverterInterface $converter, $file) |
||
0 ignored issues
–
show
|
|||
56 | { |
||
57 | parent::__construct(); |
||
58 | |||
59 | $this->options->xhtmlVisitor = 'phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\Visitors\Creator'; |
||
60 | $this->options->errorReporting = E_PARSE | E_ERROR; |
||
61 | |||
62 | $this->registerDirective( |
||
63 | 'code-block', |
||
64 | 'phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\Directives\CodeBlock' |
||
65 | ); |
||
66 | $this->registerDirective( |
||
67 | 'toctree', |
||
68 | 'phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\Directives\Toctree' |
||
69 | ); |
||
70 | $this->registerDirective( |
||
71 | 'image', |
||
72 | 'phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\Directives\Image' |
||
73 | ); |
||
74 | $this->registerDirective( |
||
75 | 'figure', |
||
76 | 'phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\Directives\Figure' |
||
77 | ); |
||
78 | $this->registerRole( |
||
79 | 'doc', |
||
80 | 'phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\Roles\Doc' |
||
81 | ); |
||
82 | |||
83 | //$this->file = $file; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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...
|
|||
84 | $this->converter = $converter; |
||
85 | |||
86 | //$this->loadString($file->fread()); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
82% 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...
|
|||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Returns the converter responsible for converting this object. |
||
91 | * |
||
92 | * @return ConverterInterface |
||
93 | */ |
||
94 | public function getConverter() |
||
95 | { |
||
96 | return $this->converter; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Returns the file associated with this document. |
||
101 | */ |
||
102 | public function getFile() |
||
103 | { |
||
104 | return $this->file; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Sends the errors of the given Rst document to the logger as a block. |
||
109 | * |
||
110 | * If a fatal error occurred then this can be passed as the $fatal argument and is shown as such. |
||
111 | * |
||
112 | * @param \Exception|null $fatal |
||
113 | */ |
||
114 | public function logStats($fatal, Logger $logger) |
||
115 | { |
||
116 | if (!$this->getErrors() && !$fatal) { |
||
117 | return; |
||
118 | } |
||
119 | |||
120 | /** @var \Exception $error */ |
||
121 | foreach ($this->getErrors() as $error) { |
||
122 | $logger->warning(' ' . $error->getMessage()); |
||
123 | } |
||
124 | |||
125 | if ($fatal) { |
||
126 | $logger->error(' ' . $fatal->getMessage()); |
||
127 | } |
||
128 | } |
||
129 | } |
||
130 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.