1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* This file is part of phpDocumentor. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @author Mike van Riel <[email protected]> |
12
|
|
|
* @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
13
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
14
|
|
|
* @link http://phpdoc.org |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace phpDocumentor\Application\Stage\Parser; |
18
|
|
|
|
19
|
|
|
use phpDocumentor\Parser\Parser; |
20
|
|
|
use Psr\Log\LoggerInterface; |
21
|
|
|
use Psr\Log\LogLevel; |
22
|
|
|
|
23
|
|
|
final class ParseFiles |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var Parser |
27
|
|
|
*/ |
28
|
|
|
private $parser; |
29
|
|
|
/** |
30
|
|
|
* @var LoggerInterface |
31
|
|
|
*/ |
32
|
|
|
private $logger; |
33
|
|
|
|
34
|
|
|
public function __construct(Parser $parser, LoggerInterface $logger) |
35
|
|
|
{ |
36
|
|
|
$this->parser = $parser; |
37
|
|
|
$this->logger = $logger; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function __invoke(Payload $payload) |
41
|
|
|
{ |
42
|
|
|
$configuration = $payload->getConfig(); |
43
|
|
|
$apiConfig = $payload->getApiConfig(); |
44
|
|
|
|
45
|
|
|
$builder = $payload->getBuilder(); |
46
|
|
|
$builder->setVisibility($apiConfig); |
47
|
|
|
$builder->setMarkers($apiConfig['markers']); |
48
|
|
|
$builder->setIncludeSource($apiConfig['include-source']); |
49
|
|
|
|
50
|
|
|
$this->parser->setForced(!$configuration['phpdocumentor']['use-cache']); |
51
|
|
|
|
52
|
|
|
if ($builder->getProjectDescriptor()->getSettings()->isModified()) { |
53
|
|
|
$this->parser->setForced(true); |
54
|
|
|
$this->log( |
55
|
|
|
'One of the project\'s settings have changed, forcing a complete rebuild', |
56
|
|
|
LogLevel::NOTICE |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$this->parser->setEncoding($apiConfig['encoding']); |
61
|
|
|
$this->parser->setMarkers($apiConfig['markers']); |
62
|
|
|
$this->parser->setIgnoredTags($apiConfig['ignore-tags']); |
63
|
|
|
$this->parser->setValidate($apiConfig['validate']); |
64
|
|
|
$this->parser->setDefaultPackageName($apiConfig['default-package-name']); |
65
|
|
|
|
66
|
|
|
$this->log('Parsing files', LogLevel::NOTICE); |
67
|
|
|
$project = $this->parser->parse($payload->getFiles()); |
68
|
|
|
$payload->getBuilder()->build($project); |
69
|
|
|
|
70
|
|
|
return $payload; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Dispatches a logging request. |
75
|
|
|
* |
76
|
|
|
* @param string $priority The logging priority as declared in the LogLevel PSR-3 class. |
77
|
|
|
* @param string[] $parameters |
78
|
|
|
*/ |
79
|
|
|
private function log(string $message, string $priority = LogLevel::INFO, array $parameters = []): void |
80
|
|
|
{ |
81
|
|
|
$this->logger->log($priority, $message, $parameters); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|