1 | <?php |
||
14 | class RemoveComments extends Pass |
||
15 | { |
||
16 | /** |
||
17 | * @var string[] List of annotations to preserve |
||
18 | */ |
||
19 | public $preserveAnnotations = [ |
||
20 | 'license' |
||
21 | ]; |
||
22 | |||
23 | /** |
||
24 | * @var bool Whether to remove DocBlock comments |
||
25 | */ |
||
26 | public $removeDocBlocks = true; |
||
27 | |||
28 | /** |
||
29 | * @var bool Whether to remove "C style" comments |
||
30 | */ |
||
31 | public $removeMultiLineComments = true; |
||
32 | |||
33 | /** |
||
34 | * @var bool Whether to remove "one-line" comments |
||
35 | */ |
||
36 | public $removeSingleLineComments = true; |
||
37 | |||
38 | /** |
||
39 | * @var TokenStream Token stream of the source being processed |
||
40 | */ |
||
41 | protected $stream; |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 13 | public function optimize(TokenStream $stream) |
|
59 | |||
60 | /** |
||
61 | * Generate a regexp that matches preserved annotations |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | 12 | protected function getRegexp() |
|
74 | |||
75 | /** |
||
76 | * Remove all docblocks tokens from given stream |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | 12 | protected function removeDocBlocks() |
|
95 | |||
96 | /** |
||
97 | * Remove current comment token from given stream |
||
98 | * |
||
99 | * @return void |
||
100 | */ |
||
101 | 8 | protected function removeComment() |
|
128 | |||
129 | /** |
||
130 | * Remove single-line and/or multi-line comments from given stream |
||
131 | * |
||
132 | * @return void |
||
133 | */ |
||
134 | 13 | protected function removeComments() |
|
152 | } |