|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the reliforp/reli-prof 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 Reli\Inspector\Settings\DaemonSettings; |
|
15
|
|
|
|
|
16
|
|
|
use PhpCast\NullableCast; |
|
|
|
|
|
|
17
|
|
|
use Reli\Inspector\Settings\InspectorSettingsException; |
|
18
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
|
|
19
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
|
|
20
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
use function filter_var; |
|
23
|
|
|
use function is_null; |
|
24
|
|
|
|
|
25
|
|
|
use const FILTER_VALIDATE_INT; |
|
26
|
|
|
|
|
27
|
|
|
final class DaemonSettingsFromConsoleInput |
|
28
|
|
|
{ |
|
29
|
|
|
/** @codeCoverageIgnore */ |
|
30
|
|
|
public function setOptions(Command $command): void |
|
31
|
|
|
{ |
|
32
|
|
|
$command |
|
33
|
|
|
->addOption( |
|
34
|
|
|
'target-regex', |
|
35
|
|
|
'P', |
|
36
|
|
|
InputOption::VALUE_REQUIRED, |
|
37
|
|
|
'regex to find target processes which have matching command-line (required)' |
|
38
|
|
|
) |
|
39
|
|
|
->addOption( |
|
40
|
|
|
'threads', |
|
41
|
|
|
'T', |
|
42
|
|
|
InputOption::VALUE_OPTIONAL, |
|
43
|
|
|
'number of workers (default: 8)' |
|
44
|
|
|
) |
|
45
|
|
|
; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @throws InspectorSettingsException |
|
50
|
|
|
*/ |
|
51
|
|
|
public function createSettings(InputInterface $input): DaemonSettings |
|
52
|
|
|
{ |
|
53
|
|
|
$threads = NullableCast::toString($input->getOption('threads')); |
|
54
|
|
|
if (is_null($threads)) { |
|
55
|
|
|
$threads = 8; |
|
56
|
|
|
} |
|
57
|
|
|
$threads = filter_var($threads, FILTER_VALIDATE_INT); |
|
58
|
|
|
if ($threads === false) { |
|
59
|
|
|
throw DaemonSettingsException::create(DaemonSettingsException::THREADS_IS_NOT_INTEGER); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
$target_regex = $input->getOption('target-regex'); |
|
63
|
|
|
if (is_null($target_regex)) { |
|
64
|
|
|
throw DaemonSettingsException::create(DaemonSettingsException::TARGET_REGEX_IS_NOT_SPECIFIED); |
|
65
|
|
|
} |
|
66
|
|
|
if (!is_string($target_regex)) { |
|
67
|
|
|
throw DaemonSettingsException::create( |
|
68
|
|
|
DaemonSettingsException::TARGET_REGEX_IS_NOT_STRING |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return new DaemonSettings('{' . $target_regex . '}', $threads); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
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