|
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\Command\Inspector\Settings; |
|
15
|
|
|
|
|
16
|
|
|
use PhpProfiler\Command\CommandSettingsException; |
|
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
class TargetProcessSettings |
|
20
|
|
|
{ |
|
21
|
|
|
private const PHP_REGEX_DEFAULT = '.*/(php(74|7.4|80|8.0)?|php-fpm|libphp[78].*\.so)$'; |
|
22
|
|
|
private const LIBPTHREAD_REGEX_DEFAULT = '.*/libpthread.*\.so$'; |
|
23
|
|
|
|
|
24
|
|
|
public int $pid; |
|
25
|
|
|
public string $php_regex; |
|
26
|
|
|
public string $libpthread_regex; |
|
27
|
|
|
public ?string $php_path; |
|
28
|
|
|
public ?string $libpthread_path; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* GetTraceSettings constructor. |
|
32
|
|
|
* @param int $pid |
|
33
|
|
|
* @param string $php_regex |
|
34
|
|
|
* @param string $libpthread_regex |
|
35
|
|
|
* @param string|null $php_path |
|
36
|
|
|
* @param string|null $libpthread_path |
|
37
|
|
|
*/ |
|
38
|
|
|
public function __construct( |
|
39
|
|
|
int $pid, |
|
40
|
|
|
string $php_regex = self::PHP_REGEX_DEFAULT, |
|
41
|
|
|
string $libpthread_regex = self::LIBPTHREAD_REGEX_DEFAULT, |
|
42
|
|
|
?string $php_path = null, |
|
43
|
|
|
?string $libpthread_path = null |
|
44
|
|
|
) { |
|
45
|
|
|
$this->pid = $pid; |
|
46
|
|
|
$this->php_regex = '{' . $php_regex . '}'; |
|
47
|
|
|
$this->libpthread_regex = '{' . $libpthread_regex . '}'; |
|
48
|
|
|
$this->php_path = $php_path; |
|
49
|
|
|
$this->libpthread_path = $libpthread_path; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param InputInterface $input |
|
54
|
|
|
* @return self |
|
55
|
|
|
* @throws CommandSettingsException |
|
56
|
|
|
*/ |
|
57
|
|
|
public static function fromConsoleInput(InputInterface $input): self |
|
58
|
|
|
{ |
|
59
|
|
|
$pid = $input->getOption('pid'); |
|
60
|
|
|
if (is_null($pid)) { |
|
61
|
|
|
throw TargetProcessSettingsException::create( |
|
62
|
|
|
TargetProcessSettingsException::PID_NOT_SPECIFIED |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
$pid = filter_var($pid, FILTER_VALIDATE_INT); |
|
66
|
|
|
if ($pid === false) { |
|
67
|
|
|
throw TargetProcessSettingsException::create( |
|
68
|
|
|
TargetProcessSettingsException::PID_NOT_SPECIFIED |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
$php_regex = $input->getOption('php-regex') ?? self::PHP_REGEX_DEFAULT; |
|
73
|
|
|
if (!is_string($php_regex)) { |
|
74
|
|
|
throw TargetProcessSettingsException::create( |
|
75
|
|
|
TargetProcessSettingsException::PHP_REGEX_IS_NOT_STRING |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$libpthread_regex = $input->getOption('libpthread-regex') ?? self::LIBPTHREAD_REGEX_DEFAULT; |
|
80
|
|
|
if (!is_string($libpthread_regex)) { |
|
81
|
|
|
throw TargetProcessSettingsException::create( |
|
82
|
|
|
TargetProcessSettingsException::LIBPTHREAD_REGEX_IS_NOT_STRING |
|
83
|
|
|
); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
$php_path = $input->getOption('php-path'); |
|
87
|
|
|
if (!is_null($php_path) and !is_string($php_path)) { |
|
88
|
|
|
throw TargetProcessSettingsException::create( |
|
89
|
|
|
TargetProcessSettingsException::PHP_PATH_IS_NOT_STRING |
|
90
|
|
|
); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
$libpthread_path = $input->getOption('libpthread-path'); |
|
94
|
|
|
if (!is_null($libpthread_path) and !is_string($libpthread_path)) { |
|
95
|
|
|
throw TargetProcessSettingsException::create( |
|
96
|
|
|
TargetProcessSettingsException::LIBPTHREAD_PATH_IS_NOT_STRING |
|
97
|
|
|
); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
return new self($pid, $php_regex, $libpthread_regex, $php_path, $libpthread_path); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
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