|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the sj-i/php-profiler package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) sji <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace PhpProfiler\Inspector\Settings\OutputSettings; |
|
15
|
|
|
|
|
16
|
|
|
use Noodlehaus\Config; |
|
|
|
|
|
|
17
|
|
|
use PhpCast\NullableCast; |
|
|
|
|
|
|
18
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
|
|
19
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
|
|
20
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
final class OutputSettingsFromConsoleInput |
|
23
|
|
|
{ |
|
24
|
|
|
public function __construct( |
|
25
|
|
|
private Config $config |
|
26
|
|
|
) { |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** @codeCoverageIgnore */ |
|
30
|
|
|
public function setOptions(Command $command): void |
|
31
|
|
|
{ |
|
32
|
|
|
$command |
|
33
|
|
|
->addOption( |
|
34
|
|
|
'template', |
|
35
|
|
|
't', |
|
36
|
|
|
InputOption::VALUE_OPTIONAL, |
|
37
|
|
|
'template name (phpspy|phpspy_with_opcode|json_lines) (default: phpspy)' |
|
38
|
|
|
) |
|
39
|
|
|
->addOption( |
|
40
|
|
|
'output', |
|
41
|
|
|
'o', |
|
42
|
|
|
InputOption::VALUE_REQUIRED, |
|
43
|
|
|
'path to write output from this tool (default: stdout)' |
|
44
|
|
|
) |
|
45
|
|
|
; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function createSettings(InputInterface $input): OutputSettings |
|
49
|
|
|
{ |
|
50
|
|
|
$template = NullableCast::toString($input->getOption('template')); |
|
51
|
|
|
if (is_null($template)) { |
|
52
|
|
|
$template = NullableCast::toString($this->config->get('output.template.default')); |
|
53
|
|
|
if (is_null($template)) { |
|
54
|
|
|
throw OutputSettingsException::create( |
|
55
|
|
|
OutputSettingsException::TEMPLATE_NOT_SPECIFIED |
|
56
|
|
|
); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$output_path = $input->getOption('output'); |
|
61
|
|
|
if (!is_null($output_path) and !is_string($output_path)) { |
|
62
|
|
|
throw OutputSettingsException::create( |
|
63
|
|
|
OutputSettingsException::OUTPUT_IS_NOT_STRING |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
return new OutputSettings( |
|
68
|
|
|
$template, |
|
69
|
|
|
$output_path, |
|
70
|
|
|
); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths